forked from WqyJh/dpdk-burst-replay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
60 lines (48 loc) · 2 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
cmake_minimum_required(VERSION 2.8)
project(dpdk-replay)
# generating build/compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_definitions(-march=native)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
message(STATUS "No CMAKE_BUILD_TYPE selected, defaulting to ${CMAKE_BUILD_TYPE}")
endif()
set(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -O0 -Wall -g -ggdb")
set(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -O3 -Wall")
find_package(PkgConfig)
message(STATUS "--- PKG_CONFIG_FOUND: ${PKG_CONFIG_FOUND}")
message(STATUS "--- PKG_CONFIG_VERSION_STRING: ${PKG_CONFIG_VERSION_STRING}")
# dpdk pkgconfig
set(ENV{PKG_CONFIG_PATH} "/usr/local/lib/x86_64-linux-gnu/pkgconfig")
pkg_search_module(DPDK libdpdk)
if (DPDK_FOUND) # DPDK >= 20.11
message(STATUS "dpdk libraries found by pkg-config")
message(STATUS "DPDK_LIBRARIES: ${DPDK_LIBRARIES}")
message(STATUS "DPDK_INCLUDE_DIRS: ${DPDK_INCLUDE_DIRS}")
message(STATUS "DPDK_CFLAGS: ${DPDK_CFLAGS}")
set(CFLAGS ${CFLAGS} ${DPDK_CFLAGS})
set(LIBRARIES ${LIBRARIES} ${DPDK_LIBRARIES})
else()
# DPDK include directory. Locating rte_config.h does not work on some systems.
# Example: it may be kept in /usr/include/x86_64-linux-gnu/, and symlinked
# from the real DPDK include directory (/usr/include/dpdk/).
find_path(DPDK_INCLUDE_DIRS NAMES rte_ethdev.h PATH_SUFFIXES dpdk)
if (DPDK_INCLUDE_DIRS)
set(DPDK_LIBRARIES -Wl,--whole-archive dpdk -Wl,--no-whole-archive)
message(STATUS "DPDK include directory = ${DPDK_INCLUDE_DIRS}")
else()
message(FATAL_ERROR "DPDK include directory not found. Please install DPDK.")
endif()
endif()
include_directories(${PROJECT_SOURCE_DIR} ${DPDK_INCLUDE_DIRS})
set(LIBRARIES ${LIBRARIES} ${DPDK_LIBRARIES} pthread dl rt m numa)
add_executable(dpdk-replay
src/main.c
src/cpus.c
src/dpdk.c
src/pcap.c
src/utils.c
)
target_link_libraries(dpdk-replay ${LIBRARIES})
include(GNUInstallDirs)
install(TARGETS dpdk-replay RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})