-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
114 lines (92 loc) · 3.04 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
cmake_minimum_required(VERSION 3.19)
project(MVPL CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#****************************************************************************#
# Variables #
#****************************************************************************#
execute_process(COMMAND nproc --all OUTPUT_VARIABLE N_CORES)
set({CMAKE_BUILD_PARALLEL_LEVEL} N_CORES)
message(STATUS "Using ${N_CORES} cores.")
set(MVPL_compile_flags
-g
-O0
-Wall
-Wextra
-Wpedantic
-fsanitize=address
-fsanitize=pointer-compare
-fsanitize=pointer-subtract
-fsanitize=leak
-fsanitize=undefined
-fsanitize=float-divide-by-zero
-fsanitize=float-cast-overflow
-fstack-protector-strong
-fstack-clash-protection
-fno-optimize-sibling-calls
-fno-omit-frame-pointer
-Wnull-dereference
-Wshadow
-Wpointer-arith
-Wswitch-default
-Wswitch-enum
-Wconversion
-Wuninitialized
-Weffc++
-Wstack-protector
)
if (DEFINED ENV{MVPL_PROFILE_COMPILE_TIME})
list(APPEND MVPL_compile_flags ${MVPL_compile_flags} -ftime-trace)
endif()
set(MVPL_link_flags
-fsanitize=address
-fsanitize=pointer-compare
-fsanitize=pointer-subtract
-fsanitize=leak
-fsanitize=undefined
-fsanitize=float-cast-overflow
-fstack-protector-strong
-fno-omit-frame-pointer
)
set(MVPL_include_dirs "")
foreach(dir IN ITEMS
src
src/frontend
src/frontend/lexer
src/frontend/parser
src/frontend/parser/ast_operations
src/frontend/semantic_analysis
src/backend
src/backend/code_generator
src/backend/interpreter
src/common
# Yeah, this could be ${json_SOURCE_DIR}/single_include,
# but this var seems to be needed exactly here but is not defined here
${CMAKE_CURRENT_BINARY_DIR}/_deps/json-src/single_include
)
get_filename_component(dir ${dir} ABSOLUTE)
list(APPEND MVPL_include_dirs ${dir})
endforeach()
#****************************************************************************#
# Dependencies #
#****************************************************************************#
include(FetchContent)
FetchContent_Declare(
docopt
GIT_REPOSITORY "https://github.com/docopt/docopt.cpp"
GIT_PROGRESS TRUE
GIT_SHALLOW TRUE
GIT_TAG "v0.6.3"
)
FetchContent_MakeAvailable(docopt)
#****************************************************************************#
# Configuration #
#****************************************************************************#
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(benchmarks)
include_directories(${MVPL_include_dirs})
add_executable(MVPL src/main.cpp)
target_link_libraries(MVPL PRIVATE MVPL_lib docopt)
target_compile_options(MVPL PRIVATE ${MVPL_compile_flags})
target_link_options(MVPL PRIVATE ${MVPL_compile_flags})