]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: define OpenLDAP::OpenLDAP library 42473/head
authorKefu Chai <kchai@redhat.com>
Sat, 24 Jul 2021 09:39:55 +0000 (17:39 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 24 Jul 2021 11:28:56 +0000 (19:28 +0800)
* 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 <kchai@redhat.com>
cmake/modules/FindOpenLDAP.cmake
src/rgw/CMakeLists.txt
src/test/CMakeLists.txt
src/test/librados/CMakeLists.txt

index 1d515c173696610bbaab63415cebe559016ab9fd..09bb49c62ed86399fc966cb8c8da887301e5d3ef 100644 (file)
@@ -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()
index adcbac49d005fae886e25c6c271661c2acd105eb..00a4e24999e6ea24adfae5eadfe7552922e41e2c 100644 (file)
@@ -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)
index 6300943e625823873eefbf8725a9bb7f2073dab7..4b316e3c8b15a91d680449c9478800bdab9edd9a 100644 (file)
@@ -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
index d7eb66730e1c00845d10b00448702801bf1d7db9..9242f68ff7e4129b07c8042e22c6821d518093b5 100644 (file)
@@ -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.