rdma: add rdma API
[vpp.git] / src / plugins / rdma / CMakeLists.txt
1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 find_path(IBVERBS_INCLUDE_DIR NAMES infiniband/verbs.h)
15
16 if (NOT IBVERBS_INCLUDE_DIR)
17   message(WARNING "-- rdma headers not found - rdma plugin disabled")
18   return()
19 endif()
20
21 vpp_plugin_find_library(rdma IBVERBS_LIB libibverbs.a)
22 vpp_plugin_find_library(rdma RDMA_UTIL_LIB librdma_util.a)
23 vpp_plugin_find_library(rdma MLX5_LIB libmlx5.a)
24
25 if (NOT IBVERBS_LIB OR NOT RDMA_UTIL_LIB OR NOT MLX5_LIB)
26   message(WARNING "rdma plugin - ibverbs not found - rdma plugin disabled")
27   return()
28 endif()
29
30 if (MLX5_LIB)
31   string_append(RDMA_LINK_FLAGS "-Wl,--whole-archive,${MLX5_LIB},--no-whole-archive")
32 endif()
33
34 set(CMAKE_REQUIRED_FLAGS "-fPIC -shared ${IBVERBS_LIB} ${RDMA_UTIL_LIB} ${RDMA_LINK_FLAGS}")
35 CHECK_C_SOURCE_COMPILES("" IBVERBS_COMPILES_CHECK)
36
37 if (NOT IBVERBS_COMPILES_CHECK)
38   message(WARNING "rdma plugins - no working ibverbs found - rdma plugin disabled")
39   return()
40 endif()
41
42 include_directories(${IBVERBS_INCLUDE_DIR})
43
44 add_vpp_plugin(rdma
45   SOURCES
46   api.c
47   cli.c
48   device.c
49   format.c
50   plugin.c
51   unformat.c
52   input.c
53   output.c
54
55   MULTIARCH_SOURCES
56   input.c
57   output.c
58
59   API_FILES
60   rdma.api
61
62   API_TEST_SOURCES
63   unformat.c
64   test_api.c
65
66   LINK_FLAGS
67   "${RDMA_LINK_FLAGS}"
68
69   LINK_LIBRARIES
70   ${IBVERBS_LIB}
71   ${RDMA_UTIL_LIB}
72 )