CMake: Don't use symbol versioning with static library.

This commit is contained in:
Lasse Collin 2022-11-24 00:02:31 +02:00
parent 48c1b99dc5
commit ae1f8a723d
1 changed files with 7 additions and 3 deletions

View File

@ -470,9 +470,13 @@ if(WIN32)
# Disable __declspec(dllimport) when linking against static liblzma. # Disable __declspec(dllimport) when linking against static liblzma.
target_compile_definitions(liblzma INTERFACE LZMA_API_STATIC) target_compile_definitions(liblzma INTERFACE LZMA_API_STATIC)
endif() endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") elseif(BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
# GNU/Linux-specific symbol versioning for shared liblzma. # GNU/Linux-specific symbol versioning for shared liblzma.
# Note that adding link options doesn't affect static builds. # Note that adding link options doesn't affect static builds
# but HAVE_SYMBOL_VERSIONS_LINUX must not be used with static builds
# because it would put symbol versions into the static library which
# can cause problems. It's clearer if all symver related things are
# omitted when not building a shared library.
target_compile_definitions(liblzma PRIVATE HAVE_SYMBOL_VERSIONS_LINUX) target_compile_definitions(liblzma PRIVATE HAVE_SYMBOL_VERSIONS_LINUX)
target_link_options(liblzma PRIVATE target_link_options(liblzma PRIVATE
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map" "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map"
@ -480,7 +484,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set_target_properties(liblzma PROPERTIES set_target_properties(liblzma PROPERTIES
LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map" LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map"
) )
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") elseif(BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
# Symbol versioning for shared liblzma for non-GNU/Linux. # Symbol versioning for shared liblzma for non-GNU/Linux.
# FIXME? What about Solaris? # FIXME? What about Solaris?
target_link_options(liblzma PRIVATE target_link_options(liblzma PRIVATE