-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
55 lines (42 loc) · 1.79 KB
/
CMakeLists.txt
File metadata and controls
55 lines (42 loc) · 1.79 KB
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
cmake_minimum_required(VERSION 3.20)
project(tracepp)
option(ADDRESS_SANITIZER "Use memory error detector (clang only and implies debug mode!)" OFF)
option(ADDRESS_SANITIZER "Use memory error detector (clang only and implies debug mode!)" OFF)
option(THREAD_SANITIZER "Use thread data race detector (clang only and implies debug mode!)" OFF)
option(UNDEFINED_SANITIZER "Use undefined behavior detector (clang only and implies debug mode!)" OFF)
option(EVERY_WARNING "Use -Weverything (clang only)" OFF)
# Exports the "compile_commands.json" file when the generator is Ninja or Makefile.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
include(compilation)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
if (ADDRESS_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(CMAKE_BUILD_TYPE Debug)
endif()
if (THREAD_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
set(CMAKE_BUILD_TYPE Debug)
endif()
if (UNDEFINED_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
set(CMAKE_BUILD_TYPE Debug)
endif()
include_directories(${CMAKE_SOURCE_DIR})
add_subdirectory(examples)
enable_testing()
add_subdirectory(tests)
message(STATUS "--------------------------------------------------")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER} (${CMAKE_CXX_COMPILER_ID})")
message(STATUS "Address sanitizer: ${ADDRESS_SANITIZER}")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
if (EVERY_WARNING)
message(STATUS "-Weverything: ON")
else()
message(STATUS "-Weverything: OFF")
endif()
endif()
message(STATUS "--------------------------------------------------")