build: declare some CMake variables as advanced
[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 vpp_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 string_append(RDMA_LINK_FLAGS "-Wl,--whole-archive,${MLX5_LIB},--no-whole-archive")
31
32 set(CMAKE_REQUIRED_FLAGS "-fPIC -shared -pthread -Wno-unused-command-line-argument ${RDMA_LINK_FLAGS} ${IBVERBS_LIB} ${RDMA_UTIL_LIB}")
33 set(CMAKE_REQUIRED_INCLUDES "${IBVERBS_INCLUDE_DIR}")
34 set(CMAKE_REQUIRED_LIBRARIES "c") # force linkage by including libc explicitely
35 CHECK_C_SOURCE_COMPILES("
36 #include <infiniband/verbs.h>
37 int main(void)
38 {
39     return 0 != ibv_get_device_list(0);
40 }" IBVERBS_COMPILES_CHECK)
41
42 if (NOT IBVERBS_COMPILES_CHECK)
43   message(WARNING "rdma plugins - no working ibverbs found - rdma plugin disabled")
44   return()
45 endif()
46
47 include_directories(${IBVERBS_INCLUDE_DIR})
48
49 add_vpp_plugin(rdma
50   SOURCES
51   api.c
52   cli.c
53   device.c
54   format.c
55   plugin.c
56   unformat.c
57   input.c
58   output.c
59
60   MULTIARCH_SOURCES
61   input.c
62   output.c
63
64   API_FILES
65   rdma.api
66
67   API_TEST_SOURCES
68   unformat.c
69   test_api.c
70
71   LINK_FLAGS
72   "${RDMA_LINK_FLAGS}"
73
74   LINK_LIBRARIES
75   ${IBVERBS_LIB}
76   ${RDMA_UTIL_LIB}
77 )