From 58725e3ff089be792a32fc067390a052d8e9e72d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 9 Feb 2015 10:52:23 +0000 Subject: [PATCH] Find iconv. --- CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3f13e519..9038f6468 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -737,6 +737,37 @@ int main(int argc, char** argv) { return cmkcheckweak == NULL; }" HAVE_WEAK_SYMBOLS) +IF(NOT ICONV_INCLUDE_DIR OR NOT ICONV_LIBRARIES) + FIND_PATH(ICONV_INCLUDE_DIR iconv.h) + FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c) + IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + SET(ICONV_FOUND TRUE) + ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + LIST(APPEND CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) + LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) + + IF(ICONV_FOUND) + CHECK_C_SOURCE_COMPILES(" +#include +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_SECOND_ARGUMENT_IS_CONST) + ENDIF(ICONV_FOUND) + + IF(ICONV_FOUND) + MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}") + ELSE(ICONV_FOUND) + MESSAGE(FATAL_ERROR "Could not find Iconv") + ENDIF(ICONV_FOUND) +ENDIF(NOT ICONV_INCLUDE_DIR OR NOT ICONV_LIBRARIES) + # Check macros CHECK_SYMBOL_EXISTS(PATH_MAX limits.h HAVE_PATH_MAX) -- 2.39.5