-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
168 lines (143 loc) · 5.32 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
cmake_minimum_required(VERSION 3.0)
project(socle CXX)
SET(SOCLE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
include_directories ("${SOCLE_DIR}")
include_directories ("common/")
include(ProcessorCount)
ProcessorCount(CPUs)
add_library(socle_lib
baseproxy.hpp
lrproxy.hpp
baseproxy.cpp
hostcx.hpp
hostcx.cpp
lrproxy.cpp
masterproxy.hpp
masterproxy.cpp
basecom.hpp
basecom.cpp
tcpcom.hpp
tcpcom.cpp
udpcom.hpp
udpcom.cpp
sslcom.hpp
sslcom.cpp
sslcom_dh.cpp
sslmitmcom.hpp
sslmitmcom.cpp
sslcertstore.hpp
sslcertstore.cpp
apphostcx.cpp
sobject.cpp
uxcom.cpp
sslcertval.cpp
iproxy.hpp
threadedworker.hpp
threadedacceptor.hpp
threadedacceptor.cpp
threadedreceiver.hpp
threadedreceiver.cpp
socketinfo.hpp
socketinfo.cpp
fdq.hpp
fdq.cpp
peering.hpp
traflog/traflog.hpp
traflog/traflog.cpp
traflog/basefilewriter.hpp
traflog/filewriter.hpp
traflog/poolwriter.hpp
traflog/threadedpoolwriter.hpp
traflog/threadedpoolwriter.cpp
traflog/filewriter.cpp
traflog/poolwriter.cpp
traflog/pcapapi.hpp
traflog/pcapapi.cpp
traflog/basetraflog.hpp
vars.hpp
varmem.hpp
traflog/pcaplog.hpp
traflog/pcaplog.cpp
traflog/smcaplog.hpp
traflog/smcaplog.cpp
traflog/fsoutput.hpp
traflog/fsoutput.cpp)
target_link_libraries(socle_lib socle_common_lib)
if(UNIX)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug)
ENDIF(NOT CMAKE_BUILD_TYPE)
# Pedantic complains about designated initializers (C++20)
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-psabi -std=c++17")
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-unused-parameter -Werror -Wno-unused-function -Wconversion -Wno-psabi -std=c++17")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-unused-variable -Wno-unused-parameter -Wno-unused-function -Wno-psabi -std=c++17")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -fno-stack-protector")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-truncation ")
if("${OPT_GCC_UNROLL}" STREQUAL "Y")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-truncation -funroll-loops --param max-unrolled-insns=4")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-string-concatenation -Wno-overloaded-virtual -Wno-unused-command-line-argument")
endif()
IF (CMAKE_BUILD_TYPE STREQUAL "Coverity")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
ENDIF()
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
if("${OPT_DEBUG_ASAN_THREADS}" STREQUAL "Y")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fPIE -pie")
endif()
if("${OPT_DEBUG_ASAN_LEAKS}" STREQUAL "Y")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -fPIE -pie")
endif()
if("${OPT_DEBUG_ASAN_UB}" STREQUAL "Y")
add_definitions(-DASAN_UB)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fPIE -pie")
endif()
ENDIF()
IF (CMAKE_BUILD_TYPE STREQUAL "Release")
message(">>> release: enabling optimizations (socle)")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fstack-protector-strong -O3 -flto=${CPUs} -s -DBUILD_RELEASE")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto=${CPUs}")
ENDIF()
SET(CMAKE_AR "gcc-ar")
SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_CXX_ARCHIVE_FINISH true)
# detect Alpine - and disable backtrace_* function use
if(EXISTS "/etc/alpine-release")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLIBC_MUSL")
endif()
endif()
if(EXISTS "${SOCLE_DIR}/.git")
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${SOCLE_DIR}
OUTPUT_VARIABLE SOCLE_GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${SOCLE_DIR}
OUTPUT_VARIABLE SOCLE_GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git describe --tags --dirty
WORKING_DIRECTORY ${SOCLE_DIR}
OUTPUT_VARIABLE SOCLE_GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else(EXISTS "${SOCLE_DIR}/.git")
set(SOCLE_GIT_BRANCH "")
set(SOCLE_GIT_COMMIT_HASH "")
set(SOCLE_GIT_VERSION "")
endif(EXISTS "${SOCLE_DIR}/.git")
message(STATUS "Git current socle branch: ${SOCLE_GIT_BRANCH}")
message(STATUS "Git commit socle hash: ${SOCLE_GIT_COMMIT_HASH}")
message(STATUS "Git commit socleversion: ${SOCLE_GIT_VERSION}")
message(STATUS "Generating socle_version.h")
configure_file(
${SOCLE_DIR}/socle_version.h.in
${SOCLE_DIR}/socle_version.h
)