From 93630ec7711dc7bd29200d9167b88ff9c86f5e6e Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 6 May 2023 16:29:35 +0200 Subject: cmake: Use version script --- CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 022f345a..a8e12c21 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}) @@ -28,6 +28,7 @@ include(CheckCSourceCompiles) include(CheckFunctionExists) include(CheckIncludeFiles) include(CheckLibraryExists) +include(CheckLinkerFlag) include(CheckSymbolExists) include(CMakePackageConfigHelpers) include(GNUInstallDirs) @@ -90,6 +91,14 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU") -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline \ -Wredundant-decls -Wno-long-long -Wno-format-extra-args") + + if(BUILD_SHARED_LIBS AND UNIX AND NOT APPLE) + check_linker_flag(C "LINKER:--undefined-version" FLAG_UNDEFINED_VERSION) + if (FLAG_UNDEFINED_VERSION) + target_link_options(LibXslt PRIVATE "LINKER:--undefined-version") + endif() + target_link_options(LibXslt PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libxslt/libxslt.syms") + endif() endif() if(LIBXSLT_WITH_CRYPTO AND NOT WIN32) -- cgit v1.2.1