1 # Copyright (c) 2016 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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 ##############################################################################
15 # Find lib and include files
16 ##############################################################################
17 find_path(DPDK_INCLUDE_DIR PATH_SUFFIXES dpdk NAMES rte_config.h HINTS
18 ${DPDK_INCLUDE_DIR_HINT})
19 find_library(DPDK_LIB NAMES libdpdk.a HINTS ${DPDK_LIB_DIR_HINT})
21 ##############################################################################
23 ##############################################################################
24 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dpdk_version.c
27 #include <rte_version.h>
30 puts(strchr(rte_version(), ' ') + 1);
35 try_compile(DPDK_VERSION_COMPILED
36 ${CMAKE_CURRENT_BINARY_DIR}
37 ${CMAKE_CURRENT_BINARY_DIR}/dpdk_version.c
39 -DINCLUDE_DIRECTORIES=${DPDK_INCLUDE_DIR}
40 COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/dpdk_version.bin
43 if(DPDK_VERSION_COMPILED)
45 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
46 COMMAND ./dpdk_version.bin
47 OUTPUT_VARIABLE DPDK_VERSION
48 OUTPUT_STRIP_TRAILING_WHITESPACE
53 ${CMAKE_CURRENT_BINARY_DIR}/dpdk_version.c
54 ${CMAKE_CURRENT_BINARY_DIR}/dpdk_version.bin
58 ##############################################################################
60 ##############################################################################
61 if(DPDK_INCLUDE_DIR AND DPDK_LIB)
62 include_directories (${DPDK_INCLUDE_DIR})
63 add_vpp_plugin(dpdk_plugin
85 vpp_library_set_multiarch_sources(dpdk_plugin
91 get_filename_component(DPDK_LIB_DIR ${DPDK_LIB} DIRECTORY)
92 set(DPDK_LINK_FLAGS "-L${DPDK_LIB_DIR} -Wl,--whole-archive,${DPDK_LIB},--no-whole-archive")
93 set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,--exclude-libs,libIPSec_MB.a,-l:libIPSec_MB.a")
94 set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,-lnuma")
95 set_target_properties(dpdk_plugin PROPERTIES LINK_FLAGS "${DPDK_LINK_FLAGS}")
96 message("-- Found DPDK ${DPDK_VERSION}: ${DPDK_INCLUDE_DIR} ${DPDK_LIB}")
98 message("-- DPDK not found - dpdk_plugin disabled")