@@ -38,7 +38,6 @@ option(USE_HTTPLIB "Enable use of httplib" ON)
38
38
option (USE_GRPC "Enable GRPC and Protobuf" ON )
39
39
option (USE_OPENSSL "Enable use of OpenSSL" ON )
40
40
option (BUILD_THIRDPARTY "Whether to build third party libraries or use preinstalled ones" OFF )
41
- option (CODECOVERAGE "Enable Code Coverage Metrics in Clang" OFF )
42
41
option (ENABLE_RESTART_RECOVERY_TESTS "Enable tests for restart recovery" OFF )
43
42
option (BUILD_UTT "Build UTT library" ON )
44
43
option (BUILD_SHARED_LIBS "whether to create shared libraires" OFF )
@@ -50,131 +49,21 @@ if(SLEEP_FOR_DBG)
50
49
add_definitions (-DSLEEP_DBG)
51
50
endif ()
52
51
52
+ # include compiler specific options
53
+ include (cmake/${CMAKE_CXX_COMPILER_ID} .cmake)
54
+ include (cmake/cppcheck.cmake)
53
55
54
- #
55
- # Compiler options
56
- #
57
- #
58
-
59
- string (APPEND CMAKE_CXX_FLAGS " -Wall" )
60
- string (APPEND CMAKE_CXX_FLAGS " -Wbuiltin-macro-redefined" )
61
- string (APPEND CMAKE_CXX_FLAGS " -pedantic" )
62
- string (APPEND CMAKE_CXX_FLAGS " -Werror" )
63
- string (APPEND CMAKE_CXX_FLAGS " -fno-omit-frame-pointer" )
64
-
65
- # At most, only one of the next options should be defined from below ONLY_ONE_OPT_RAISED_CHECK
66
- set (COUNTER 0)
67
- set (ONLY_ONE_OPT_RAISED_CHECK LEAKCHECK;THREADCHECK;UNDEFINED_BEHAVIOR_CHECK;CODECOVERAGE;HEAPTRACK)
68
- foreach (option IN LISTS ONLY_ONE_OPT_RAISED_CHECK)
69
- if (${option} )
70
- MATH (EXPR COUNTER "${COUNTER} +1" )
71
- endif ()
72
- endforeach ()
73
- if (${COUNTER} GREATER 1)
74
- message (FATAL_ERROR "More than one of the following options were chosen: \
75
- LEAKCHECK=${LEAKCHECK} \
76
- THREADCHECK=${THREADCHECK} \
77
- UNDEFINED_BEHAVIOR_CHECK=${UNDEFINED_BEHAVIOR_CHECK} \
78
- CODECOVERAGE=${CODECOVERAGE} \
79
- HEAPTRACK=${HEAPTRACK} \
80
- " )
81
- endif ()
82
-
83
- if (LEAKCHECK)
84
- string (APPEND CMAKE_CXX_FLAGS " -fsanitize=leak -fsanitize=address" )
85
- add_compile_definitions (RUN_WITH_LEAKCHECK=1)
86
- message ("-- Address and Leak Sanitizers Enabled" )
87
- elseif (THREADCHECK)
88
- string (APPEND CMAKE_CXX_FLAGS " -fsanitize=thread" )
89
- message ("-- Thread Sanitizer Enabled" )
90
- elseif (UNDEFINED_BEHAVIOR_CHECK)
91
- string (APPEND CMAKE_CXX_FLAGS " -fsanitize=undefined" )
92
- message ("-- Undefined Behavior Sanitizer Enabled" )
93
- elseif (UNDEFINED_BEHAVIOR_CHECK)
94
- string (APPEND CMAKE_CXX_FLAGS " -fsanitize=undefined" )
95
- message ("-- Undefined Behavior Sanitizer Enabled" )
96
- elseif (HEAPTRACK)
97
- message ("-- Heaptrack Enabled" )
98
- endif ()
99
-
100
-
101
- if (OMIT_TEST_OUTPUT)
102
- message ("-- OMIT_TEST_OUTPUT Enabled" )
103
- endif ()
104
- if (KEEP_APOLLO_LOGS)
105
- message ("-- KEEP_APOLLO_LOGS Enabled" )
106
- endif ()
107
- if (RUN_APOLLO_TESTS)
108
- message ("-- RUN_APOLLO_TESTS Enabled" )
109
- endif ()
56
+ list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR} /cmake" )
57
+ include (cmake/grpc_utils.cmake)
110
58
111
- #
112
- # Code Quality (static, dynamic, coverage) Analysers
113
- #
114
- if (CODECOVERAGE)
115
- string (APPEND CMAKE_CXX_FLAGS " -fprofile-instr-generate -fcoverage-mapping" )
116
- string (APPEND CMAKE_EXE_LINKER_FLAGS " -fprofile-instr-generate" )
117
- message ( "-- Building with llvm Code Coverage Tools" )
59
+ if (BUILD_TESTING)
60
+ include (CTest)
118
61
endif ()
119
62
120
- if (CPPCHECK)
121
- find_program (cppcheck cppcheck HINTS "/usr/local/bin/cppcheck" REQUIRED)
122
- message (STATUS "cppcheck ${cppcheck} " )
123
- if (cppcheck MATCHES "NOTFOUND" )
124
- message (FATAL_ERROR "failed to find cppcheck executable for CPPCHECK option" )
125
- endif ()
126
- # Create <cppcheck> work folder for whole program analysis, for faster analysis and to store some useful debug information
127
- # Add cppcheck work folder and reports folder for cppcheck output.
128
- file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR} /cppcheck/reports/)
129
- # max number of threads = number of CPUs
130
- include (ProcessorCount)
131
- ProcessorCount(CPU_CORES)
132
- set (CMAKE_CXX_CPPCHECK
133
- "${cppcheck} "
134
- "--enable=all"
135
- "--inconclusive"
136
- "--inline-suppr"
137
- "--quiet"
138
- "--std=c++17"
139
- "--template=cppcheck1"
140
- "--max-configs=1"
141
- "--library=boost.cfg"
142
- "--library=openssl.cfg"
143
- "--library=googletest"
144
- "--addon=threadsafety.py"
145
- "--cppcheck-build-dir=${PROJECT_BINARY_DIR} /cppcheck/"
146
- "--suppressions-list=${CMAKE_CURRENT_SOURCE_DIR} /.cppcheck/suppressions.txt"
147
- "--exitcode-suppressions=${CMAKE_CURRENT_SOURCE_DIR} /.cppcheck/exitcode-suppressions.txt"
148
- CACHE STRING "Default value for cppcheck CXX_CPPCHECK target property" )
149
- endif (CPPCHECK)
150
-
151
63
if (USE_S3_OBJECT_STORE)
152
64
add_compile_definitions (USE_S3_OBJECT_STORE=1)
153
65
endif ()
154
- # TODO: Figure out right way to deal with -fstrict-overflow / -Wstrict-overflow related errors
155
- # string(APPEND CXX_FLAGS " -fno-strict-overflow")
156
- # Prevents some buffer overflows: https://access.redhat.com/blogs/766093/posts/1976213
157
- string (APPEND CMAKE_CXX_FLAGS_RELEASE " -D_FORTIFY_SOURCE=2" )
158
-
159
- string (APPEND CMAKE_CXX_FLAGS_DEBUG " -fstack-protector-all" )
160
-
161
-
162
- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
163
-
164
- string (APPEND CMAKE_CXX_FLAGS " -ferror-limit=3" )
165
-
166
-
167
- # Export a compile database for use by semantic analysis tools
168
- set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
169
-
170
- elseif ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "GNU" )
171
- string (APPEND CMAKE_CXX_FLAGS " -fmax-errors=3" )
172
- endif ()
173
-
174
- list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR} /cmake" )
175
- include (cmake/grpc_utils.cmake)
176
66
177
- include (CTest)
178
67
#
179
68
# Subdirectories
180
69
#
@@ -207,10 +96,18 @@ endif()
207
96
#
208
97
# Setup testing
209
98
#
210
-
211
- option (OMIT_TEST_OUTPUT "Forwards output stdout and stdin to /dev/null" OFF )
212
-
213
99
if (BUILD_TESTING)
100
+ option (OMIT_TEST_OUTPUT "Forwards output stdout and stdin to /dev/null" OFF )
101
+ if (OMIT_TEST_OUTPUT)
102
+ message ("-- OMIT_TEST_OUTPUT Enabled" )
103
+ endif ()
104
+ if (KEEP_APOLLO_LOGS)
105
+ message ("-- KEEP_APOLLO_LOGS Enabled" )
106
+ endif ()
107
+ if (RUN_APOLLO_TESTS)
108
+ message ("-- RUN_APOLLO_TESTS Enabled" )
109
+ endif ()
110
+
214
111
add_subdirectory (bftengine/tests)
215
112
add_subdirectory (tests)
216
113
add_subdirectory (messages)
0 commit comments