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.
This commit is contained in:
Lasse Collin 2022-09-08 15:02:41 +03:00
parent 5875a45be0
commit a273a0cb77
1 changed files with 19 additions and 5 deletions

View File

@ -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()