cmake: always reference OpenSSL and ZLIB via imported targets

Some places where still referencing them via global variables.

Closes #16207
This commit is contained in:
Viktor Szakats 2025-02-06 02:50:09 +01:00
parent b3e12b7d6f
commit 8c5be18843
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201

View File

@ -744,7 +744,7 @@ if(CURL_USE_OPENSSL)
set(_curl_ca_bundle_supported TRUE)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
list(APPEND CMAKE_REQUIRED_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
if(NOT DEFINED HAVE_BORINGSSL)
check_symbol_exists("OPENSSL_IS_BORINGSSL" "openssl/base.h" HAVE_BORINGSSL)
endif()
@ -941,10 +941,9 @@ endif()
macro(curl_openssl_check_symbol_exists _symbol _files _variable)
cmake_push_check_state()
if(USE_OPENSSL)
list(APPEND CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}")
list(APPEND CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES}")
list(APPEND CMAKE_REQUIRED_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
if(HAVE_LIBZ)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${ZLIB_LIBRARIES}")
list(APPEND CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB)
endif()
if(WIN32)
list(APPEND CMAKE_REQUIRED_LIBRARIES "ws2_32")
@ -956,8 +955,7 @@ macro(curl_openssl_check_symbol_exists _symbol _files _variable)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${WOLFSSL_LIBRARIES}")
curl_required_libpaths("${WOLFSSL_LIBRARY_DIRS}")
if(HAVE_LIBZ)
list(APPEND CMAKE_REQUIRED_INCLUDES "${ZLIB_INCLUDE_DIRS}") # Public wolfSSL headers require zlib headers
list(APPEND CMAKE_REQUIRED_LIBRARIES "${ZLIB_LIBRARIES}")
list(APPEND CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB) # Public wolfSSL headers also require zlib headers
endif()
if(WIN32)
list(APPEND CMAKE_REQUIRED_LIBRARIES "ws2_32" "crypt32")
@ -1182,7 +1180,7 @@ if(NOT CURL_DISABLE_LDAP)
# Check for LDAP
cmake_push_check_state()
if(USE_OPENSSL)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES})
list(APPEND CMAKE_REQUIRED_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
endif()
find_package(LDAP)
if(LDAP_FOUND)