Skip to content

Commit e6c7ed6

Browse files
committed
build: make LLVM_ENABLE_ZLIB a tri-bool for users
Treat the flag `LLVM_ENABLE_ZLIB` as a tri-bool, `FORCE_ON` being `ON`, and `ON` being an auto-detect. This is needed as many of the builders enable the flag without having zlib available.
1 parent 68a235d commit e6c7ed6

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

llvm/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ option(LLVM_ENABLE_LIBPFM "Use libpfm for performance counters if available." ON
347347

348348
option(LLVM_ENABLE_THREADS "Use threads if available." ON)
349349

350-
option(LLVM_ENABLE_ZLIB "Use zlib for compression/decompression if available." ON)
350+
set(LLVM_ENABLE_ZLIB "ON" CACHE STRING "Use zlib for compression/decompression if available. Can be ON, OFF, or FORCE_ON")
351351

352352
set(LLVM_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver.")
353353

llvm/cmake/config-ix.cmake

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ endif()
117117
# Don't look for these libraries if we're using MSan, since uninstrumented third
118118
# party code may call MSan interceptors like strlen, leading to false positives.
119119
if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
120-
if(LLVM_ENABLE_ZLIB)
121-
find_package(ZLIB REQUIRED)
122-
endif()
123-
124120
# Don't look for these libraries on Windows.
125121
if (NOT PURE_WINDOWS)
126122
# Skip libedit if using ASan as it contains memory leaks.
@@ -506,7 +502,21 @@ else( LLVM_ENABLE_THREADS )
506502
endif()
507503

508504
if(LLVM_ENABLE_ZLIB)
509-
find_package(ZLIB REQUIRED)
505+
if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON)
506+
find_package(ZLIB REQUIRED)
507+
else()
508+
find_package(ZLIB)
509+
endif()
510+
511+
if(ZLIB_FOUND)
512+
set(LLVM_ENABLE_ZLIB "YES" CACHE STRING
513+
"Use zlib for compression/decompression if available. Can be ON, OFF, or FORCE_ON"
514+
FORCE)
515+
else()
516+
set(LLVM_ENABLE_ZLIB "NO" CACHE STRING
517+
"Use zlib for compression/decompression if available. Can be ON, OFF, or FORCE_ON"
518+
FORCE)
519+
endif()
510520
endif()
511521

512522
if (LLVM_ENABLE_DOXYGEN)

llvm/lib/Support/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
set(system_libs ${ZLIB_LIBRARY})
1+
if(LLVM_ENABLE_ZLIB)
2+
set(system_libs ${ZLIB_LIBRARY})
3+
endif()
4+
25
if( MSVC OR MINGW )
36
# libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
47
# advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.

0 commit comments

Comments
 (0)