* 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>
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()
${CURL_LIBRARIES}
${EXPAT_LIBRARIES}
${LUA_LIBRARIES}
- ${OpenLDAP_LIBRARIES}
PUBLIC
spawn)
target_include_directories(rgw_common
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)
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.
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
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
)
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
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.