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
9 if(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
10 # Already in cache, be silent
11 set(ICONV_FIND_QUIETLY TRUE)
14 find_path(ICONV_INCLUDE_DIR iconv.h)
15 check_function_exists(iconv_open libc_has_iconv)
16 find_library(iconv_lib NAMES iconv libiconv libiconv-2 c)
18 if(ICONV_INCLUDE_DIR AND libc_has_iconv)
20 set(ICONV_LIBRARIES "")
21 if(NOT ICONV_FIND_QUIETLY)
22 message(STATUS "Found Iconv: provided by libc")
23 endif(NOT ICONV_FIND_QUIETLY)
24 elseif(ICONV_INCLUDE_DIR AND iconv_lib)
26 # split iconv into -L and -l linker options, so we can
27 # set them for pkg-config
28 get_filename_component(iconv_path ${iconv_lib} PATH)
29 get_filename_component(iconv_name ${iconv_lib} NAME_WE)
30 string(REGEX REPLACE "^lib" "" iconv_name ${iconv_name})
31 set(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}")
33 if(NOT ICONV_FIND_QUIETLY)
34 message(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
37 if(Iconv_FIND_REQUIRED)
38 message(FATAL_ERROR "Could not find Iconv")
39 endif(Iconv_FIND_REQUIRED)