2 # Once done this will define
4 # ICONV_FOUND - system has Iconv
5 # ICONV_INCLUDE_DIR - the Iconv include directory
6 # ICONV_LIBRARIES - Link these to use Iconv
7 # ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
9 include(CheckCCompilerFlag)
10 include(CheckCSourceCompiles)
12 IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
13 # Already in cache, be silent
14 SET(ICONV_FIND_QUIETLY TRUE)
15 ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
17 FIND_PATH(ICONV_INCLUDE_DIR iconv.h HINTS /sw/include/ PATHS /opt/local)
19 FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv c PATHS /opt/local)
21 IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
25 set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
26 set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
28 check_c_compiler_flag("-Werror" ICONV_HAVE_WERROR)
29 set (CMAKE_C_FLAGS_BACKUP "${CMAKE_C_FLAGS}")
31 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
33 check_c_source_compiles("
41 iconv(conv, &in, &ilen, &out, &olen);
44 " ICONV_SECOND_ARGUMENT_IS_CONST )
45 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BACKUP}")
47 set(CMAKE_REQUIRED_INCLUDES)
48 set(CMAKE_REQUIRED_LIBRARIES)
51 IF(NOT ICONV_FIND_QUIETLY)
52 MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
55 IF(Iconv_FIND_REQUIRED)
56 MESSAGE(FATAL_ERROR "Could not find Iconv")
63 ICONV_SECOND_ARGUMENT_IS_CONST