blob: 8742be0bb8b22aa2009fd77648ccdc40c6fb05e4 (
plain)
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
|
# This file provides a special "standard_settings" target which is supposed to
# be linked privately by all other targets.
add_library(standard_settings INTERFACE)
if(CMAKE_CXX_COMPILER_ID MATCHES "^GNU|(Apple)?Clang$")
target_compile_options(
standard_settings
INTERFACE -include ${CMAKE_BINARY_DIR}/config.h
)
option(ENABLE_COVERAGE "Enable coverage reporting for GCC/Clang" FALSE)
if(ENABLE_COVERAGE)
target_compile_options(standard_settings INTERFACE --coverage -O0 -g)
target_link_libraries(standard_settings INTERFACE --coverage)
endif()
set(SANITIZERS "")
option(ENABLE_SANITIZER_ADDRESS "Enable address sanitizer" FALSE)
if(ENABLE_SANITIZER_ADDRESS)
list(APPEND SANITIZERS "address")
endif()
option(ENABLE_SANITIZER_MEMORY "Enable memory sanitizer" FALSE)
if(ENABLE_SANITIZER_MEMORY)
list(APPEND SANITIZERS "memory")
endif()
option(
ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
"Enable undefined behavior sanitizer"
FALSE)
if(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR)
list(APPEND SANITIZERS "undefined")
endif()
option(ENABLE_SANITIZER_THREAD "Enable thread sanitizer" FALSE)
if(ENABLE_SANITIZER_THREAD)
list(APPEND SANITIZERS "thread")
endif()
foreach(SANITIZER IN LISTS SANITIZERS)
target_compile_options(
standard_settings
INTERFACE -fsanitize=${SANITIZER})
target_link_libraries(
standard_settings
INTERFACE -fsanitize=${SANITIZER})
endforeach()
include(StdAtomic)
elseif(MSVC)
target_compile_options(standard_settings INTERFACE "/FI${CMAKE_BINARY_DIR}/config.h")
target_compile_options(
standard_settings
INTERFACE /Zc:preprocessor /Zc:__cplusplus /D_CRT_SECURE_NO_WARNINGS
)
endif()
|