From 9a349d66c91884943f60fd472d84b024bb7993c6 Mon Sep 17 00:00:00 2001 From: Amy Huang Date: Thu, 12 Mar 2020 15:51:40 -0700 Subject: [PATCH] CMake: Turn LLVM_ENABLE_ZLIB into a tri-state option Summary: Add FORCE_ON option to LLVM_ENABLE_ZLIB, which causes a configuration error if zlib is not found. Similar to https://reviews.llvm.org/D40050. Reviewers: hans, thakis, rnk Subscribers: mgorny, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D76110 --- llvm/CMakeLists.txt | 2 +- llvm/cmake/config-ix.cmake | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 0da3302425c75..23f36d5039a7c 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -348,7 +348,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 f758366bc79d4..612ce5bdbcbea 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -175,6 +175,10 @@ if (LLVM_ENABLE_LIBXML2 STREQUAL "FORCE_ON" AND NOT LLVM_LIBXML2_ENABLED) message(FATAL_ERROR "Failed to congifure libxml2") endif() +if (LLVM_ENABLE_ZLIB STREQUAL "FORCE_ON" AND NOT HAVE_LIBZ) + message(FATAL_ERROR "Failed to configure zlib") +endif() + check_library_exists(xar xar_open "" HAVE_LIBXAR) if(HAVE_LIBXAR) set(XAR_LIB xar)