Merge pull request #23092 from webosbrew/feature/webOS
[xbmc.git] / cmake / modules / FindIconv.cmake
blobae7d8d7f5789756ff0c7da10d4e9de152ed9d1b8
1 #.rst:
2 # FindICONV
3 # --------
4 # Finds the ICONV library
6 # This will define the following variables::
8 # ICONV_FOUND - system has ICONV
9 # ICONV_INCLUDE_DIRS - the ICONV include directory
10 # ICONV_LIBRARIES - the ICONV libraries
12 # and the following imported targets::
14 #   ICONV::ICONV   - The ICONV library
16 find_path(ICONV_INCLUDE_DIR NAMES iconv.h)
18 find_library(ICONV_LIBRARY NAMES iconv libiconv c)
20 set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY})
21 check_function_exists(iconv HAVE_ICONV_FUNCTION)
22 if(NOT HAVE_ICONV_FUNCTION)
23   check_function_exists(libiconv HAVE_LIBICONV_FUNCTION2)
24   set(HAVE_ICONV_FUNCTION ${HAVE_LIBICONV_FUNCTION2})
25   unset(HAVE_LIBICONV_FUNCTION2)
26 endif()
28 include(FindPackageHandleStandardArgs)
29 find_package_handle_standard_args(Iconv
30                                   REQUIRED_VARS ICONV_LIBRARY ICONV_INCLUDE_DIR HAVE_ICONV_FUNCTION)
32 if(ICONV_FOUND)
33   set(ICONV_LIBRARIES ${ICONV_LIBRARY})
34   set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR})
36   if(NOT TARGET ICONV::ICONV)
37     add_library(ICONV::ICONV UNKNOWN IMPORTED)
38     set_target_properties(ICONV::ICONV PROPERTIES
39                                      IMPORTED_LOCATION "${ICONV_LIBRARY}"
40                                      INTERFACE_INCLUDE_DIRECTORIES "${ICONV_INCLUDE_DIR}")
41   endif()
42 endif()
44 mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARY HAVE_ICONV_FUNCTION)