1 # Originally found here:
2 # https://github.com/onyx-intl/cmake_modules/blob/master/FindIconv.cmake
5 # Once done this will define
7 # ICONV_FOUND - system has Iconv
8 # ICONV_INCLUDE_DIR - the Iconv include directory
9 # ICONV_LIBRARIES - Link these to use Iconv
10 # ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
12 include(CheckCXXSourceCompiles)
14 IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
15 # Already in cache, be silent
16 SET(ICONV_FIND_QUIETLY TRUE)
17 ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
19 FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
21 FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
23 IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
25 ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
27 set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
28 set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
30 check_cxx_source_compiles("
38 iconv(conv, &in, &ilen, &out, &olen);
41 " ICONV_SECOND_ARGUMENT_IS_CONST )
43 set(CMAKE_REQUIRED_INCLUDES)
44 set(CMAKE_REQUIRED_LIBRARIES)
47 IF(NOT ICONV_FIND_QUIETLY)
48 MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
49 ENDIF(NOT ICONV_FIND_QUIETLY)
51 IF(Iconv_FIND_REQUIRED)
52 MESSAGE(FATAL_ERROR "Could not find Iconv")
53 ENDIF(Iconv_FIND_REQUIRED)
59 ICONV_SECOND_ARGUMENT_IS_CONST