Skip to content

Commit

Permalink
cmake: use OpenSSL for LDAP detection only if available
Browse files Browse the repository at this point in the history
Also unset `CMAKE_REQUIRED_LIBRARIES` in two error branches.

Reported-by: Vollstrecker on github
Fixes curl#15077
Closes curl#15152
  • Loading branch information
vszakats committed Oct 4, 2024
1 parent e9eda86 commit b171ee6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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})
Expand Down

0 comments on commit b171ee6

Please sign in to comment.