From 63656af5f224b2c07cd74ed0197984bc94760014 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 28 Jun 2018 17:05:53 +0800 Subject: [PATCH] cmake: extract the RDMA libraries interface properties out Signed-off-by: Kefu Chai --- cmake/modules/Findrdmacm.cmake | 10 ++++++++++ cmake/modules/Findverbs.cmake | 7 +++++++ src/CMakeLists.txt | 15 ++------------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/cmake/modules/Findrdmacm.cmake b/cmake/modules/Findrdmacm.cmake index c6b199aaa6b6d..0016180f41f00 100644 --- a/cmake/modules/Findrdmacm.cmake +++ b/cmake/modules/Findrdmacm.cmake @@ -11,6 +11,16 @@ find_library(RDMACM_LIBRARIES rdmacm) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(rdmacm DEFAULT_MSG RDMACM_LIBRARIES RDMACM_INCLUDE_DIR) +if(RDMACM_FOUND) + if(NOT TARGET RDMA::RDMAcm) + add_library(RDMA::RDMAcm UNKNOWN IMPORTED) + endif() + set_target_properties(RDMA::RDMAcm PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${RDMACM_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${RDMACM_LIBRARIES}") +endif() + mark_as_advanced( RDMACM_LIBRARIES ) diff --git a/cmake/modules/Findverbs.cmake b/cmake/modules/Findverbs.cmake index 0409fe74aa78d..e266a4ebc9fae 100644 --- a/cmake/modules/Findverbs.cmake +++ b/cmake/modules/Findverbs.cmake @@ -22,6 +22,13 @@ if(VERBS_FOUND) ibv_exp_query_gid_attr(ctxt, 1, 0, &gid_attr); return 0; } " HAVE_IBV_EXP) + if(NOT TARGET IBVerbs::verbs) + add_library(IBVerbs::verbs UNKNOWN IMPORTED) + endif() + set_target_properties(IBVerbs::verbs PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${VERBS_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${VERBS_LIBRARIES}") endif() mark_as_advanced( diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1b857599e592d..2521ecfaab02d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -297,17 +297,6 @@ if(HAVE_XIO) list(APPEND EXTRALIBS ${XIO_LIBRARY} pthread) endif(HAVE_XIO) -if(HAVE_RDMACM) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${RDMACM_INCLUDE_DIR}") - list(APPEND EXTRALIBS ${RDMACM_LIBRARIES} pthread) -endif(HAVE_RDMACM) - -if(HAVE_VERBS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${VERBS_INCLUDE_DIR}") - list(APPEND EXTRALIBS ${VERBS_LIBRARIES} pthread) -endif(HAVE_VERBS) - - # sort out which allocator to use if(ALLOCATOR STREQUAL "tcmalloc") set(ALLOC_LIBS ${GPERFTOOLS_TCMALLOC_LIBRARY}) @@ -672,10 +661,10 @@ if(HAVE_UDEV) list(APPEND ceph_common_deps ${UDEV_LIBRARIES}) endif() if(HAVE_VERBS) - list(APPEND ceph_common_deps ${VERBS_LIBRARIES}) + list(APPEND ceph_common_deps IBVerbs::verbs) endif() if(HAVE_RDMACM) - list(APPEND ceph_common_deps ${RDMACM_LIBRARIES}) + list(APPEND ceph_common_deps RDMA::RDMAcm) endif() if(NOT WITH_SYSTEM_BOOST) list(APPEND ceph_common_deps ${ZLIB_LIBRARIES}) -- 2.39.5