From: Kefu Chai Date: Sat, 24 Jul 2021 09:39:55 +0000 (+0800) Subject: cmake: define OpenLDAP::OpenLDAP library X-Git-Tag: v17.1.0~1280^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F42473%2Fhead;p=ceph.git cmake: define OpenLDAP::OpenLDAP library * define OpenLDAP::OpenLDAP, so this library can be consumed in a simpler way. * use OpenLDAP::OpenLDAP instead of OpenLDAP_LIBRARIES when appropriate * do not link against unused ${OpenLDAP_LIBRARIES} Signed-off-by: Kefu Chai --- diff --git a/cmake/modules/FindOpenLDAP.cmake b/cmake/modules/FindOpenLDAP.cmake index 1d515c173696..09bb49c62ed8 100644 --- a/cmake/modules/FindOpenLDAP.cmake +++ b/cmake/modules/FindOpenLDAP.cmake @@ -16,7 +16,26 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(OpenLDAP DEFAULT_MSG OpenLDAP_INCLUDE_DIR LDAP_LIBRARY LBER_LIBRARY) -set(OpenLDAP_LIBRARIES ${LDAP_LIBRARY} ${LBER_LIBRARY}) - mark_as_advanced( OpenLDAP_INCLUDE_DIR LDAP_LIBRARY LBER_LIBRARY) + +if(OpenLDAP_FOUND) + set(OpenLDAP_LIBRARIES ${LDAP_LIBRARY} ${LBER_LIBRARY}) + if(NOT TARGET OpenLDAP::OpenLDAP) + add_library(OpenLDAP::LDAP UNKNOWN IMPORTED) + set_target_properties(OpenLDAP::LDAP PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OpenLDAP_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${LDAP_LIBRARY}") + add_library(OpenLDAP::BER UNKNOWN IMPORTED) + set_target_properties(OpenLDAP::BER PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OpenLDAP_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${LBER_LIBRARY}") + add_library(openldap INTERFACE) + target_link_libraries(openldap INTERFACE + OpenLDAP::LDAP + OpenLDAP::BER) + add_library(OpenLDAP::OpenLDAP ALIAS openldap) + endif() +endif() diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index adcbac49d005..00a4e24999e6 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -188,7 +188,6 @@ target_link_libraries(rgw_common ${CURL_LIBRARIES} ${EXPAT_LIBRARIES} ${LUA_LIBRARIES} - ${OpenLDAP_LIBRARIES} PUBLIC spawn) target_include_directories(rgw_common @@ -208,6 +207,11 @@ if(WITH_RADOSGW_AMQP_ENDPOINT) RabbitMQ::RabbitMQ OpenSSL::SSL) endif() +if(WITH_OPENLDAP) + target_link_libraries(rgw_common + PRIVATE + OpenLDAP::OpenLDAP) +endif() if(WITH_RADOSGW_LUA_PACKAGES) target_link_libraries(rgw_common PRIVATE Boost::filesystem StdFilesystem::filesystem) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 6300943e6258..4b316e3c8b15 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -1,7 +1,7 @@ include(AddCephTest) set(UNITTEST_LIBS GMock::Main GMock::GMock GTest::GTest ${CMAKE_THREAD_LIBS_INIT} - ${GSSAPI_LIBRARIES} ${OpenLDAP_LIBRARIES} ${CMAKE_DL_LIBS}) + ${GSSAPI_LIBRARIES} ${CMAKE_DL_LIBS}) if(WIN32) # Needed by Boost. @@ -386,9 +386,11 @@ add_executable(test_rgw_ldap target_link_libraries(test_rgw_ldap librados ceph-common - ${OpenLDAP_LIBRARIES} - ${UNITTEST_LIBS} - ) + ${UNITTEST_LIBS}) +if(WITH_OPENLDAP) + target_link_libraries(test_rgw_ldap + OpenLDAP::OpenLDAP) +endif() endif(${WITH_RADOSGW}) # ceph_multi_stress_watch diff --git a/src/test/librados/CMakeLists.txt b/src/test/librados/CMakeLists.txt index d7eb66730e1c..9242f68ff7e4 100644 --- a/src/test/librados/CMakeLists.txt +++ b/src/test/librados/CMakeLists.txt @@ -12,7 +12,7 @@ target_link_libraries(radostest PUBLIC GTest::GTest ceph-common json_spirit - ${GSSAPI_LIBRARIES} ${OpenLDAP_LIBRARIES} ${EXTRALIBS}) + ${GSSAPI_LIBRARIES} ${EXTRALIBS}) add_library(radostest-cxx STATIC testcase_cxx.cc test_cxx.cc @@ -181,7 +181,7 @@ add_executable(unittest_librados ) add_ceph_unittest(unittest_librados) target_link_libraries(unittest_librados librados ${BLKID_LIBRARIES} - ${GSSAPI_LIBRARIES} ${OpenLDAP_LIBRARIES}) + ${GSSAPI_LIBRARIES}) # unittest_librados_config add_executable(unittest_librados_config @@ -190,7 +190,7 @@ add_executable(unittest_librados_config add_ceph_unittest(unittest_librados_config) target_link_libraries(unittest_librados_config librados - ${BLKID_LIBRARIES} ${GSSAPI_LIBRARIES} ${OpenLDAP_LIBRARIES}) + ${BLKID_LIBRARIES} ${GSSAPI_LIBRARIES}) # Removing this test. We can't shove it into Finisher as it's not a # Context any more, and wrapping it to adapt it would be less fair.