-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
92 lines (70 loc) · 2.53 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
cmake_minimum_required(VERSION 3.19.2)
project(clox)
include(CTest)
set(CMAKE_CXX_STANDARD 20)
find_package(Python COMPONENTS Interpreter)
if (!Python_FOUND)
message(ERROR "A python interpreter with higher version than 3.9.0 is required")
else ()
message(STATUS "Use python executable ${Python_EXECUTABLE}")
endif ()
add_executable(clox main.cpp)
add_dependencies(clox parser_classes_inc)
add_subdirectory(libs)
# Enable unit testing
enable_testing()
add_subdirectory(test)
add_subdirectory(base)
add_subdirectory(driver)
add_subdirectory(logger)
add_subdirectory(scanner)
add_subdirectory(parser)
add_subdirectory(object)
add_subdirectory(native)
add_subdirectory(helper)
add_subdirectory(interpreter)
add_subdirectory(resolver)
add_subdirectory(tools)
target_link_libraries(clox
PUBLIC GSL
PUBLIC argparse
PUBLIC magic_enum)
if (${ENABLE_ASAN})
message(STATUS "Use address sanitizer.")
target_link_libraries(clox
PRIVATE -fsanitize=address)
target_link_options(clox
PRIVATE -fsanitize=address)
target_compile_options(clox
PRIVATE -fsanitize=address)
set(addressSanitizerEnabled true)
else ()
message(STATUS "Not use address sanitizer.")
endif ()
if (ENABLE_DEBUG_STRESS_GC)
target_compile_definitions(clox
PRIVATE -DDEBUG_STRESS_GC=1)
target_compile_definitions(clox_test
PRIVATE -DDEBUG_STRESS_GC=1)
else ()
target_compile_definitions(clox
PRIVATE -DDEBUG_STRESS_GC=0)
target_compile_definitions(clox_test
PRIVATE -DDEBUG_STRESS_GC=1)
endif ()
if (ENABLE_DEBUG_LOGGING_GC)
target_compile_definitions(clox
PRIVATE -DDEBUG_LOGGING_GC=1)
target_compile_definitions(clox_test
PRIVATE -DDEBUG_LOGGING_GC=1)
else ()
target_compile_definitions(clox
PRIVATE -DDEBUG_LOGGING_GC=0)
target_compile_definitions(clox_test
PRIVATE -DDEBUG_LOGGING_GC=1)
endif ()
add_custom_target(parser_classes_inc
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/parser/generator/parser_gen.py -c ${CMAKE_CURRENT_SOURCE_DIR}/parser/config/classes.json -H ${CMAKE_CURRENT_SOURCE_DIR}/parser/config/classes.head -t ${CMAKE_CURRENT_SOURCE_DIR}/parser/config/classes.tail -p ${CMAKE_CURRENT_SOURCE_DIR}/parser/include/parser/gen/parser_classes.inc -s ${CMAKE_CURRENT_SOURCE_DIR}/parser/include/parser/gen/parser_base.inc
BYPRODUCTS {CMAKE_CURRENT_SOURCE_DIR}/parser/include/parser_classes.inc
COMMENT "Generating parser expression classes"
)