]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: allow manual configuration for LDAP
authorViktor Szakats <commit@vsz.me>
Sat, 5 Oct 2024 00:01:21 +0000 (02:01 +0200)
committerViktor Szakats <commit@vsz.me>
Thu, 10 Oct 2024 20:48:20 +0000 (22:48 +0200)
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

CMakeLists.txt

index 29f17fb659da84cb43d94de9c422da139af991eb..30e267eb0a41c5cfa3701b83a289c20d5f3bd251 100644 (file)
@@ -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)