-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
123 lines (93 loc) · 2.97 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
cmake_minimum_required(VERSION 3.13)
project(flashws)
add_library(flashws INTERFACE)
add_library(fws::flashws ALIAS flashws)
target_include_directories(flashws INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
OPTION(FWS_ENABLE_FSTACK "Use f-stack, other wise system api" ON)
OPTION(FWS_DEBUG "In Debug Mode" ON)
OPTION(FWS_DEV_DEBUG "Debug Mode For Development" OFF)
OPTION(FWS_FORCE_NO_EPOLL "Force not to use epoll even if f-stack is turned off" OFF)
OPTION(FWS_FORCE_TIMEOUT_ZERO "Force timeout of FEventWait to be zero, otherwise may keeping wait" OFF)
OPTION(FWS_USE_BORINGSSL "Use BoringSSL" OFF)
if(FWS_DEBUG)
target_compile_definitions(flashws
INTERFACE -DFWS_DEBUG)
endif()
if(FWS_DEV_DEBUG)
target_compile_definitions(flashws
INTERFACE -DFWS_DEV_DEBUG)
endif()
if(FWS_FORCE_NO_EPOLL)
target_compile_definitions(flashws
INTERFACE -DFWS_FORCE_NO_EPOLL)
endif()
if(FWS_FORCE_TIMEOUT_ZERO)
target_compile_definitions(flashws
INTERFACE -DFWS_FORCE_TIMEOUT_ZERO)
endif()
MESSAGE(STATUS "FWS_ENABLE_FSTACK ${FWS_ENABLE_FSTACK}")
MESSAGE(STATUS "FWS_DEBUG: ${FWS_DEBUG}")
MESSAGE(STATUS "FWS_DEV_DEBUG ${FWS_DEV_DEBUG}")
MESSAGE(STATUS "FWS_FORCE_NO_EPOLL ${FWS_FORCE_NO_EPOLL}")
MESSAGE(STATUS "FWS_FORCE_TIMEOUT_ZERO ${FWS_FORCE_TIMEOUT_ZERO}")
MESSAGE(STATUS "FWS_USE_BORINGSSL ${FWS_USE_BORINGSSL}")
# Check if the compiler supports AVX2
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-mavx2" COMPILER_SUPPORTS_AVX2)
if(COMPILER_SUPPORTS_AVX2 AND (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64"))
message(STATUS "AVX2 supported. Adding -mavx2 flag.")
target_compile_options(flashws
INTERFACE
-mavx2
)
else()
message(STATUS "AVX2 not supported by the compiler.")
endif()
if (FWS_USE_BORINGSSL AND NOT FWS_ENABLE_FSTACK)
add_subdirectory(thirdparty/boringssl)
target_compile_definitions(flashws
INTERFACE
-DFWS_USE_BORINGSSL)
target_link_libraries(
flashws
INTERFACE
crypto
ssl
)
else()
find_package(OpenSSL REQUIRED)
target_link_libraries(
flashws
INTERFACE
OpenSSL::SSL
OpenSSL::Crypto
)
target_compile_options(flashws
INTERFACE
-Wno-deprecated-declarations
)
endif()
if(FWS_ENABLE_FSTACK)
target_compile_definitions(flashws
INTERFACE
-DFWS_ENABLE_FSTACK)
find_package(PkgConfig REQUIRED)
pkg_check_modules(DPDK REQUIRED IMPORTED_TARGET libdpdk)
target_compile_options(flashws
INTERFACE
${DPDK_CFLAGS}
)
target_link_options(flashws
INTERFACE
${DPDK_STATIC_LDFLAGS}
"SHELL:-Wl,--whole-archive,-lfstack,--no-whole-archive"
)
target_link_options(flashws
INTERFACE
-pthread
-lm
-lrt
-ldl
-lnuma
)
endif()