FindOPENLDAP.cmake 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ################################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ################################################################################
  17. # - Try to find the OpenLDAP libraries
  18. # Once done this will define
  19. #
  20. # OPENLDAP_FOUND - system has the OpenLDAP library
  21. # OPENLDAP_INCLUDE_DIR - the OpenLDAP include directory
  22. # OPENLDAP_LIBRARIES - The libraries needed to use OpenLDAP
  23. #
  24. # Note that we use winldap for windows builds at present
  25. #
  26. IF (NOT OPENLDAP_FOUND)
  27. IF (WIN32)
  28. SET (ldap_dll "wldap32")
  29. SET (ldap_inc "Winldap.h")
  30. ELSE()
  31. SET (ldap_dll "ldap_r")
  32. SET (ldap_inc "ldap.h")
  33. ENDIF()
  34. IF (NOT ${EXTERNALS_DIRECTORY} STREQUAL "")
  35. IF (UNIX)
  36. IF (${ARCH64BIT} EQUAL 1)
  37. SET (osincdir "openldap/linux64_gcc4.1.1/include")
  38. SET (oslibdir "openldap/linux64_gcc4.1.1")
  39. ELSE()
  40. SET (osincdir "openldap/linux32_gcc4.1.1/include")
  41. SET (oslibdir "openldap/linux32_gcc4.1.1")
  42. ENDIF()
  43. ELSEIF(WIN32)
  44. SET (osincdir "winldap/include")
  45. SET (oslibdir "winldap/lib")
  46. ELSE()
  47. SET (osincdir "unknown")
  48. ENDIF()
  49. IF (NOT ("${osincdir}" STREQUAL "unknown"))
  50. FIND_PATH (OPENLDAP_INCLUDE_DIR NAMES ${ldap_inc} PATHS "${EXTERNALS_DIRECTORY}/${osincdir}" NO_DEFAULT_PATH)
  51. FIND_LIBRARY (OPENLDAP_LIBRARIES NAMES ${ldap_dll} PATHS "${EXTERNALS_DIRECTORY}/${oslibdir}" NO_DEFAULT_PATH)
  52. ENDIF()
  53. ENDIF()
  54. # if we didn't find in externals, look in system include path
  55. if (USE_NATIVE_LIBRARIES)
  56. FIND_PATH (OPENLDAP_INCLUDE_DIR NAMES ${ldap_inc})
  57. FIND_LIBRARY (OPENLDAP_LIBRARIES NAMES ${ldap_dll})
  58. endif()
  59. include(FindPackageHandleStandardArgs)
  60. find_package_handle_standard_args(OpenLDAP DEFAULT_MSG
  61. OPENLDAP_LIBRARIES
  62. OPENLDAP_INCLUDE_DIR
  63. )
  64. IF (OPENLDAP_FOUND)
  65. IF (UNIX)
  66. STRING(REPLACE "ldap_r" "lber" OPENLDAP_EXTRA "${OPENLDAP_LIBRARIES}")
  67. set (OPENLDAP_LIBRARIES ${OPENLDAP_LIBRARIES} ${OPENLDAP_EXTRA} )
  68. ELSE()
  69. set (OPENLDAP_LIBRARIES ${OPENLDAP_LIBRARIES} netapi32 )
  70. ENDIF()
  71. ENDIF()
  72. MARK_AS_ADVANCED(OPENLDAP_INCLUDE_DIR OPENLDAP_LIBRARIES)
  73. ENDIF()