Skip to content

Conversation

@Theresa-0328
Copy link
Contributor

Some zstd installations (e.g. GitHub Actions ubuntu-24.04) set zstd_FOUNDwithout providing a zstd::libzstd target, causing invalid target_link_libraries().Use imported target presence to detect zstd usage instead.

Fixes #2313

@yhirose
Copy link
Owner

yhirose commented Jan 21, 2026

@sum01 @jimmy-park @Tachi107 does the pr look good for you?

@Tachi107
Copy link
Contributor

Tachi107 commented Jan 21, 2026 via email

@Theresa-0328
Copy link
Contributor Author

This isn’t caused by the build environment itself, but by differences in how zstd is discovered across systems.

On some systems, zstd provides an imported target named zstd::zstd rather than zstd::libzstd (for example, the Findzstd.cmake used by RocksDB: https://github.com/facebook/rocksdb/blob/main/cmake/modules/Findzstd.cmake
).

In those cases, find_package(zstd) sets zstd_FOUND to true, but zstd::libzstd is not defined. For this reason, checking whether zstd::libzstd exists is more reliable than relying on zstd_FOUND alone.

@Tachi107
Copy link
Contributor

Tachi107 commented Jan 21, 2026 via email

@Theresa-0328
Copy link
Contributor Author

Using find_package(zstd CONFIG) still fails to compile in my case.
After inspecting zstdTargets.cmake, I found that in the default zstd package shipped with Ubuntu 24.04 (zstd v1.5.5), there is no zstd::libzstd target. Only the following targets are defined:

zstd::libzstd_static

zstd::libzstd_shared

The zstd::libzstd alias target was only added in zstd v1.5.6, as seen here:
https://github.com/facebook/zstd/blob/794ea1b0afca0f020f4e57b6732332231fb23c70/build/cmake/lib/CMakeLists.txt#L159

Therefore, even when zstd_FOUND is defined and the upstream Config file is used, zstd::libzstd may legitimately not exist, depending on the zstd version provided by the system.

@Tachi107
Copy link
Contributor

Tachi107 commented Jan 22, 2026 via email

@Theresa-0328
Copy link
Contributor Author

Agreed — this makes sense to me.
Using find_package(zstd 1.5.6 CONFIG) avoids the target ambiguity and keeps the pkg-config fallback intact. After applying this, the issue is fully resolved on my side. Thanks!

@Tachi107
Copy link
Contributor

Tachi107 commented Jan 22, 2026 via email

@yhirose
Copy link
Owner

yhirose commented Jan 22, 2026

@Theresa-0328 @Tachi107 thanks for taking care of this pull request. Is it ready to merge?

@Tachi107
Copy link
Contributor

Tachi107 commented Jan 22, 2026 via email

@yhirose yhirose merged commit 191bfb2 into yhirose:master Jan 22, 2026
7 of 10 checks passed
@yhirose
Copy link
Owner

yhirose commented Jan 22, 2026

Merged. Thanks for the fine contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue finding zstd

3 participants