diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2023-04-29 20:43:54 +0200 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2023-04-29 20:43:54 +0200 |
commit | a5bc4605838335dd6bee9374fcb6b4718b2f5a5a (patch) | |
tree | 19cce0bae2fb13429f1060dc74f029d09e2cc767 | |
parent | a8fe4900be5d2971f06917889784f678494a6a13 (diff) | |
download | libxml2-a5bc4605838335dd6bee9374fcb6b4718b2f5a5a.tar.gz |
cmake: Link with --undefined-version
-rw-r--r-- | CMakeLists.txt | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 39d36234..86b2b0aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.18) file(STRINGS "configure.ac" CONFIGURE_AC_LINES) foreach(line ${CONFIGURE_AC_LINES}) @@ -16,6 +16,7 @@ include(CheckCSourceCompiles) include(CheckFunctionExists) include(CheckIncludeFiles) include(CheckLibraryExists) +include(CheckLinkerFlag) include(CheckStructHasMember) include(CheckSymbolExists) include(CMakePackageConfigHelpers) @@ -337,7 +338,11 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU") -Wredundant-decls -Wno-long-long -Wno-format-extra-args") if(BUILD_SHARED_LIBS AND UNIX AND NOT APPLE) - target_link_options(LibXml2 PRIVATE "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libxml2.syms") + check_linker_flag(C "LINKER:--undefined-version" FLAG_UNDEFINED_VERSION) + if (FLAG_UNDEFINED_VERSION) + target_link_options(LibXml2 PRIVATE "LINKER:--undefined-version") + endif() + target_link_options(LibXml2 PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libxml2.syms") endif() endif() |