summaryrefslogtreecommitdiffstats
path: root/cmake/Modules/FindMozLDAP.cmake
blob: 634241ce11be1b174d6f88c7ad3d7663e5739254 (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
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
# - Try to find MozLDAP
# Once done this will define
#
#  MOZLDAP_FOUND - system has MozLDAP
#  MOZLDAP_INCLUDE_DIRS - the MozLDAP include directory
#  MOZLDAP_LIBRARIES - Link these to use MozLDAP
#  MOZLDAP_DEFINITIONS - Compiler switches required for using MozLDAP
#
#  Copyright (c) 2010 Andreas Schneider <asn@redhat.com>
#
#  Redistribution and use is allowed according to the terms of the New
#  BSD license.
#  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#


if (MOZLDAP_LIBRARIES AND MOZLDAP_INCLUDE_DIRS)
  # in cache already
  set(MOZLDAP_FOUND TRUE)
else (MOZLDAP_LIBRARIES AND MOZLDAP_INCLUDE_DIRS)
  find_package(PkgConfig)
  if (PKG_CONFIG_FOUND)
    pkg_check_modules(_MOZLDAP mozldap)
  endif (PKG_CONFIG_FOUND)

  find_path(MOZLDAP_INCLUDE_DIR
    NAMES
      ldap.h
      ldif.h
    PATHS
      ${_MOZLDAP_INCLUDEDIR}
      /usr/include
      /usr/local/include
      /opt/local/include
      /sw/include
    PATH_SUFFIXES
      mozldap
  )

  find_library(SSLDAP60_LIBRARY
    NAMES
      ssldap60
    PATHS
      ${_MOZLDAP_LIBDIR}
      /usr/lib
      /usr/local/lib
      /opt/local/lib
      /sw/lib
  )

  find_library(PRLDAP60_LIBRARY
    NAMES
      prldap60
    PATHS
      ${_MOZLDAP_LIBDIR}
      /usr/lib
      /usr/local/lib
      /opt/local/lib
      /sw/lib
  )

  find_library(LDAP60_LIBRARY
    NAMES
      ldap60
    PATHS
      ${_MOZLDAP_LIBDIR}
      /usr/lib
      /usr/local/lib
      /opt/local/lib
      /sw/lib
  )

  find_library(LDIF60_LIBRARY
    NAMES
      ldif60
    PATHS
      ${_MOZLDAP_LIBDIR}
      /usr/lib
      /usr/local/lib
      /opt/local/lib
      /sw/lib
  )

  set(MOZLDAP_INCLUDE_DIRS
    ${MOZLDAP_INCLUDE_DIR}
  )

  if (SSLDAP60_LIBRARY)
    set(MOZLDAP_LIBRARIES
        ${MOZLDAP_LIBRARIES}
        ${SSLDAP60_LIBRARY}
    )
  endif (SSLDAP60_LIBRARY)

  if (PRLDAP60_LIBRARY)
    set(MOZLDAP_LIBRARIES
        ${MOZLDAP_LIBRARIES}
        ${PRLDAP60_LIBRARY}
    )
  endif (PRLDAP60_LIBRARY)

  if (LDAP60_LIBRARY)
    set(MOZLDAP_LIBRARIES
        ${MOZLDAP_LIBRARIES}
        ${LDAP60_LIBRARY}
    )
  endif (LDAP60_LIBRARY)

  if (LDIF60_LIBRARY)
    set(MOZLDAP_LIBRARIES
        ${MOZLDAP_LIBRARIES}
        ${LDIF60_LIBRARY}
    )
  endif (LDIF60_LIBRARY)

  include(FindPackageHandleStandardArgs)
  find_package_handle_standard_args(MozLDAP DEFAULT_MSG MOZLDAP_LIBRARIES MOZLDAP_INCLUDE_DIRS)

  # show the MOZLDAP_INCLUDE_DIRS and MOZLDAP_LIBRARIES variables only in the advanced view
  mark_as_advanced(MOZLDAP_INCLUDE_DIRS MOZLDAP_LIBRARIES)

endif (MOZLDAP_LIBRARIES AND MOZLDAP_INCLUDE_DIRS)