forked from Cryolite/kanachan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
115 lines (93 loc) · 3.67 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
cmake_minimum_required(VERSION 3.25.0)
project(kanachan)
enable_testing()
if (NOT DEFINED PYTHON_VERSION)
execute_process(
COMMAND bash "-c" "python --version | grep -Eo '^Python [[:digit:]]+\\.[[:digit:]]+' | grep -Eo '[[:digit:]]+\\.[[:digit:]]+'"
OUTPUT_VARIABLE PYTHON_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
if (NOT DEFINED PYTHON_INCLUDE_PATH)
set(PYTHON_INCLUDE_PATH /usr/include/python${PYTHON_VERSION})
endif()
message("PYTHON_VERSION=${PYTHON_VERSION}")
message("PYTHON_INCLUDE_PATH=${PYTHON_INCLUDE_PATH}")
message("CMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
message("CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
set(CMAKE_CXX_STANDARD 20)
include_directories(
"${PYTHON_INCLUDE_PATH}"
src)
if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
add_compile_options(-Werror)
endif()
message("CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(KANACHAN_ENABLE_ASSERT ON)
endif()
if (KANACHAN_ENABLE_ASSERT)
add_compile_definitions(KANACHAN_ENABLE_ASSERT)
endif()
message("KANACHAN_ENABLE_ASSERT=${KANACHAN_ENABLE_ASSERT}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
add_compile_definitions(_GLIBCXX_DEBUG _GLIBCXX_DEBUG_PEDANTIC)
endif()
endif()
if (KANACHAN_WITH_COVERAGE)
add_compile_definitions(KANACHAN_WITH_COVERAGE)
add_compile_options("-coverage")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -coverage")
endif()
message("KANACHAN_WITH_COVERAGE=${KANACHAN_WITH_COVERAGE}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
set(KANACHAN_WITH_ASAN ON)
endif()
endif()
if (KANACHAN_WITH_ASAN)
add_compile_options(-fsanitize=address)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
endif()
message("KANACHAN_WITH_ASAN=${KANACHAN_WITH_ASAN}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
set(KANACHAN_WITH_UBSAN ON)
endif()
endif()
if (KANACHAN_WITH_UBSAN)
add_compile_options(-fsanitize=undefined)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=undefined")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
endif()
message("KANACHAN_WITH_UBSAN=${KANACHAN_WITH_UBSAN}")
if (KANACHAN_WITH_TSAN)
add_compile_options(-fsanitize=thread)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=thread")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
endif()
message("KANACHAN_WITH_TSAN=${KANACHAN_WITH_TSAN}")
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
add_compile_options(-pthread)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pthread")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
message("CMAKE_SHARED_LINKER_FLAGS=${CMAKE_SHARED_LINKER_FLAGS}")
message("CMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(Boost_USE_DEBUG_LIBS ON)
set(Boost_USE_RELEASE_LIBS OFF)
else()
set(Boost_USE_DEBUG_LIBS OFF)
set(Boost_USE_RELEASE_LIBS ON)
endif()
set(BOOST_ROOT "$ENV{HOME}/.local")
find_package(Boost
REQUIRED
COMPONENTS stacktrace_backtrace python)
add_compile_definitions(BOOST_STACKTRACE_USE_BACKTRACE)
add_subdirectory(src)
add_subdirectory(test/annotation_vs_simulation)