| 1 |
Description: Use the CMake package and target names the system lz4/zstd export |
| 2 |
The WITH_SYSTEM_DEFLATE branch looks for a CMake package called "libzstd" |
| 3 |
and links against the bare targets "lz4_shared" and "libzstd_shared". |
| 4 |
Those names only exist in the else() branch, where the vendored |
| 5 |
ext/lz4 and ext/zstd subprojects are pulled in with add_subdirectory(). |
| 6 |
. |
| 7 |
The installed lz4 and zstd both export a config package and namespaced |
| 8 |
imported targets instead: |
| 9 |
. |
| 10 |
lz4Config.cmake -> LZ4::lz4_shared, LZ4::lz4_static, LZ4::lz4 |
| 11 |
zstdConfig.cmake -> zstd::libzstd_shared, zstd::libzstd_static, |
| 12 |
zstd::libzstd |
| 13 |
. |
| 14 |
Use those, matching the libdeflate::libdeflate_shared already on the same |
| 15 |
line. This is not Debian-specific: the names come from lz4's and zstd's |
| 16 |
own upstream CMake install rules, so the fix should apply anywhere the |
| 17 |
system libraries are used, and is worth forwarding upstream. |
| 18 |
. |
| 19 |
Based on a patch by Stuart Prescott, extended to link the namespaced |
| 20 |
imported targets rather than fall back to bare -llz4 / -lzstd. |
| 21 |
Author: Stuart Prescott <[email protected]> |
| 22 |
Forwarded: https://github.com/danielhrisca/asammdf/pull/1314 |
| 23 |
Last-Update: 2026-09-10 |
| 24 |
--- a/CMakeLists.txt |
| 25 |
+++ b/CMakeLists.txt |
| 26 |
@@ -24,8 +24,8 @@ python_add_library(cutils MODULE WITH_SO |
| 27 |
if (WITH_SYSTEM_DEFLATE) |
| 28 |
find_package(libdeflate REQUIRED) |
| 29 |
find_package(lz4 REQUIRED) |
| 30 |
- find_package(libzstd REQUIRED) |
| 31 |
- target_link_libraries(cutils PRIVATE Python::NumPy libdeflate::libdeflate_shared lz4_shared libzstd_shared) |
| 32 |
+ find_package(zstd REQUIRED) |
| 33 |
+ target_link_libraries(cutils PRIVATE Python::NumPy libdeflate::libdeflate_shared LZ4::lz4_shared zstd::libzstd_shared) |
| 34 |
else() |
| 35 |
# Add submodule libdeflate |
| 36 |
set(CMAKE_POSITION_INDEPENDENT_CODE ON) |