summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorCristian Morales Vega <cristian@samknows.com>2020-11-19 07:54:09 +0000
committerDaniel Stenberg <daniel@haxx.se>2020-11-19 13:38:47 +0100
commitf21cc62832a9d5c521d10da9177b075bfed43f2f (patch)
tree13c3f34d01fc4f3e980c462dac2d0a0cf765e0a6 /CMakeLists.txt
parent73b63876b1d7ede288f38b35ad664b2f9d058825 (diff)
downloadcurl-f21cc62832a9d5c521d10da9177b075bfed43f2f.tar.gz
cmake: make CURL_ZLIB a tri-state variable
By differentiating between ON and AUTO it can make a missing zlib library a hard error when CURL_ZLIB=ON is used. Reviewed-by: Jakub Zakrzewski Closes #6221 Fixes #6173
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt33
1 files changed, 15 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 29c588bcd..7a2ad440b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -623,28 +623,25 @@ check_library_exists_concat("idn2" idn2_lookup_ul HAVE_LIBIDN2)
# Check for symbol dlopen (same as HAVE_LIBDL)
check_library_exists("${CURL_LIBS}" dlopen "" HAVE_DLOPEN)
-option(CURL_ZLIB "Set to ON to enable building curl with zlib support." ON)
set(HAVE_LIBZ OFF)
set(HAVE_ZLIB_H OFF)
set(USE_ZLIB OFF)
-if(CURL_ZLIB)
- find_package(ZLIB QUIET)
- if(ZLIB_FOUND)
- set(HAVE_ZLIB_H ON)
- set(HAVE_LIBZ ON)
- set(USE_ZLIB ON)
-
- # Depend on ZLIB via imported targets if supported by the running
- # version of CMake. This allows our dependents to get our dependencies
- # transitively.
- if(NOT CMAKE_VERSION VERSION_LESS 3.4)
- list(APPEND CURL_LIBS ZLIB::ZLIB)
- else()
- list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
- include_directories(${ZLIB_INCLUDE_DIRS})
- endif()
- list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
+optional_dependency(ZLIB)
+if(ZLIB_FOUND)
+ set(HAVE_ZLIB_H ON)
+ set(HAVE_LIBZ ON)
+ set(USE_ZLIB ON)
+
+ # Depend on ZLIB via imported targets if supported by the running
+ # version of CMake. This allows our dependents to get our dependencies
+ # transitively.
+ if(NOT CMAKE_VERSION VERSION_LESS 3.4)
+ list(APPEND CURL_LIBS ZLIB::ZLIB)
+ else()
+ list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
+ include_directories(${ZLIB_INCLUDE_DIRS})
endif()
+ list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
endif()
option(CURL_BROTLI "Set to ON to enable building curl with brotli support." OFF)