summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSune Vuorela <sune@vuorela.dk>2023-09-29 13:49:03 +0200
committerSune Vuorela <sune@vuorela.dk>2023-10-02 08:16:03 +0000
commita678acd1224e40140980ec05b117e3fcded36246 (patch)
tree2fb227372e226a78a37f1cae5594ea73832797fd
parent6789f6fb2774940c2b60d71850826f0dad988167 (diff)
Check if linker supports version scripts
This is at least not fully supported on solaris.
-rw-r--r--CMakeLists.txt20
1 files changed, 19 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d8801e64..51bee589 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -639,7 +639,25 @@ set_target_properties(poppler PROPERTIES
SOVERSION ${POPPLER_SOVERSION_NUMBER})
if(UNIX AND (NOT APPLE))
- set_target_properties(poppler PROPERTIES LINK_OPTIONS LINKER:--version-script=${LINKER_SCRIPT})
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/linkerscript_test.map "VERS_1 {\nglobal:\n *;};\n")
+
+ # once we require cmake 3.18,
+ # the next set of lines can be changed
+ # to the check_linker_flags function instead
+ include(CheckCXXSourceCompiles)
+ set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/linkerscript_test.map)
+ check_cxx_source_compiles("
+ int main(int, char**) {
+ return 0;
+ }
+ " SUPPORT_VERSION_SCRIPT)
+ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
+
+ file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/linkerscript_test.map)
+ if (SUPPORT_VERSION_SCRIPT)
+ set_target_properties(poppler PROPERTIES LINK_OPTIONS LINKER:--version-script=${LINKER_SCRIPT})
+ endif()
endif()
if(MINGW AND BUILD_SHARED_LIBS)
get_target_property(POPPLER_SOVERSION poppler SOVERSION)