mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2026-01-26 21:41:34 +03:00
CMake: Fix dlopen check
Systems can have dlopen symbol in various libraries. For example, on Haiku, dlopen is in 'root' library, which is linked by default. The CMAKE_DL_LIBS variable is automatically set by CMake and contains the name of the library or libraries that contain dynamic loading functionality. CMakePushCheckState checks for the symbol in isolation, so the required libraries variable can be modified.
This commit is contained in:
@@ -20,6 +20,7 @@ include(CheckStructHasMember)
|
||||
include(CheckSymbolExists)
|
||||
include(CMakeDependentOption)
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(CMakePushCheckState)
|
||||
include(FindPkgConfig)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
@@ -323,10 +324,13 @@ target_include_directories(
|
||||
)
|
||||
|
||||
if(LIBXML2_WITH_MODULES)
|
||||
check_library_exists(dl dlopen "" HAVE_DLOPEN)
|
||||
cmake_push_check_state(RESET)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
|
||||
check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN)
|
||||
cmake_pop_check_state()
|
||||
if(HAVE_DLOPEN)
|
||||
target_link_libraries(LibXml2 PRIVATE dl)
|
||||
set(MODULE_LIBS "-ldl")
|
||||
target_link_libraries(LibXml2 PRIVATE ${CMAKE_DL_LIBS})
|
||||
list(TRANSFORM CMAKE_DL_LIBS PREPEND "-l" OUTPUT_VARIABLE MODULE_LIBS)
|
||||
else()
|
||||
check_library_exists(dld shl_load "" HAVE_SHLLOAD)
|
||||
if(HAVE_SHLLOAD)
|
||||
|
||||
Reference in New Issue
Block a user