FindOPENLDAP.cmake 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ################################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. # - Try to find the OpenLDAP libraries
  17. # Once done this will define
  18. #
  19. # OPENLDAP_FOUND - system has the OpenLDAP library
  20. # OPENLDAP_INCLUDE_DIR - the OpenLDAP include directory
  21. # OPENLDAP_LIBRARIES - The libraries needed to use OpenLDAP
  22. #
  23. # Note that we use winldap for windows builds at present
  24. #
  25. IF (NOT OPENLDAP_FOUND)
  26. IF (WIN32)
  27. SET (ldap_dll "wldap32")
  28. SET (ldap_inc "Winldap.h")
  29. ELSE()
  30. SET (ldap_dll "ldap_r")
  31. SET (ldap_inc "ldap.h")
  32. ENDIF()
  33. IF (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  34. IF (UNIX)
  35. IF (${ARCH64BIT} EQUAL 1)
  36. SET (osincdir "openldap/linux64_gcc4.1.1/include")
  37. SET (oslibdir "openldap/linux64_gcc4.1.1")
  38. ELSE()
  39. SET (osincdir "openldap/linux32_gcc4.1.1/include")
  40. SET (oslibdir "openldap/linux32_gcc4.1.1")
  41. ENDIF()
  42. ELSEIF(WIN32)
  43. SET (osincdir "winldap/include")
  44. SET (oslibdir "winldap/lib")
  45. ELSE()
  46. SET (osincdir "unknown")
  47. ENDIF()
  48. IF (NOT ("${osincdir}" STREQUAL "unknown"))
  49. FIND_PATH (OPENLDAP_INCLUDE_DIR NAMES ${ldap_inc} PATHS "${EXTERNALS_DIRECTORY}/${osincdir}" NO_DEFAULT_PATH)
  50. FIND_LIBRARY (OPENLDAP_LIBRARIES NAMES ${ldap_dll} PATHS "${EXTERNALS_DIRECTORY}/${oslibdir}" NO_DEFAULT_PATH)
  51. ENDIF()
  52. ENDIF()
  53. # if we didn't find in externals, look in system include path
  54. if (USE_NATIVE_LIBRARIES)
  55. FIND_PATH (OPENLDAP_INCLUDE_DIR NAMES ${ldap_inc})
  56. FIND_LIBRARY (OPENLDAP_LIBRARIES NAMES ${ldap_dll})
  57. endif()
  58. include(FindPackageHandleStandardArgs)
  59. find_package_handle_standard_args(OpenLDAP DEFAULT_MSG
  60. OPENLDAP_LIBRARIES
  61. OPENLDAP_INCLUDE_DIR
  62. )
  63. IF (OPENLDAP_FOUND)
  64. IF (UNIX)
  65. STRING(REPLACE "ldap_r" "lber" OPENLDAP_EXTRA "${OPENLDAP_LIBRARIES}")
  66. set (OPENLDAP_LIBRARIES ${OPENLDAP_LIBRARIES} ${OPENLDAP_EXTRA} )
  67. ELSE()
  68. set (OPENLDAP_LIBRARIES ${OPENLDAP_LIBRARIES} netapi32 )
  69. ENDIF()
  70. ENDIF()
  71. MARK_AS_ADVANCED(OPENLDAP_INCLUDE_DIR OPENLDAP_LIBRARIES)
  72. ENDIF()