generated from koinos/koinos-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KoinosCompilerOptions.cmake
48 lines (45 loc) · 1.53 KB
/
KoinosCompilerOptions.cmake
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
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(Boost_NO_BOOST_CMAKE ON)
# This is to force color output when using ccache with Unix Makefiles
if (FORCE_COLORED_OUTPUT)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
add_compile_options(-fdiagnostics-color=always)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
add_compile_options(-fcolor-diagnostics)
endif()
endif()
if (MSVC)
# warning level 4 and all warnings as errors
add_compile_options(/W4 /WX)
else()
# lots of warnings and all warnings as errors
add_compile_options(-Werror -Wno-unknown-pragmas)
endif()
if (SANITIZER MATCHES "Address")
message(STATUS "Sanitizer configuration type: ${SANITIZER}")
add_compile_options(
-fsanitize=address
-fsanitize=undefined
-fno-sanitize-recover=all)
add_link_options(
-fsanitize=address
-fsanitize=undefined
-fno-sanitize-recover=all)
elseif(SANITIZER MATCHES "Stack")
message(STATUS "Sanitizer configuration type: ${SANITIZER}")
add_compile_options(
-fsanitize=safe-stack)
add_link_options(
-fsanitize=safe-stack)
elseif(SANITIZER MATCHES "Thread")
message(STATUS "Sanitizer configuration type: ${SANITIZER}")
add_compile_options(
-fsanitize=thread)
add_link_options(
-fsanitize=thread)
elseif(NOT SANITIZER MATCHES "None")
message(FATAL_ERROR "Unknown value for option SANITIZER: '${SANITIZER}'. Must be None, Address, Stack, or Thread.")
endif()