From a273a0cb77c6000e4da627b07f28c5af41f0908c Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Thu, 8 Sep 2022 15:02:41 +0300 Subject: [PATCH] CMake: Update for liblzma_*.map files and fix wrong common_w32res.rc dep. The previous commit split liblzma.map into liblzma_linux.map and liblzma_generic.map. This commit updates the CMake build for those. common_w32res.rc dependency was listed under Linux/FreeBSD while obviously it belongs to Windows when building a DLL. --- CMakeLists.txt | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf42055c..90939c2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -414,20 +414,34 @@ if(WIN32) # Add the Windows resource file for liblzma.dll. target_sources(liblzma PRIVATE src/liblzma/liblzma_w32res.rc) + set_target_properties(liblzma PROPERTIES + LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/common/common_w32res.rc" + ) + # Export the public API symbols with __declspec(dllexport). target_compile_definitions(liblzma PRIVATE DLL_EXPORT) else() # Disable __declspec(dllimport) when linking against static liblzma. target_compile_definitions(liblzma INTERFACE LZMA_API_STATIC) endif() -elseif(CMAKE_SYSTEM_NAME MATCHES "^Linux$|^FreeBSD$") - # Symbol versioning for shared liblzma. This doesn't affect static builds. +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # GNU/Linux-specific symbol versioning for shared liblzma. + # Note that adding link options doesn't affect static builds. + target_compile_definitions(liblzma PRIVATE HAVE_SYMBOL_VERSIONS_LINUX) target_link_options(liblzma PRIVATE - "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma.map" + "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map" ) set_target_properties(liblzma PROPERTIES - LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma.map" - LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/common/common_w32res.rc" + LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map" + ) +elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + # Symbol versioning for shared liblzma for non-GNU/Linux. + # FIXME? What about Solaris? + target_link_options(liblzma PRIVATE + "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_generic.map" + ) + set_target_properties(liblzma PROPERTIES + LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_generic.map" ) endif()