2007-05-21 16:30:04 +00:00
|
|
|
#
|
2018-01-05 00:54:18 +01:00
|
|
|
# Copyright (C) 2003-2018 Sébastien Helleu <flashcode@flashtux.org>
|
2010-06-22 19:46:28 +02:00
|
|
|
#
|
|
|
|
# This file is part of WeeChat, the extensible chat client.
|
|
|
|
#
|
|
|
|
# WeeChat is free software; you can redistribute it and/or modify
|
2007-05-21 16:30:04 +00:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-07-02 12:25:13 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2007-05-21 16:30:04 +00:00
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
2010-06-22 19:46:28 +02:00
|
|
|
# WeeChat is distributed in the hope that it will be useful,
|
2007-05-21 16:30:04 +00:00
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2010-06-22 19:46:28 +02:00
|
|
|
# along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
2007-05-21 16:30:04 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# - Find Iconv
|
2010-03-19 23:33:14 +01:00
|
|
|
# This module finds if libiconv is installed and determines where
|
2007-05-21 16:30:04 +00:00
|
|
|
# the include files and libraries are.
|
|
|
|
#
|
|
|
|
# This code sets the following variables:
|
|
|
|
#
|
|
|
|
# ICONV_INCLUDE_PATH = path to where <iconv.h> can be found
|
|
|
|
# ICONV_LIBRARY = path to where libiconv.so* can be found (on non glibc based systems)
|
|
|
|
#
|
|
|
|
# ICONV_FOUND = is iconv usable on system?
|
|
|
|
|
2014-04-12 18:00:27 +02:00
|
|
|
if(ICONV_FOUND)
|
2007-05-21 16:30:04 +00:00
|
|
|
# Already in cache, be silent
|
|
|
|
set(ICONV_FIND_QUIETLY TRUE)
|
2014-04-12 18:00:27 +02:00
|
|
|
endif()
|
2007-05-21 16:30:04 +00:00
|
|
|
|
2014-04-12 18:00:27 +02:00
|
|
|
include(CheckLibraryExists)
|
|
|
|
include(CheckFunctionExists)
|
2010-01-28 12:26:39 +01:00
|
|
|
|
2014-04-12 18:00:27 +02:00
|
|
|
find_path(ICONV_INCLUDE_PATH
|
2007-05-21 16:30:04 +00:00
|
|
|
NAMES iconv.h
|
|
|
|
PATHS /usr/include /usr/local/include /usr/pkg/include
|
|
|
|
)
|
|
|
|
|
2014-04-12 18:00:27 +02:00
|
|
|
find_library(ICONV_LIBRARY
|
2007-05-21 16:30:04 +00:00
|
|
|
NAMES iconv
|
|
|
|
PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib
|
|
|
|
)
|
|
|
|
|
2014-04-12 18:00:27 +02:00
|
|
|
if(ICONV_INCLUDE_PATH)
|
|
|
|
if(ICONV_LIBRARY)
|
2015-09-02 14:56:26 +02:00
|
|
|
check_library_exists("${ICONV_LIBRARY}" libiconv_open "" LIBICONV_OPEN_FOUND)
|
|
|
|
check_library_exists("${ICONV_LIBRARY}" iconv_open "" ICONV_OPEN_FOUND)
|
2014-04-12 18:00:27 +02:00
|
|
|
if(LIBICONV_OPEN_FOUND OR ICONV_OPEN_FOUND)
|
|
|
|
set(ICONV_FOUND TRUE)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
check_function_exists(iconv_open ICONV_FOUND)
|
|
|
|
endif()
|
|
|
|
endif()
|
2007-05-21 16:30:04 +00:00
|
|
|
|
|
|
|
include(CheckCSourceCompiles)
|
2007-05-26 19:15:46 +00:00
|
|
|
|
2014-04-12 18:00:27 +02:00
|
|
|
if(ICONV_LIBRARY)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY})
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_PATH})
|
|
|
|
endif()
|
2007-05-26 19:15:46 +00:00
|
|
|
|
2014-04-12 18:00:27 +02:00
|
|
|
set(CMAKE_REQUIRED_FLAGS -Werror)
|
2007-05-21 16:30:04 +00:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <iconv.h>
|
|
|
|
int main(){
|
|
|
|
iconv_t conv = 0;
|
|
|
|
const char* in = 0;
|
|
|
|
size_t ilen = 0;
|
|
|
|
char* out = 0;
|
|
|
|
size_t olen = 0;
|
|
|
|
iconv(conv, &in, &ilen, &out, &olen);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" ICONV_2ARG_IS_CONST)
|
2014-04-12 18:00:27 +02:00
|
|
|
|
|
|
|
mark_as_advanced(
|
2007-05-21 16:30:04 +00:00
|
|
|
ICONV_INCLUDE_PATH
|
|
|
|
ICONV_LIBRARY
|
|
|
|
ICONV_FOUND
|
|
|
|
)
|