7b6b37cc59be1aafbe13c348d8ac6861f0f4b334
[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 MLX5_LIB libmlx5.a)
23
24 if (NOT IBVERBS_LIB OR NOT MLX5_LIB)
25   message(WARNING "rdma plugin - ibverbs not found - rdma plugin disabled")
26   return()
27 endif()
28
29 if (MLX5_LIB)
30   string_append(RDMA_LINK_FLAGS "-Wl,--whole-archive,${MLX5_LIB},--no-whole-archive")
31 endif()
32
33 set(CMAKE_REQUIRED_FLAGS "-fPIC -shared ${IBVERBS_LIB} ${RDMA_LINK_FLAGS}")
34 CHECK_C_SOURCE_COMPILES("" IBVERBS_COMPILES_CHECK)
35
36 if (NOT IBVERBS_COMPILES_CHECK)
37   message(WARNING "rdma plugins - no working ibverbs found - rdma plugin disabled")
38   return()
39 endif()
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 )