FindOPENLDAP.cmake 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. IF (${ARCH64BIT} EQUAL 1)
  45. SET (oslibdir "winldap/lib64")
  46. ELSE()
  47. SET (oslibdir "winldap/lib32")
  48. ENDIF()
  49. ELSE()
  50. SET (osincdir "unknown")
  51. ENDIF()
  52. IF (NOT ("${osincdir}" STREQUAL "unknown"))
  53. FIND_PATH (OPENLDAP_INCLUDE_DIR NAMES ${ldap_inc} PATHS "${EXTERNALS_DIRECTORY}/${osincdir}" NO_DEFAULT_PATH)
  54. FIND_LIBRARY (OPENLDAP_LIBRARIES NAMES ${ldap_dll} PATHS "${EXTERNALS_DIRECTORY}/${oslibdir}" NO_DEFAULT_PATH)
  55. ENDIF()
  56. ENDIF()
  57. # if we didn't find in externals, look in system include path
  58. if (USE_NATIVE_LIBRARIES)
  59. FIND_PATH (OPENLDAP_INCLUDE_DIR NAMES ${ldap_inc})
  60. FIND_LIBRARY (OPENLDAP_LIBRARIES NAMES ${ldap_dll})
  61. endif()
  62. include(FindPackageHandleStandardArgs)
  63. find_package_handle_standard_args(OpenLDAP DEFAULT_MSG
  64. OPENLDAP_LIBRARIES
  65. OPENLDAP_INCLUDE_DIR
  66. )
  67. IF (OPENLDAP_FOUND)
  68. IF (UNIX)
  69. STRING(REPLACE "ldap_r" "lber" OPENLDAP_EXTRA "${OPENLDAP_LIBRARIES}")
  70. set (OPENLDAP_LIBRARIES ${OPENLDAP_LIBRARIES} ${OPENLDAP_EXTRA} )
  71. ELSE()
  72. set (OPENLDAP_LIBRARIES ${OPENLDAP_LIBRARIES} netapi32 )
  73. ENDIF()
  74. ENDIF()
  75. MARK_AS_ADVANCED(OPENLDAP_INCLUDE_DIR OPENLDAP_LIBRARIES)
  76. ENDIF()