-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
66 lines (57 loc) · 2.7 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
cmake_minimum_required (VERSION 3.22)
project (rays C Fortran)
#-------------------------------------------------------------------------------
# Setup build types.
#-------------------------------------------------------------------------------
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
Debug
Release
Sanitized
)
#-------------------------------------------------------------------------------
# Sanitizer options
#-------------------------------------------------------------------------------
macro (register_sanitizer_option name default)
string (TOUPPER ${name} upper_name)
option (SANITIZE_${upper_name} "Enable the ${name} sanitizer" ${default})
endmacro ()
register_sanitizer_option (address ON)
register_sanitizer_option (leak OFF)
register_sanitizer_option (memory OFF)
register_sanitizer_option (thread OFF)
register_sanitizer_option (undefined ON)
#-------------------------------------------------------------------------------
# Set up rays library target.
#-------------------------------------------------------------------------------
add_library (rays)
target_compile_features (rays
PUBLIC
c_std_99
)
target_compile_definitions (rays
PUBLIC
BACKTRACE_SIZE=128
)
target_compile_options (rays
PUBLIC
$<$<CONFIG:Sanitized>:$<$<BOOL:${SANITIZE_ADDRESS}>:-fsanitize=address>>
$<$<CONFIG:Sanitized>:$<$<BOOL:${SANITIZE_THREAD}>:-fsanitize=thread>>
$<$<CONFIG:Sanitized>:$<$<BOOL:${SANITIZE_MEMORY}>:-fsanitize=memory>>
$<$<CONFIG:Sanitized>:$<$<BOOL:${SANITIZE_UNDEFINED}>:-fsanitize=undefined>>
$<$<CONFIG:Sanitized>:$<$<BOOL:${SANITIZE_LEAK}>:-fsanitize=leak>>
$<$<CONFIG:Sanitized>:-g>
$<$<COMPILE_LANGUAGE:Fortran>:-cpp>
)
target_link_options (rays
PUBLIC
$<$<CONFIG:Sanitized>:$<$<BOOL:${SANITIZE_ADDRESS}>:-fsanitize=address>>
$<$<CONFIG:Sanitized>:$<$<BOOL:${SANITIZE_THREAD}>:-fsanitize=thread>>
$<$<CONFIG:Sanitized>:$<$<BOOL:${SANITIZE_MEMORY}>:-fsanitize=memory>>
$<$<CONFIG:Sanitized>:$<$<BOOL:${SANITIZE_UNDEFINED}>:-fsanitize=undefined>>
$<$<CONFIG:Sanitized>:$<$<BOOL:${SANITIZE_LEAK}>:-fsanitize=leak>>
)
add_subdirectory (Source)
#-------------------------------------------------------------------------------
# Setup testing
#-------------------------------------------------------------------------------
enable_testing ()