client: add FontSelector SettingsPage::hasChanged
[quassel.git] / cmake / FindLdap.cmake
1 # Copied from https://raw.github.com/facebook/hiphop-php/master/CMake/FindLdap.cmake
2
3 # - Try to find the LDAP client libraries
4 # Once done this will define
5 #
6 #  LDAP_FOUND - system has libldap
7 #  LDAP_INCLUDE_DIR - the ldap include directory
8 #  LDAP_LIBRARIES - libldap + liblber (if found) library
9 #  LBER_LIBRARIES - liblber library
10
11 if(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES)
12     # Already in cache, be silent
13     set(Ldap_FIND_QUIETLY TRUE)
14 endif(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES)
15
16 # Attempt to link against ldap.h regardless of platform!
17 FIND_PATH(LDAP_INCLUDE_DIR ldap.h)
18
19 # If we detect path to invalid ldap.h on osx, try /usr/include/
20 # This might also be achievable with additional parameters to FIND_PATH.
21 string(TOLOWER ${LDAP_INCLUDE_DIR} ldapincludelower)
22 if("${ldapincludelower}" MATCHES "\\/system\\/library\\/frameworks\\/ldap\\.framework\\/headers")
23   set(LDAP_INCLUDE_DIR "/usr/include/")
24 endif()
25
26 FIND_LIBRARY(LDAP_LIBRARIES NAMES ldap)
27
28 # On osx remove invalid ldap.h
29 string(TOLOWER ${LDAP_LIBRARIES} ldaplower)
30 if("${ldaplower}" MATCHES "\\/system\\/library\\/frameworks\\/ldap\\.framework")
31   set(LDAP_LIBRARIES FALSE)
32 endif()
33
34 FIND_LIBRARY(LBER_LIBRARIES NAMES lber)
35
36 # It'd be nice to link against winldap on Windows, unfortunately
37 # the interfaces are different. In theory a compatibility shim
38 # could be written; if someone ever gets around to doing that these
39 # lines should be uncommented and used on Windows.
40 #   FIND_PATH(LDAP_INCLUDE_DIR winldap.h)
41 #   FIND_LIBRARY(LDAP_LIBRARIES NAMES wldap32)
42
43 if(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES)
44    set(LDAP_FOUND TRUE)
45    if(LBER_LIBRARIES)
46      set(LDAP_LIBRARIES ${LDAP_LIBRARIES} ${LBER_LIBRARIES})
47    endif(LBER_LIBRARIES)
48 endif(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES)
49
50 if(LDAP_FOUND)
51    if(NOT Ldap_FIND_QUIETLY)
52       message(STATUS "Found ldap: ${LDAP_LIBRARIES}")
53    endif(NOT Ldap_FIND_QUIETLY)
54 else(LDAP_FOUND)
55    if (Ldap_FIND_REQUIRED)
56         message(FATAL_ERROR "Could NOT find ldap")
57    endif (Ldap_FIND_REQUIRED)
58 endif(LDAP_FOUND)
59
60 MARK_AS_ADVANCED(LDAP_INCLUDE_DIR LDAP_LIBRARIES LBER_LIBRARIES LDAP_DIR)