[llvm] e6c7ed6 - build: make `LLVM_ENABLE_ZLIB` a tri-bool for users
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 1 17:04:43 PST 2020
Author: Saleem Abdulrasool
Date: 2020-01-01T17:02:16-08:00
New Revision: e6c7ed6d2164a0659fd9f6ee44f1375d301e3cad
URL: https://github.com/llvm/llvm-project/commit/e6c7ed6d2164a0659fd9f6ee44f1375d301e3cad
DIFF: https://github.com/llvm/llvm-project/commit/e6c7ed6d2164a0659fd9f6ee44f1375d301e3cad.diff
LOG: 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.
Added:
Modified:
llvm/CMakeLists.txt
llvm/cmake/config-ix.cmake
llvm/lib/Support/CMakeLists.txt
Removed:
################################################################################
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index eeac7bab850a..05e93f67e990 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -347,7 +347,7 @@ option(LLVM_ENABLE_LIBPFM "Use libpfm for performance counters if available." ON
option(LLVM_ENABLE_THREADS "Use threads if available." ON)
-option(LLVM_ENABLE_ZLIB "Use zlib for compression/decompression if available." ON)
+set(LLVM_ENABLE_ZLIB "ON" CACHE STRING "Use zlib for compression/decompression if available. Can be ON, OFF, or FORCE_ON")
set(LLVM_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver.")
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index d5a15a680a6d..a16038f70989 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -117,10 +117,6 @@ endif()
# Don't look for these libraries if we're using MSan, since uninstrumented third
# party code may call MSan interceptors like strlen, leading to false positives.
if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
- if(LLVM_ENABLE_ZLIB)
- find_package(ZLIB REQUIRED)
- endif()
-
# Don't look for these libraries on Windows.
if (NOT PURE_WINDOWS)
# Skip libedit if using ASan as it contains memory leaks.
@@ -506,7 +502,21 @@ else( LLVM_ENABLE_THREADS )
endif()
if(LLVM_ENABLE_ZLIB)
- find_package(ZLIB REQUIRED)
+ if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON)
+ find_package(ZLIB REQUIRED)
+ else()
+ find_package(ZLIB)
+ endif()
+
+ if(ZLIB_FOUND)
+ set(LLVM_ENABLE_ZLIB "YES" CACHE STRING
+ "Use zlib for compression/decompression if available. Can be ON, OFF, or FORCE_ON"
+ FORCE)
+ else()
+ set(LLVM_ENABLE_ZLIB "NO" CACHE STRING
+ "Use zlib for compression/decompression if available. Can be ON, OFF, or FORCE_ON"
+ FORCE)
+ endif()
endif()
if (LLVM_ENABLE_DOXYGEN)
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 2fa641ff5da3..26332d4f539c 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -1,4 +1,7 @@
-set(system_libs ${ZLIB_LIBRARY})
+if(LLVM_ENABLE_ZLIB)
+ set(system_libs ${ZLIB_LIBRARY})
+endif()
+
if( MSVC OR MINGW )
# libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
# advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.
More information about the llvm-commits
mailing list