[CMake] Fix config when static zstd libraries are not found (#113584)

Fixes: https://github.com/llvm/llvm-project/issues/113583
This commit is contained in:
Udit Kumar Agarwal 2025-05-28 07:09:25 -07:00 committed by GitHub
parent 5e28af04f3
commit d58e00ddae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -195,8 +195,19 @@ if(LLVM_ENABLE_ZSTD)
elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
find_package(zstd QUIET)
endif()
# If LLVM_USE_STATIC_ZSTD is specified, make sure we enable zstd only if static
# libraries are found.
if(LLVM_USE_STATIC_ZSTD AND NOT TARGET zstd::libzstd_static)
# Fail if LLVM_ENABLE_ZSTD is FORCE_ON.
if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON)
message(FATAL_ERROR "Failed to find static zstd libraries, but LLVM_USE_STATIC_ZSTD=ON and LLVM_ENABLE_ZSTD=FORCE_ON.")
endif()
set(LLVM_ENABLE_ZSTD OFF)
else()
set(LLVM_ENABLE_ZSTD ${zstd_FOUND})
endif()
endif()
set(LLVM_ENABLE_ZSTD ${zstd_FOUND})
if(LLVM_ENABLE_LIBXML2)
if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON)