Skip to content

Commit

Permalink
cmake: Link with --undefined-version
Browse files Browse the repository at this point in the history
  • Loading branch information
nwellnhof committed Apr 29, 2023
1 parent a8fe490 commit a5bc460
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
Expand All @@ -16,6 +16,7 @@ include(CheckCSourceCompiles)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CheckLinkerFlag)
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CMakePackageConfigHelpers)
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit a5bc460

Please sign in to comment.