This is an archive of the discontinued LLVM Phabricator instance.

[llvm] [cmake] Support finding both static and shared zstd via FindZstd
ClosedPublic

Authored by mgorny on Oct 7 2022, 9:45 AM.

Details

Summary

Improve the logic in FindZstd to support finding both shared and static
variants of the zstd library simultaneously. Otherwise, if the shared
library is installed, zstd::libzstd_static is not declared at all
and CMake fails if LLVM_USE_STATIC_ZSTD is used.

Diff Detail

Event Timeline

mgorny created this revision.Oct 7 2022, 9:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 7 2022, 9:45 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
mgorny requested review of this revision.Oct 7 2022, 9:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 7 2022, 9:45 AM
MaskRay accepted this revision.Oct 11 2022, 10:02 PM
This revision is now accepted and ready to land.Oct 11 2022, 10:02 PM

Alternative that I'd slightly prefer would be to only search for static library when LLVM_USE_STATIC_ZSTD is enabled, otherwise try both as before. That's more in line with what the other CMake modules do. I haven't found any module that would try to find both shared and static library at the same time and I'm not sure if there's a use case for it.

However, exporting both targets is in line with what zstd cmake configs do.