@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.12)
3
3
# ------------------------------------------------------------------------------------------------
4
4
project (ut_exe CXX ) # as early as possible, eg must before CMAKE_CXX_FLAGS
5
5
6
- if (COV )
6
+ if (COV STREQUAL "1" )
7
7
message ("!!! coverage enabled" )
8
8
set (CMAKE_CXX_STANDARD 20 ) # if gtest fix bug, try c++20/23 to see cov rate inc or not
9
9
@@ -17,11 +17,40 @@ if(COV)
17
17
18
18
add_compile_definitions (SMART_LOG )
19
19
add_compile_definitions (WITH_HID_LOG ) # more info to debug ci
20
+
21
+ elseif (COV STREQUAL "asan" )
22
+ set (CMAKE_CXX_STANDARD 14 ) # low c++ version for wide usage
23
+ message ("!!! SANITIZE for: use-after-free, double-free, out-of-bound" )
24
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address" ) # compile
25
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address" ) # link
26
+ set (lib_san "-lasan" )
27
+
28
+ elseif (COV STREQUAL "lsan" )
29
+ set (CMAKE_CXX_STANDARD 14 )
30
+ message ("!!! SANITIZE for: leak" )
31
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=leak" )
32
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=leak" )
33
+ set (lib_san "-llsan" )
34
+
35
+ elseif (COV STREQUAL "tsan" )
36
+ set (CMAKE_CXX_STANDARD 14 )
37
+ message ("!!! SANITIZE for: thread" )
38
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=thread" )
39
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread" )
40
+
41
+ elseif (COV STREQUAL "ubsan" )
42
+ set (CMAKE_CXX_STANDARD 14 )
43
+ message ("!!! SANITIZE for: undefined behavior" )
44
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=undefined" )
45
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined" )
46
+
20
47
else ()
48
+ message ("!!! UT only - no cov, no SANITIZE check etc" )
21
49
set (CMAKE_CXX_STANDARD 14 ) # low c++ version for wide usage
22
50
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1" ) # fastest build+ut
23
51
#add_compile_definitions(WITH_HID_LOG) # cov no HID; easy to turn-on
24
52
endif ()
53
+
25
54
set (CMAKE_CXX_STANDARD_REQUIRED TRUE )
26
55
set (CMAKE_CXX_EXTENSIONS OFF )
27
56
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions" ) # inc branch coverage
0 commit comments