From: Viktor Szakats Date: Sat, 5 Oct 2024 00:01:21 +0000 (+0200) Subject: cmake: allow manual configuration for LDAP X-Git-Tag: curl-8_11_0~180 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c90f7f69e117543a9f0102bb89112125f0032bd;p=thirdparty%2Fcurl.git cmake: allow manual configuration for LDAP Via these configuration values: - `LDAP_LIBRARY` - `LDAP_LBER_LIBRARY` - `LDAP_INCLUDE_DIR` Following the naming scheme used in `Find` modules. Cherry-picked from #15157 Closes #15255 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 29f17fb659..30e267eb0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -980,26 +980,32 @@ if(NOT CURL_DISABLE_LDAP) endif() endif() - set(CMAKE_LDAP_LIB "ldap" CACHE STRING "Name or full path to ldap library") - set(CMAKE_LBER_LIB "lber" CACHE STRING "Name or full path to lber library") - # Now that we know, we are not using Windows LDAP... if(NOT USE_WIN32_LDAP) + if(NOT DEFINED LDAP_LIBRARY) + set(LDAP_LIBRARY "ldap" CACHE STRING "Name or full path to ldap library") + endif() + if(NOT DEFINED LDAP_LBER_LIBRARY) + set(LDAP_LBER_LIBRARY "lber" CACHE STRING "Name or full path to lber library") + endif() + if(NOT DEFINED LDAP_INCLUDE_DIR) + set(LDAP_INCLUDE_DIR "" CACHE STRING "Path to LDAP include directory") + endif() + # Check for LDAP cmake_push_check_state() if(USE_OPENSSL) set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) endif() - check_library_exists("${CMAKE_LDAP_LIB}" "ldap_init" "" HAVE_LIBLDAP) + check_library_exists("${LDAP_LIBRARY}" "ldap_init" "" HAVE_LIBLDAP) if(HAVE_LIBLDAP) - check_library_exists("${CMAKE_LDAP_LIB};${CMAKE_LBER_LIB}" "ber_init" "" HAVE_LIBLBER) + check_library_exists("${LDAP_LIBRARY};${LDAP_LBER_LIBRARY}" "ber_init" "" HAVE_LIBLBER) else() - check_library_exists("${CMAKE_LBER_LIB}" "ber_init" "" HAVE_LIBLBER) + check_library_exists("${LDAP_LBER_LIBRARY}" "ber_init" "" HAVE_LIBLBER) endif() - set(CMAKE_LDAP_INCLUDE_DIR "" CACHE STRING "Path to LDAP include directory") - if(CMAKE_LDAP_INCLUDE_DIR) - list(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_LDAP_INCLUDE_DIR}) + if(LDAP_INCLUDE_DIR) + list(APPEND CMAKE_REQUIRED_INCLUDES ${LDAP_INCLUDE_DIR}) endif() check_include_file_concat("ldap.h" HAVE_LDAP_H) check_include_file_concat("lber.h" HAVE_LBER_H) @@ -1008,19 +1014,19 @@ if(NOT CURL_DISABLE_LDAP) message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON") set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE) elseif(NOT HAVE_LIBLDAP) - message(STATUS "LDAP library '${CMAKE_LDAP_LIB}' not found CURL_DISABLE_LDAP set ON") + message(STATUS "LDAP library '${LDAP_LIBRARY}' not found CURL_DISABLE_LDAP set ON") set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE) else() - if(CMAKE_LDAP_INCLUDE_DIR) - include_directories(SYSTEM ${CMAKE_LDAP_INCLUDE_DIR}) + if(LDAP_INCLUDE_DIR) + include_directories(SYSTEM ${LDAP_INCLUDE_DIR}) endif() list(APPEND CMAKE_REQUIRED_DEFINITIONS "-DLDAP_DEPRECATED=1") - list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB}) - set(CURL_LIBS "${CMAKE_LDAP_LIB};${CURL_LIBS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES ${LDAP_LIBRARY}) + set(CURL_LIBS "${LDAP_LIBRARY};${CURL_LIBS}") set(LIBCURL_PC_REQUIRES_PRIVATE "ldap;${LIBCURL_PC_REQUIRES_PRIVATE}") if(HAVE_LIBLBER) - list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LBER_LIB}) - set(CURL_LIBS "${CMAKE_LBER_LIB};${CURL_LIBS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES ${LDAP_LBER_LIBRARY}) + set(CURL_LIBS "${LDAP_LBER_LIBRARY};${CURL_LIBS}") endif() check_function_exists("ldap_url_parse" HAVE_LDAP_URL_PARSE)