diff options
author | Jessie Hernandez <jessie.hernandez@shell.com> | 2024-07-30 22:40:20 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-07-31 13:48:46 (GMT) |
commit | cee34d7ab302c666d28c9bc9b6b982c45a1474cf (patch) | |
tree | cae19a5657969ab3ac07aaf6431b6b71b434a410 | |
parent | 2903eb1963255296649f1cb17ac34751e31a8004 (diff) | |
download | CMake-cee34d7ab302c666d28c9bc9b6b982c45a1474cf.zip CMake-cee34d7ab302c666d28c9bc9b6b982c45a1474cf.tar.gz CMake-cee34d7ab302c666d28c9bc9b6b982c45a1474cf.tar.bz2 |
FindEXPAT: Implement EXPAT_USE_STATIC_LIBS for non-Windows platforms
In commit 302501ad36 (FindEXPAT: add a EXPAT_USE_STATIC_LIBS hint,
2023-06-19, v3.28.0-rc1~447^2) this flag was introduced but was only
implemented for windows like systems. To make the flag complete and also
behave as you would expect on non-windows systems cmake also looks for
`.a` files now.
Fixes: #26177
-rw-r--r-- | Modules/FindEXPAT.cmake | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake index 398a415..04a8715 100644 --- a/Modules/FindEXPAT.cmake +++ b/Modules/FindEXPAT.cmake @@ -39,6 +39,10 @@ Hints Set to ``TRUE`` to use static libraries. + .. versionadded:: 3.31 + + Implemented on non-Windows platforms. + #]=======================================================================] cmake_policy(PUSH) @@ -72,10 +76,24 @@ if(NOT EXPAT_LIBRARY) set(_expat_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) endif() + if(DEFINED CMAKE_FIND_LIBRARY_SUFFIXES) + set(_expat_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}") + else() + set(_expat_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + endif() + if(WIN32) list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib") endif() + if (EXPAT_USE_STATIC_LIBS) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) + endif() + endif() + # Look for the library. find_library(EXPAT_LIBRARY_RELEASE NAMES ${EXPAT_NAMES} NAMES_PER_DIR HINTS ${PC_EXPAT_LIBRARY_DIRS} PATH_SUFFIXES lib) find_library(EXPAT_LIBRARY_DEBUG NAMES ${EXPAT_NAMES_DEBUG} NAMES_PER_DIR HINTS ${PC_EXPAT_LIBRARY_DIRS} PATH_SUFFIXES lib) @@ -87,6 +105,12 @@ if(NOT EXPAT_LIBRARY) set(CMAKE_FIND_LIBRARY_PREFIXES) endif() + if(DEFINED _expat_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${_expat_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}") + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES) + endif() + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(EXPAT) endif() |