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()