1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
#.rst:
# FindLdap
# --------
#
# Try to find the LDAP client libraries.
#
# This will define the following variables:
#
# ``Ldap_FOUND``
# True if libldap is available.
#
# ``Ldap_VERSION``
# The version of libldap
#
# ``Ldap_INCLUDE_DIRS``
# This should be passed to target_include_directories() if
# the target is not used for linking
#
# ``Ldap_LIBRARIES``
# The LDAP libraries (libldap + liblber if available)
# This can be passed to target_link_libraries() instead of
# the ``Ldap::Ldap`` target
#
# If ``Ldap_FOUND`` is TRUE, the following imported target
# will be available:
#
# ``Ldap::Ldap``
# The LDAP library
#
# Since pre-5.0.0.
#
# Imported target since 5.1.41
#
#=============================================================================
# SPDX-FileCopyrightText: 2006 Szombathelyi György <gyurco@freemail.hu>
# SPDX-FileCopyrightText: 2007-2025 Laurent Montel <montel@kde.org>
#
# SPDX-License-Identifier: BSD-3-Clause
#=============================================================================
find_path(Ldap_INCLUDE_DIRS NAMES ldap.h)
if(APPLE)
find_library(
Ldap_LIBRARIES
NAMES
LDAP
PATHS
/System/Library/Frameworks
/Library/Frameworks
)
else()
find_library(Ldap_LIBRARY NAMES ldap)
find_library(Lber_LIBRARY NAMES lber)
endif()
if(Ldap_LIBRARY AND Lber_LIBRARY)
set(Ldap_LIBRARIES
${Ldap_LIBRARY}
${Lber_LIBRARY}
)
endif()
if(EXISTS ${Ldap_INCLUDE_DIRS}/ldap_features.h)
file(READ ${Ldap_INCLUDE_DIRS}/ldap_features.h LDAP_FEATURES_H_CONTENT)
string(
REGEX
MATCH
"#define LDAP_VENDOR_VERSION_MAJOR[ ]+[0-9]+"
_LDAP_VERSION_MAJOR_MATCH
${LDAP_FEATURES_H_CONTENT}
)
string(
REGEX
MATCH
"#define LDAP_VENDOR_VERSION_MINOR[ ]+[0-9]+"
_LDAP_VERSION_MINOR_MATCH
${LDAP_FEATURES_H_CONTENT}
)
string(
REGEX
MATCH
"#define LDAP_VENDOR_VERSION_PATCH[ ]+[0-9]+"
_LDAP_VERSION_PATCH_MATCH
${LDAP_FEATURES_H_CONTENT}
)
string(REGEX REPLACE ".*_MAJOR[ ]+(.*)" "\\1" LDAP_VERSION_MAJOR ${_LDAP_VERSION_MAJOR_MATCH})
string(REGEX REPLACE ".*_MINOR[ ]+(.*)" "\\1" LDAP_VERSION_MINOR ${_LDAP_VERSION_MINOR_MATCH})
string(REGEX REPLACE ".*_PATCH[ ]+(.*)" "\\1" LDAP_VERSION_PATCH ${_LDAP_VERSION_PATCH_MATCH})
set(Ldap_VERSION "${LDAP_VERSION_MAJOR}.${LDAP_VERSION_MINOR}.${LDAP_VERSION_PATCH}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Ldap
FOUND_VAR Ldap_FOUND
REQUIRED_VARS
Ldap_LIBRARIES
Ldap_INCLUDE_DIRS
VERSION_VAR Ldap_VERSION
)
if(Ldap_FOUND AND NOT TARGET Lber::Lber)
add_library(Lber::Lber UNKNOWN IMPORTED)
set_target_properties(
Lber::Lber
PROPERTIES
IMPORTED_LOCATION
"${Lber_LIBRARY}"
)
endif()
if(Ldap_FOUND AND NOT TARGET Ldap::Ldap)
add_library(Ldap::Ldap UNKNOWN IMPORTED)
set_target_properties(
Ldap::Ldap
PROPERTIES
IMPORTED_LOCATION
"${Ldap_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES
"${Ldap_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES
Lber::Lber
)
endif()
mark_as_advanced(
Ldap_INCLUDE_DIRS
Ldap_LIBRARY
Lber_LIBRARY
Ldap_LIBRARIES
)
include(FeatureSummary)
set_package_properties(
Ldap
PROPERTIES
URL
"https://www.openldap.org/"
DESCRIPTION
"LDAP (Lightweight Directory Access Protocol) libraries."
)
|