Attempt to link against openldap on Windows, too
[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 #if(UNIX)
17 # Attempt to link against ldap.h regardless of platform!
18 FIND_PATH(LDAP_INCLUDE_DIR ldap.h)
19 FIND_LIBRARY(LDAP_LIBRARIES NAMES ldap)
20 FIND_LIBRARY(LBER_LIBRARIES NAMES lber)
21
22 #else(UNIX)
23 #   FIND_PATH(LDAP_INCLUDE_DIR winldap.h)
24 #   FIND_LIBRARY(LDAP_LIBRARIES NAMES wldap32)
25 #endif(UNIX)
26
27 if(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES)
28    set(LDAP_FOUND TRUE)
29    if(LBER_LIBRARIES)
30      set(LDAP_LIBRARIES ${LDAP_LIBRARIES} ${LBER_LIBRARIES})
31    endif(LBER_LIBRARIES)
32 endif(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES)
33
34 if(LDAP_FOUND)
35    if(NOT Ldap_FIND_QUIETLY)
36       message(STATUS "Found ldap: ${LDAP_LIBRARIES}")
37    endif(NOT Ldap_FIND_QUIETLY)
38 else(LDAP_FOUND)
39    if (Ldap_FIND_REQUIRED)
40         message(FATAL_ERROR "Could NOT find ldap")
41    endif (Ldap_FIND_REQUIRED)
42 endif(LDAP_FOUND)
43
44 MARK_AS_ADVANCED(LDAP_INCLUDE_DIR LDAP_LIBRARIES LBER_LIBRARIES LDAP_DIR)