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 913ddc5572
commit 17485e884c
1 changed files with 19 additions and 5 deletions

View File

@ -417,20 +417,34 @@ if(WIN32)
# Add the Windows resource file for liblzma.dll. # Add the Windows resource file for liblzma.dll.
target_sources(liblzma PRIVATE src/liblzma/liblzma_w32res.rc) 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). # Export the public API symbols with __declspec(dllexport).
target_compile_definitions(liblzma PRIVATE DLL_EXPORT) target_compile_definitions(liblzma PRIVATE DLL_EXPORT)
else() else()
# 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 MATCHES "^Linux$|^FreeBSD$") elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# Symbol versioning for shared liblzma. This doesn't affect static builds. # 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 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 set_target_properties(liblzma PROPERTIES
LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma.map" LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map"
LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/common/common_w32res.rc" )
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() endif()