-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
120 lines (93 loc) · 2.74 KB
/
Copy pathCMakeLists.txt
File metadata and controls
120 lines (93 loc) · 2.74 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
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
116
117
118
119
120
cmake_minimum_required(VERSION 3.20)
project( tails
VERSION 0.1.0
DESCRIPTION "Minimal Forth-like language"
LANGUAGES CXX C
)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
#### CONFIG
if (NOT(CMAKE_BUILD_TYPE STREQUAL "Debug"))
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) # Enable link-time optimization
endif()
if (MSVC)
# MSVC:
add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0A00 -DNOMINMAX)
else()
# Clang & GCC:
add_compile_options(
-Werror
-Wall
-Wpedantic
-Wno-gnu-case-range
-Wno-vla-extension
-Wno-unknown-pragmas
-Wno-unknown-warning-option
)
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# GCC-specific:
add_compile_options(
-Wno-psabi # suppress annoying GCC ABI warning
-Wno-sign-compare # apparently comes with `pedantic` in GCC
-D_FORTIFY_SOURCE=2 # static+dynamic buffer-overflow checks
)
else()
# Clang-specific:
add_compile_options(
-Wno-nullability-extension
-Wno-gnu-zero-variadic-macro-arguments
-Wno-gnu-statement-expression-from-macro-expansion
-Wno-ambiguous-reversed-operator
)
endif()
endif()
add_compile_options(
$<$<CONFIG:Debug>:-fsanitize=address>
$<$<CONFIG:Debug>:-fsanitize=undefined>
$<$<CONFIG:Release>:-Ofast> # This improves speed, at least w/Clang 16
)
add_link_options(
$<$<CONFIG:Debug>:-fsanitize=address>
)
add_library( libtails STATIC
src/compiler/compiler.cc
src/compiler/parser.cc
src/compiler/vocabulary.cc
src/core/core_words.cc
src/values/gc.cc
src/values/value.cc
src/more_words.cc
)
target_include_directories( libtails PUBLIC
src/
src/compiler/
src/core/
src/values/
)
# These flags _should_ speed up the interpreter by removing extra stack manipulation instructions,
# but as of Jan 2025 (M1 MacBook Pro, AppleClang 16) they seem to make no difference:
#target_compile_options(libtails PRIVATE
# $<$<CONFIG:Release>:-fomit-frame-pointer>
# $<$<CONFIG:Release>:-fno-stack-protector>
#)
#### TESTS
add_executable( tails_tests
src/test.cc
)
target_link_libraries( tails_tests
libtails
)
#### CLI
add_executable( tails
src/repl.cc
vendor/linenoise/linenoise.c
vendor/linenoise/utf8.c
)
target_include_directories( tails PRIVATE
vendor/linenoise/
)
target_link_libraries( tails
libtails
)