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

via llvm-commits llvm-commits at lists.llvm.org
Wed May 28 07:09:29 PDT 2025


Author: Udit Kumar Agarwal
Date: 2025-05-28T14:09:25Z
New Revision: d58e00ddae0d4d6d68db565482aeb47597e00a25

URL: https://github.com/llvm/llvm-project/commit/d58e00ddae0d4d6d68db565482aeb47597e00a25
DIFF: https://github.com/llvm/llvm-project/commit/d58e00ddae0d4d6d68db565482aeb47597e00a25.diff

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

Fixes: https://github.com/llvm/llvm-project/issues/113583

Added: 
    

Modified: 
    llvm/cmake/config-ix.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 9d59fea8799b1..687f5077cbfd2 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -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)


        


More information about the llvm-commits mailing list