44 lines
1.6 KiB
CMake
44 lines
1.6 KiB
CMake
# Locate the OpenLDAP client libraries without relying on pkg-config.
|
|
|
|
find_path(OpenLDAP_INCLUDE_DIR
|
|
NAMES ldap.h)
|
|
|
|
find_library(OpenLDAP_LDAP_LIBRARY
|
|
NAMES ldap)
|
|
|
|
find_library(OpenLDAP_LBER_LIBRARY
|
|
NAMES lber)
|
|
|
|
if(OpenLDAP_INCLUDE_DIR AND EXISTS "${OpenLDAP_INCLUDE_DIR}/ldap_features.h")
|
|
file(STRINGS "${OpenLDAP_INCLUDE_DIR}/ldap_features.h"
|
|
_OpenLDAP_VERSION_LINES
|
|
REGEX "^#define LDAP_VENDOR_VERSION_(MAJOR|MINOR|PATCH) [0-9]+$")
|
|
foreach(_part MAJOR MINOR PATCH)
|
|
string(REGEX MATCH
|
|
"LDAP_VENDOR_VERSION_${_part} ([0-9]+)"
|
|
_match "${_OpenLDAP_VERSION_LINES}")
|
|
set(OpenLDAP_VERSION_${_part} "${CMAKE_MATCH_1}")
|
|
endforeach()
|
|
if(DEFINED OpenLDAP_VERSION_MAJOR AND
|
|
DEFINED OpenLDAP_VERSION_MINOR AND
|
|
DEFINED OpenLDAP_VERSION_PATCH)
|
|
set(OpenLDAP_VERSION
|
|
"${OpenLDAP_VERSION_MAJOR}.${OpenLDAP_VERSION_MINOR}.${OpenLDAP_VERSION_PATCH}")
|
|
endif()
|
|
endif()
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(OpenLDAP
|
|
REQUIRED_VARS OpenLDAP_INCLUDE_DIR OpenLDAP_LDAP_LIBRARY OpenLDAP_LBER_LIBRARY
|
|
VERSION_VAR OpenLDAP_VERSION)
|
|
|
|
if(OpenLDAP_FOUND AND NOT TARGET OpenLDAP::LDAP)
|
|
add_library(OpenLDAP::LDAP UNKNOWN IMPORTED)
|
|
set_target_properties(OpenLDAP::LDAP PROPERTIES
|
|
IMPORTED_LOCATION "${OpenLDAP_LDAP_LIBRARY}"
|
|
INTERFACE_INCLUDE_DIRECTORIES "${OpenLDAP_INCLUDE_DIR}"
|
|
INTERFACE_LINK_LIBRARIES "${OpenLDAP_LBER_LIBRARY}")
|
|
endif()
|
|
|
|
mark_as_advanced(OpenLDAP_INCLUDE_DIR OpenLDAP_LDAP_LIBRARY OpenLDAP_LBER_LIBRARY)
|