diff options
author | Brad King <brad.king@kitware.com> | 2021-04-27 17:54:44 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-04-27 17:54:51 (GMT) |
commit | 95afd879176256b17db44682d0664b87827c599b (patch) | |
tree | bebd7e83c8201b3e405285c9089b8f94dc321fac | |
parent | 970f175d8879d88eccb035a9d5254f4052608fb1 (diff) | |
parent | 404025b00cc3f913c5e8f04412cd6a5a26ebdfb7 (diff) | |
download | CMake-95afd879176256b17db44682d0664b87827c599b.zip CMake-95afd879176256b17db44682d0664b87827c599b.tar.gz CMake-95afd879176256b17db44682d0664b87827c599b.tar.bz2 |
Merge topic 'FindIconv-no-libc'
404025b00c FindIconv: Avoid explicitly finding C runtime library
8b30e7adfb FindIntl: Use explicit find_library signature NAMES keyword
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
Merge-request: !6046
-rw-r--r-- | Modules/FindIconv.cmake | 50 | ||||
-rw-r--r-- | Modules/FindIntl.cmake | 4 |
2 files changed, 30 insertions, 24 deletions
diff --git a/Modules/FindIconv.cmake b/Modules/FindIconv.cmake index 5ec12b2..566330f 100644 --- a/Modules/FindIconv.cmake +++ b/Modules/FindIconv.cmake @@ -122,26 +122,28 @@ if(NOT DEFINED Iconv_IS_BUILT_IN) endif() endif() -if(NOT Iconv_IS_BUILT_IN) +set(_Iconv_REQUIRED_VARS) +if(Iconv_IS_BUILT_IN) + set(_Iconv_REQUIRED_VARS _Iconv_IS_BUILT_IN_MSG) + set(_Iconv_IS_BUILT_IN_MSG "built in to C library") +else() + set(_Iconv_REQUIRED_VARS Iconv_LIBRARY Iconv_INCLUDE_DIR) + find_path(Iconv_INCLUDE_DIR NAMES "iconv.h" DOC "iconv include directory") set(Iconv_LIBRARY_NAMES "iconv" "libiconv") -else() - set(Iconv_INCLUDE_DIR "" CACHE FILEPATH "iconv include directory") - set(Iconv_LIBRARY_NAMES "c") -endif() - -find_library(Iconv_LIBRARY - NAMES ${Iconv_LIBRARY_NAMES} - NAMES_PER_DIR - DOC "iconv library (potentially the C library)") + mark_as_advanced(Iconv_INCLUDE_DIR) -mark_as_advanced(Iconv_INCLUDE_DIR) -mark_as_advanced(Iconv_LIBRARY) + find_library(Iconv_LIBRARY + NAMES iconv libiconv + NAMES_PER_DIR + DOC "iconv library (if not in the C library)") + mark_as_advanced(Iconv_LIBRARY) +endif() # NOTE: glibc's iconv.h does not define _LIBICONV_VERSION -if(Iconv_INCLUDE_DIR AND NOT Iconv_IS_BUILT_IN) +if(Iconv_INCLUDE_DIR AND EXISTS "${Iconv_INCLUDE_DIR}/iconv.h") file(STRINGS ${Iconv_INCLUDE_DIR}/iconv.h Iconv_VERSION_DEFINE REGEX "_LIBICONV_VERSION (.*)") if(Iconv_VERSION_DEFINE MATCHES "(0x[A-Fa-f0-9]+)") @@ -160,19 +162,21 @@ if(Iconv_INCLUDE_DIR AND NOT Iconv_IS_BUILT_IN) endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -if(NOT Iconv_IS_BUILT_IN) - find_package_handle_standard_args(Iconv REQUIRED_VARS Iconv_LIBRARY Iconv_INCLUDE_DIR - VERSION_VAR Iconv_VERSION) -else() - find_package_handle_standard_args(Iconv REQUIRED_VARS Iconv_LIBRARY) -endif() +find_package_handle_standard_args(Iconv + REQUIRED_VARS ${_Iconv_REQUIRED_VARS} + VERSION_VAR Iconv_VERSION) if(Iconv_FOUND) - set(Iconv_INCLUDE_DIRS "${Iconv_INCLUDE_DIR}") - set(Iconv_LIBRARIES "${Iconv_LIBRARY}") + if(Iconv_IS_BUILT_IN) + set(Iconv_INCLUDE_DIRS "") + set(Iconv_LIBRARIES "") + else() + set(Iconv_INCLUDE_DIRS "${Iconv_INCLUDE_DIR}") + set(Iconv_LIBRARIES "${Iconv_LIBRARY}") + endif() if(NOT TARGET Iconv::Iconv) add_library(Iconv::Iconv INTERFACE IMPORTED) + set_property(TARGET Iconv::Iconv PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${Iconv_INCLUDE_DIRS}") + set_property(TARGET Iconv::Iconv PROPERTY INTERFACE_LINK_LIBRARIES "${Iconv_LIBRARIES}") endif() - set_property(TARGET Iconv::Iconv PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${Iconv_INCLUDE_DIRS}") - set_property(TARGET Iconv::Iconv PROPERTY INTERFACE_LINK_LIBRARIES "${Iconv_LIBRARIES}") endif() diff --git a/Modules/FindIntl.cmake b/Modules/FindIntl.cmake index 038f4da..95eeabd 100644 --- a/Modules/FindIntl.cmake +++ b/Modules/FindIntl.cmake @@ -129,7 +129,9 @@ else() DOC "libintl include directory") mark_as_advanced(Intl_INCLUDE_DIR) - find_library(Intl_LIBRARY "intl" "libintl" NAMES_PER_DIR + find_library(Intl_LIBRARY + NAMES "intl" "libintl" + NAMES_PER_DIR DOC "libintl libraries (if not in the C library)") mark_as_advanced(Intl_LIBRARY) endif() |