Browse Source

curl: Restore build within CMake after update to 8.0.1

Restore changes from commit 2be5a7de4e (Build: Use imported target
`ZLIB::ZLIB` instead of variables, 2022-08-21, v3.25.0-rc1~97^2~10)
that were undone by the update to curl 8.0.1.  The code was moved.
Brad King 2 years ago
parent
commit
eca41c0243
1 changed files with 7 additions and 3 deletions
  1. 7 3
      Utilities/cmcurl/CMakeLists.txt

+ 7 - 3
Utilities/cmcurl/CMakeLists.txt

@@ -588,7 +588,7 @@ endif()
 
 set(HAVE_LIBZ OFF)
 set(USE_ZLIB OFF)
-optional_dependency(ZLIB)
+find_package(ZLIB)
 if(ZLIB_FOUND)
   set(HAVE_LIBZ ON)
   set(USE_ZLIB ON)
@@ -597,12 +597,16 @@ if(ZLIB_FOUND)
   # 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)
+    if(CMAKE_USE_SYSTEM_ZLIB)
+      list(APPEND CURL_LIBS ZLIB::ZLIB)
+    else()
+      list(APPEND CURL_LIBS cmzlib)
+    endif()
   else()
     list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
     include_directories(${ZLIB_INCLUDE_DIRS})
+    list(APPEND CMAKE_REQUIRED_INCLUDES ${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)