Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / cmake / modules / Findrdma.cmake
1 # - Find rdma
2 # Find the rdma library and includes
3 #
4 # RDMA_INCLUDE_DIR - where to find ibverbs.h, etc.
5 # RDMA_LIBRARIES - List of libraries when using ibverbs.
6 # RDMA_FOUND - True if ibverbs found.
7
8 find_path(RDMA_INCLUDE_DIR infiniband/verbs.h)
9
10 set(RDMA_NAMES ${RDMA_NAMES} ibverbs)
11 find_library(RDMA_LIBRARY NAMES ${RDMA_NAMES})
12
13 if (RDMA_INCLUDE_DIR AND RDMA_LIBRARY)
14   set(RDMA_FOUND TRUE)
15   set(RDMA_LIBRARIES ${RDMA_LIBRARY})
16 else ()
17   set(RDMA_FOUND FALSE)
18   set( RDMA_LIBRARIES )
19 endif ()
20
21 if (RDMA_FOUND)
22   message(STATUS "Found libibverbs: ${RDMA_LIBRARY}")
23
24   include(CheckCXXSourceCompiles)
25   CHECK_CXX_SOURCE_COMPILES("
26     #include <infiniband/verbs.h>
27     int main() {
28       struct ibv_context* ctxt;
29       struct ibv_exp_gid_attr gid_attr;
30       ibv_exp_query_gid_attr(ctxt, 1, 0, &gid_attr);
31       return 0;
32     } " HAVE_IBV_EXP)
33
34 else ()
35   message(STATUS "Not Found libibverbs: ${RDMA_LIBRARY}")
36   if (RDMA_FIND_REQUIRED)
37     message(STATUS "Looked for libibverbs named ${RDMA_NAMES}.")
38     message(FATAL_ERROR "Could NOT find libibverbs")
39   endif ()
40 endif ()
41
42 # handle the QUIETLY and REQUIRED arguments and set UUID_FOUND to TRUE if
43 # all listed variables are TRUE
44 include(FindPackageHandleStandardArgs)
45 find_package_handle_standard_args(ibverbs DEFAULT_MSG RDMA_LIBRARIES RDMA_INCLUDE_DIR)
46
47 mark_as_advanced(
48   RDMA_LIBRARY
49 )