|
1 | 1 | cmake_minimum_required(VERSION 3.15.5) |
2 | 2 | project(duplo) |
| 3 | + |
| 4 | +if(CMAKE_CONFIGURATION_TYPES) |
| 5 | + list(APPEND CMAKE_CONFIGURATION_TYPES ASAN TSAN UBSAN PROFILE) |
| 6 | + list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES) |
| 7 | + set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING |
| 8 | + "Add the configurations that we need" |
| 9 | + FORCE) |
| 10 | +endif() |
| 11 | + |
| 12 | + |
3 | 13 | file(GLOB SOURCES src/*.cpp) |
4 | 14 |
|
5 | 15 | SET(DUPLO_VERSION "\"v1.0.1\"" CACHE STRING "Duplo version") |
@@ -28,4 +38,16 @@ target_link_libraries(duplo PRIVATE nlohmann_json::nlohmann_json) |
28 | 38 |
|
29 | 39 | if(NOT MSVC) |
30 | 40 | target_compile_options(duplo PRIVATE -Wall -Wextra -pedantic -Werror) |
| 41 | + # https://clang.llvm.org/docs/AddressSanitizer.html |
| 42 | + target_compile_options(duplo PRIVATE $<$<CONFIG:ASAN>:-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -O1>) |
| 43 | + target_link_options(duplo PRIVATE $<$<CONFIG:ASAN>:-fsanitize=address>) |
| 44 | + # https://clang.llvm.org/docs/ThreadSanitizer.html |
| 45 | + target_compile_options(duplo PRIVATE $<$<CONFIG:TSAN>:-fsanitize=thread -g -O1>) |
| 46 | + target_link_options(duplo PRIVATE $<$<CONFIG:TSAN>:-fsanitize=thread>) |
| 47 | + # https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html |
| 48 | + target_compile_options(duplo PRIVATE $<$<CONFIG:UBSAN>:-fsanitize=undefined,bounds -g -O1>) |
| 49 | + target_link_options(duplo PRIVATE $<$<CONFIG:UBSAN>:-fsanitize=undefined,bounds>) |
| 50 | + # gperftools CPU Profiler https://github.com/gperftools/gperftools |
| 51 | + target_compile_options(duplo PRIVATE $<$<CONFIG:PROFILE>:-g -O1>) |
| 52 | + target_link_options(duplo PRIVATE $<$<CONFIG:PROFILE>:-lprofiler>) |
31 | 53 | endif() |
0 commit comments