-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
48 lines (34 loc) · 1.42 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
cmake_minimum_required(VERSION 3.0)
project(tracepp)
option(ADDRESS_SANITIZER "Use memory error 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)
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
message(FATAL_ERROR "Clang is required to use address sanitizer to detect memory errors!")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -g -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
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 "--------------------------------------------------")