Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update zstd target handling and fix a small config error #223

Merged
merged 6 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,37 @@ if (ENABLE_DECOMPRESSION)
# Zlib and ZSTD need to be found otherwise disable it
if(NOT TARGET ZLIB::ZLIB)
find_package(ZLIB)
else()
# Presumably in this case, the target has been found externally but set this flag just in case
set(ZLIB_FOUND TRUE)
endif()
if(NOT TARGET ZSTD::ZSTD)
# This feels excessive, however perhaps better safe than sorry
if(
NOT (
TARGET zstd::libzstd_shared OR
TARGET zstd::libzstd_static OR
TARGET libzstd_shared OR
TARGET libzstd_static OR
TARGET ZSTD::ZSTD
)
)
find_package(ZSTD)
else()
# Presumably in this case, the target has been found externally but set this flag just in case
set(ZSTD_FOUND TRUE)
endif()
# Unfortunately aliasing ZSTD::ZSTD to zstd::libzstd_shared/static can lead to problems for end-users, a variable
# is used
if(TARGET zstd::libzstd_shared)
set(ZSTD_LIB zstd::libzstd_shared)
elseif(TARGET zstd::libzstd_static)
set(ZSTD_LIB zstd::libzstd_static)
elseif(TARGET libzstd_shared)
set(ZSTD_LIB libzstd_shared)
elseif(TARGET libzstd_static)
set(ZSTD_LIB libzstd_static)
else()
set(ZSTD_LIB ZSTD::ZSTD)
endif()
if (ZLIB_FOUND AND ZSTD_FOUND )
set(HAVE_ZLIB TRUE)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libdwarf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ target_include_directories(dwarf PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if(ZLIB_FOUND AND ZSTD_FOUND)
target_link_libraries(dwarf PRIVATE ZLIB::ZLIB ZSTD::ZSTD )
target_link_libraries(dwarf PRIVATE ZLIB::ZLIB ${ZSTD_LIB} )
endif()
set_target_properties(dwarf PROPERTIES PUBLIC_HEADER "libdwarf.h;dwarf.h")

Expand Down
2 changes: 1 addition & 1 deletion src/lib/libdwarf/cmake/libdwarfConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(LIBDWARF_BUILT_WITH_ZLIB_AND_ZSTD "@BUILT_WITH_ZLIB_AND_ZSTD@")

if(LIBDWARF_BUILT_WITH_ZLIB_AND_ZSTD)
find_dependency(ZLIB)
set(CMAKE_MODULE_PATH_OLD "CMAKE_MODULE_PATH")
set(CMAKE_MODULE_PATH_OLD "${CMAKE_MODULE_PATH}")
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_LIST_DIR}")
find_dependency(ZSTD)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH_OLD}")
Expand Down