forked from outscale/butterfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
148 lines (114 loc) · 6.39 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
cmake_minimum_required(VERSION 2.6)
include(ExternalProject)
project(BUTTERFLY)
# 3rdparties directories
set(3RDPARTY_DIR ${PROJECT_SOURCE_DIR}/3rdparty)
set(3RDPARTY_INSTALL_DIR ${PROJECT_BINARY_DIR}/3rdparty-build)
set(DPDK_INSTALL_DIR ${3RDPARTY_INSTALL_DIR}/dpdk)
set(LIBZMQ_INSTALL_DIR ${3RDPARTY_INSTALL_DIR}/libzmq)
set(ZMQPP_INSTALL_DIR ${3RDPARTY_INSTALL_DIR}/zmqpp)
set(PROTOBUF_INSTALL_DIR ${3RDPARTY_INSTALL_DIR}/protobuf)
set(PG_INSTALL_DIR ${3RDPARTY_INSTALL_DIR}/packetgraph)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules/")
find_package(GLIB2 REQUIRED)
set(PROTOBUF_LIBRARIES
${PROTOBUF_INSTALL_DIR}/src/.libs/libprotobuf-lite.a
${PROTOBUF_INSTALL_DIR}/src/.libs/libprotobuf.a)
set(PROTOBUF_INCLUDE_DIR
${3RDPARTY_DIR}/protobuf/src
${PROJECT_BINARY_DIR})
set(PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_INSTALL_DIR}/src/protoc)
set(LIBZMQ_LIBRARIES ${LIBZMQ_INSTALL_DIR}/lib/libzmq-static.a)
set(LIBZMQ_INCLUDE_DIR ${3RDPARTY_DIR}/libzmq/include)
set(ZMQPP_LIBRARIES ${ZMQPP_INSTALL_DIR}/libzmqpp-static.a)
set(ZMQPP_INCLUDE_DIR ${3RDPARTY_DIR}/zmqpp/src)
set(PG_LIBRARIES
-L${DPDK_INSTALL_DIR}/build/lib -Wl,--start-group
${DPDK_INSTALL_DIR}/build/lib/libdpdk.a
${PG_INSTALL_DIR}/lib/libbpfjit.a
${PG_INSTALL_DIR}/lib/libcdb.a
${PG_INSTALL_DIR}/lib/libnpf.a
${PG_INSTALL_DIR}/lib/libnpfkern.a
${PG_INSTALL_DIR}/lib/libnvlist.a
${PG_INSTALL_DIR}/lib/libthmap.a
${PG_INSTALL_DIR}/lib/libqsbr.a
${PG_INSTALL_DIR}/lib/libsljit.a
${PG_INSTALL_DIR}/lib/libpacketgraph.a -Wl,--end-group
-lz -lnuma -ldl -lpcap)
set(PG_INCLUDE_DIR ${3RDPARTY_DIR}/packetgraph/include)
set(CMAKE_C_FLAGS "-g -O3 -march=core-avx-i -mtune=core-avx-i -fmessage-length=0 -Werror -Wall -Wextra -Wwrite-strings -Winit-self -Wcast-align -Wpointer-arith -fno-strict-aliasing -Wformat=2 -Wmissing-declarations -Wmissing-include-dirs -Wno-unused-parameter -Wuninitialized -Wold-style-definition -Wstrict-prototypes -Wmissing-prototypes -L${DPDK_INSTALL_DIR}/build/lib")
option(COVERAGE "Coverage" OFF)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
set(GCC_COVERAGE_COMPILE_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
set(GCC_COVERAGE_LINK_FLAGS "-lgcov")
option(ASAN "Asan" OFF)
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
add_custom_target(butterfly-genere-version
COMMAND ${PROJECT_SOURCE_DIR}/scripts/genHdrVersion.sh ${PROJECT_BINARY_DIR}/api/version.h
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
add_subdirectory(3rdparty)
add_subdirectory(api)
# Add custom targets for tests
add_custom_target(tests-all
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_all.sh ${PROJECT_BINARY_DIR} ${VERBOSE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(tests-crypto
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_crypto.sh ${PROJECT_BINARY_DIR} ${VERBOSE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(style
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_api_style.sh
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(tests-api
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_api.sh ${PROJECT_BINARY_DIR} ${VERBOSE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(tests-scenario
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_scenario.sh ${PROJECT_BINARY_DIR} "all" ${VERBOSE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(tests-coverage
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_coverage.sh ${PROJECT_BINARY_DIR}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(tests-firewall
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_scenario.sh ${PROJECT_BINARY_DIR} "firewall" ${VERBOSE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(tests-icmp
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_scenario.sh ${PROJECT_BINARY_DIR} "icmp" ${VERBOSE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(tests-udp
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_scenario.sh ${PROJECT_BINARY_DIR} "udp" ${VERBOSE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(tests-tcp
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_scenario.sh ${PROJECT_BINARY_DIR} "tcp" ${VERBOSE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(tests-sctp
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_scenario.sh ${PROJECT_BINARY_DIR} "sctp" ${VERBOSE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(tests-udp_tcp
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_scenario.sh ${PROJECT_BINARY_DIR} "udp_tcp" ${VERBOSE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(tests-other
COMMAND ${PROJECT_SOURCE_DIR}/scripts/tests_scenario.sh ${PROJECT_BINARY_DIR} "other" ${VERBOSE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(package-rpm
COMMAND ${PROJECT_SOURCE_DIR}/scripts/build_package.sh ${PROJECT_BINARY_DIR} rpm
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(package-deb
COMMAND ${PROJECT_SOURCE_DIR}/scripts/build_package.sh ${PROJECT_BINARY_DIR} deb
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(package-fat-rpm
COMMAND ${PROJECT_SOURCE_DIR}/scripts/build_fat_package.sh ${PROJECT_BINARY_DIR} rpm
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(package-fat-deb
COMMAND ${PROJECT_SOURCE_DIR}/scripts/build_fat_package.sh ${PROJECT_BINARY_DIR} deb
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(package-fat
COMMAND rm -rvf ${PROJECT_BINARY_DIR}/fat-butterfly*
COMMAND ${PROJECT_SOURCE_DIR}/scripts/dep-gets.sh ${PROJECT_BINARY_DIR}/api/server/butterflyd ${PROJECT_BINARY_DIR}/fat-butterflyd
COMMAND ${PROJECT_SOURCE_DIR}/scripts/dep-gets.sh ${PROJECT_BINARY_DIR}/api/client/butterfly ${PROJECT_BINARY_DIR}/fat-butterfly
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})