Add RDMA ibverb driver plugin
[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 message(STATUS "RDMA plugins - looking for ibverbs")
15
16 find_path(IBVERBS_INCLUDE_DIR NAMES infiniband/verbs.h)
17 find_library(IBVERBS_LIB NAMES libibverbs.a)
18 find_library(MLX5_LIB NAMES libmlx5.a)
19
20 if (NOT IBVERBS_LIB OR NOT MLX5_LIB)
21   message(WARNING "RDMA plugins - ibverbs not found - rdma_plugin disabled")
22   return()
23 endif()
24
25 if (MLX5_LIB)
26   string_append(RDMA_LINK_FLAGS "-Wl,--whole-archive,${MLX5_LIB},--no-whole-archive")
27 endif()
28
29 set(CMAKE_REQUIRED_FLAGS "-fPIC -shared ${IBVERBS_LIB} ${RDMA_LINK_FLAGS}")
30 CHECK_C_SOURCE_COMPILES("" IBVERBS_COMPILES_CHECK)
31
32 if (NOT IBVERBS_COMPILES_CHECK)
33   message(WARNING "RDMA plugins - no working ibverbs found - rdma_plugin disabled")
34   return()
35 endif()
36
37 message(STATUS "RDMA plugins - found ${IBVERBS_INCLUDE_DIR}")
38 message(STATUS "RDMA plugins - found ${IBVERBS_LIB}")
39 message(STATUS "RDMA plugins - found ${MLX5_LIB}")
40
41 include_directories(${IBVERBS_INCLUDE_DIR})
42
43 add_vpp_plugin(rdma
44   SOURCES
45   cli.c
46   device.c
47   format.c
48   plugin.c
49   input.c
50   output.c
51
52   MULTIARCH_SOURCES
53   input.c
54   output.c
55
56   LINK_FLAGS
57   "${RDMA_LINK_FLAGS}"
58
59   LINK_LIBRARIES
60   ${IBVERBS_LIB}
61 )