Revert "[CMake] Simplify CMake handling for zlib"
This reverts commit 8c1a79dc12f3cc600e16153961cd8cc50ba2c33b because
it fails when zlib isn't installed.
GitOrigin-RevId: bcd27d9d73f74f291fbd8b0fd1182e69a327be88
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d35ca8d..7f8e071 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -114,10 +114,6 @@
option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON)
- if(LLVM_ENABLE_ZLIB)
- find_package(ZLIB)
- endif()
-
include(AddLLVM)
include(TableGen)
include(HandleLLVMOptions)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 334a904..38bbc5b 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -9,6 +9,15 @@
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
+if(CLANG_BUILT_STANDALONE)
+ # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
+ # value is forced to 0 if zlib was not found, so it is fine to use it
+ # instead of HAVE_LIBZ (not recorded).
+ if(LLVM_ENABLE_ZLIB)
+ set(HAVE_LIBZ 1)
+ endif()
+endif()
+
llvm_canonicalize_cmake_booleans(
CLANG_BUILD_EXAMPLES
CLANG_ENABLE_ARCMT
@@ -16,7 +25,7 @@
CLANG_SPAWN_CC1
ENABLE_BACKTRACES
ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
- LLVM_ENABLE_ZLIB
+ HAVE_LIBZ
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
LLVM_ENABLE_PLUGINS
LLVM_ENABLE_THREADS)
diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in
index 286ea06..d9b5b2f 100644
--- a/test/lit.site.cfg.py.in
+++ b/test/lit.site.cfg.py.in
@@ -16,7 +16,7 @@
config.target_triple = "@TARGET_TRIPLE@"
config.host_cxx = "@CMAKE_CXX_COMPILER@"
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.have_zlib = @HAVE_LIBZ@
config.clang_arcmt = @CLANG_ENABLE_ARCMT@
config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@