From: Kefu Chai Date: Thu, 28 Jun 2018 09:05:53 +0000 (+0800) Subject: cmake: extract the RDMA libraries interface properties out X-Git-Tag: v14.0.1~977^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F22752%2Fhead;p=ceph.git cmake: extract the RDMA libraries interface properties out Signed-off-by: Kefu Chai --- diff --git a/cmake/modules/Findrdmacm.cmake b/cmake/modules/Findrdmacm.cmake index c6b199aaa6b6..0016180f41f0 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 0409fe74aa78..e266a4ebc9fa 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 1b857599e592..2521ecfaab02 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})