Skip to content

Commit

Permalink
cmake: cleanup FindOpenLdap.cmake
Browse files Browse the repository at this point in the history
* use find_package_handle_standard_args() and remove unused bits.
* rename OPENLDAP_LIBS to OPENLDAP_LIBRARIES, to be consistent with
  find_package() modules.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Jul 25, 2016
1 parent 3f6fd58 commit e21d98a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 30 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ option(WITH_OPENLDAP "OPENLDAP is here" ON)
if(${WITH_OPENLDAP})
find_package(OpenLdap REQUIRED)
set(HAVE_OPENLDAP ${OPENLDAP_FOUND})
message(STATUS "${OPENLDAP_LIBS}")
endif(${WITH_OPENLDAP})

option(WITH_FUSE "Fuse is here" ON)
Expand Down
38 changes: 11 additions & 27 deletions cmake/modules/FindOpenLdap.cmake
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
# - Find OpenLDAP C Libraries
#
# OPENLDAP_PREFIX - where to find ldap.h and libraries
# OPENLDAP_FOUND - True if found.
# OPENLDAP_INCLUDE_DIR - Path to the openldap include directory
# OPENLDAP_LIBRARIES - Paths to the ldap and lber libraries

set(OPENLDAP_LIB_DIR "${OPENLDAP_PREFIX}/lib")

find_path(OPENLDAP_INCLUDE_DIR ldap.h NO_DEFAULT_PATH PATHS
find_path(OPENLDAP_INCLUDE_DIR ldap.h PATHS
/usr/include
/opt/local/include
/usr/local/include
"${OPENLDAP_PREFIX}/include"
)

find_library(LIBLDAP NAMES ldap)
find_library(LIBLBER NAMES lber)
/usr/local/include)

if (OPENLDAP_INCLUDE_DIR AND LIBLDAP AND LIBLBER)
set(OPENLDAP_FOUND TRUE)
else (OPENLDAP_INCLUDE_DIR AND LIBLDAP AND LIBLBER)
set(OPENLDAP_FOUND FALSE)
endif (OPENLDAP_INCLUDE_DIR AND LIBLDAP AND LIBLBER)
find_library(LDAP_LIBRARY ldap)
find_library(LBER_LIBRARY lber)

if (OPENLDAP_FOUND)
message(STATUS "Found ldap: ${OPENLDAP_INCLUDE_DIR}")
else (OPENLDAP_FOUND)
if (NOT OPENLDAP_INCLUDE_DIR)
message(FATAL_ERROR "Missing required ldap.h (openldap-devel)")
else (NOT OPENLDAP_INCLUDE_DIR)
message (FATAL_ERROR "Missing required LDAP libraries (openldap)")
endif (NOT OPENLDAP_INCLUDE_DIR)
endif (OPENLDAP_FOUND)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenLdap DEFAULT_MSG
OPENLDAP_INCLUDE_DIR LDAP_LIBRARY LBER_LIBRARY)

set(OPENLDAP_LIBS ${LIBLDAP} ${LIBLBER})
set(OPENLDAP_LIBRARIES ${LDAP_LIBRARY} ${LBER_LIBRARY})

mark_as_advanced(
OPENLDAP_INCLUDE_DIR OPENLDAP_LIB_DIR OPENLDAP_LIBRARIES
)
OPENLDAP_INCLUDE_DIR LDAP_LIBRARY LBER_LIBRARY)
2 changes: 1 addition & 1 deletion src/rgw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ add_library(rgw_a STATIC ${rgw_a_srcs})
target_include_directories(rgw_a PUBLIC ${FCGI_INCLUDE_DIR})
target_link_libraries(rgw_a librados cls_rgw_client cls_refcount_client
cls_log_client cls_statelog_client cls_timeindex_client cls_version_client
cls_replica_log_client cls_user_client curl global expat ${OPENLDAP_LIBS}
cls_replica_log_client cls_user_client curl global expat ${OPENLDAP_LIBRARIES}
${CRYPTO_LIBS})

set(radosgw_srcs
Expand Down
2 changes: 1 addition & 1 deletion src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ set_target_properties(test_rgw_ldap PROPERTIES COMPILE_FLAGS
${UNITTEST_CXX_FLAGS})
target_link_libraries(test_rgw_ldap
librados
${OPENLDAP_LIBS}
${OPENLDAP_LIBRARIES}
${Boost_LIBRARIES}
${UNITTEST_LIBS}
)
Expand Down

0 comments on commit e21d98a

Please sign in to comment.