From: Viktor Szakats Date: Fri, 4 Oct 2024 19:24:54 +0000 (+0200) Subject: cmake: use OpenSSL for LDAP detection only if available X-Git-Tag: curl-8_11_0~231 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b171ee6019d5639ab67a619234e39121491c7340;p=thirdparty%2Fcurl.git cmake: use OpenSSL for LDAP detection only if available Also unset `CMAKE_REQUIRED_LIBRARIES` in two error branches. Reported-by: Vollstrecker on github Fixes #15077 Closes #15152 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0129380e66..28f93bd056 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -960,7 +960,10 @@ if(NOT CURL_DISABLE_LDAP) # Now that we know, we are not using Windows LDAP... if(NOT USE_WIN32_LDAP) # Check for LDAP - set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) + unset(CMAKE_REQUIRED_LIBRARIES) + if(USE_OPENSSL) + set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) + endif() check_library_exists("${CMAKE_LDAP_LIB}" "ldap_init" "" HAVE_LIBLDAP) if(HAVE_LIBLDAP) check_library_exists("${CMAKE_LDAP_LIB};${CMAKE_LBER_LIB}" "ber_init" "" HAVE_LIBLBER) @@ -980,10 +983,12 @@ if(NOT CURL_DISABLE_LDAP) message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON") set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE) set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) # LDAP includes will not be used + unset(CMAKE_REQUIRED_LIBRARIES) elseif(NOT HAVE_LIBLDAP) message(STATUS "LDAP library '${CMAKE_LDAP_LIB}' not found CURL_DISABLE_LDAP set ON") set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE) set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) # LDAP includes will not be used + unset(CMAKE_REQUIRED_LIBRARIES) else() if(CMAKE_LDAP_INCLUDE_DIR) include_directories(SYSTEM ${CMAKE_LDAP_INCLUDE_DIR})