diff options
Diffstat (limited to 'cmake/modules/FindIconv.cmake')
| -rw-r--r-- | cmake/modules/FindIconv.cmake | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cmake/modules/FindIconv.cmake b/cmake/modules/FindIconv.cmake new file mode 100644 index 0000000..8ee01fb --- /dev/null +++ b/cmake/modules/FindIconv.cmake | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | #.rst: | ||
| 2 | # FindICONV | ||
| 3 | # -------- | ||
| 4 | # Finds the ICONV library | ||
| 5 | # | ||
| 6 | # This will will define the following variables:: | ||
| 7 | # | ||
| 8 | # ICONV_FOUND - system has ICONV | ||
| 9 | # ICONV_INCLUDE_DIRS - the ICONV include directory | ||
| 10 | # ICONV_LIBRARIES - the ICONV libraries | ||
| 11 | # | ||
| 12 | # and the following imported targets:: | ||
| 13 | # | ||
| 14 | # ICONV::ICONV - The ICONV library | ||
| 15 | |||
| 16 | find_path(ICONV_INCLUDE_DIR NAMES iconv.h) | ||
| 17 | |||
| 18 | find_library(ICONV_LIBRARY NAMES iconv libiconv c) | ||
| 19 | |||
| 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() | ||
| 27 | |||
| 28 | include(FindPackageHandleStandardArgs) | ||
| 29 | find_package_handle_standard_args(Iconv | ||
| 30 | REQUIRED_VARS ICONV_LIBRARY ICONV_INCLUDE_DIR HAVE_ICONV_FUNCTION) | ||
| 31 | |||
| 32 | if(ICONV_FOUND) | ||
| 33 | set(ICONV_LIBRARIES ${ICONV_LIBRARY}) | ||
| 34 | set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR}) | ||
| 35 | |||
| 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() | ||
| 43 | |||
| 44 | mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARY HAVE_ICONV_FUNCTION) | ||
