]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: use OpenSSL for LDAP detection only if available
authorViktor Szakats <commit@vsz.me>
Fri, 4 Oct 2024 19:24:54 +0000 (21:24 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 4 Oct 2024 23:08:45 +0000 (01:08 +0200)
Also unset `CMAKE_REQUIRED_LIBRARIES` in two error branches.

Reported-by: Vollstrecker on github
Fixes #15077
Closes #15152

CMakeLists.txt

index 0129380e6604583ecfee96fa983e486a31a75789..28f93bd0562576af407c7c9ed6d47df8e44fa29b 100644 (file)
@@ -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})