summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindOpenLDAP.cmake
blob: 09bb49c62ed86399fc966cb8c8da887301e5d3ef (plain)
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
# - Find OpenLDAP C Libraries
#
# OpenLDAP_FOUND - True if found.
# OpenLDAP_INCLUDE_DIR - Path to the openldap include directory
# OpenLDAP_LIBRARIES - Paths to the ldap and lber libraries

find_path(OpenLDAP_INCLUDE_DIR ldap.h PATHS
  /usr/include
  /opt/local/include
  /usr/local/include)

find_library(LDAP_LIBRARY ldap)
find_library(LBER_LIBRARY lber)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenLDAP DEFAULT_MSG
  OpenLDAP_INCLUDE_DIR LDAP_LIBRARY LBER_LIBRARY)

mark_as_advanced(
  OpenLDAP_INCLUDE_DIR LDAP_LIBRARY LBER_LIBRARY)

if(OpenLDAP_FOUND)
  set(OpenLDAP_LIBRARIES ${LDAP_LIBRARY} ${LBER_LIBRARY})
  if(NOT TARGET OpenLDAP::OpenLDAP)
    add_library(OpenLDAP::LDAP UNKNOWN IMPORTED)
    set_target_properties(OpenLDAP::LDAP PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${OpenLDAP_INCLUDE_DIR}"
      IMPORTED_LINK_INTERFACE_LANGUAGES "C"
      IMPORTED_LOCATION "${LDAP_LIBRARY}")
    add_library(OpenLDAP::BER UNKNOWN IMPORTED)
    set_target_properties(OpenLDAP::BER PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${OpenLDAP_INCLUDE_DIR}"
      IMPORTED_LINK_INTERFACE_LANGUAGES "C"
      IMPORTED_LOCATION "${LBER_LIBRARY}")
    add_library(openldap INTERFACE)
    target_link_libraries(openldap INTERFACE
      OpenLDAP::LDAP
      OpenLDAP::BER)
    add_library(OpenLDAP::OpenLDAP ALIAS openldap)
  endif()
endif()