Skip to content

Commit d58e00d

Browse files
[CMake] Fix config when static zstd libraries are not found (#113584)
Fixes: #113583
1 parent 5e28af0 commit d58e00d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

llvm/cmake/config-ix.cmake

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,19 @@ if(LLVM_ENABLE_ZSTD)
195195
elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
196196
find_package(zstd QUIET)
197197
endif()
198+
199+
# If LLVM_USE_STATIC_ZSTD is specified, make sure we enable zstd only if static
200+
# libraries are found.
201+
if(LLVM_USE_STATIC_ZSTD AND NOT TARGET zstd::libzstd_static)
202+
# Fail if LLVM_ENABLE_ZSTD is FORCE_ON.
203+
if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON)
204+
message(FATAL_ERROR "Failed to find static zstd libraries, but LLVM_USE_STATIC_ZSTD=ON and LLVM_ENABLE_ZSTD=FORCE_ON.")
205+
endif()
206+
set(LLVM_ENABLE_ZSTD OFF)
207+
else()
208+
set(LLVM_ENABLE_ZSTD ${zstd_FOUND})
209+
endif()
198210
endif()
199-
set(LLVM_ENABLE_ZSTD ${zstd_FOUND})
200211

201212
if(LLVM_ENABLE_LIBXML2)
202213
if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON)

0 commit comments

Comments
 (0)