-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCMakeLists.txt
217 lines (198 loc) · 7.18 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
cmake_minimum_required(VERSION 3.5.0)
project(YASL)
OPTION(DEBUG "Debug Asserts On" OFF)
OPTION(SECURE_SCRATCH "memset scratch to 0 after use" OFF)
if(cpp)
message(STATUS "COMPILING AS C++")
file(GLOB_RECURSE CFILES "${CMAKE_SOURCE_DIR}/*.c")
SET_SOURCE_FILES_PROPERTIES(${CFILES} PROPERTIES LANGUAGE CXX )
endif()
if(DEBUG)
ADD_DEFINITIONS(-DYASL_DEBUG)
endif()
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
# 4244 is lossy coercions:
# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-levels-3-and-4-c4244
# 4003 is empty macro parameters:
# https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4003?view=msvc-170
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set(CMAKE_C_FLAGS "/WX /W3 /wd4244 /wd4003")
endif()
if (NOT "${CMAKE_C_COMPILER_ID}" MATCHES ".*MSVC.*")
set(CMAKE_C_FLAGS "-Wall -Wextra -Werror=vla -Wno-logical-op-parentheses -Wno-parentheses -Werror")
endif()
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES ".*MSVC.*")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-function -Wno-unused-variable -Wno-vla -Wno-deprecated -Wno-logical-op-parentheses -Wno-parentheses -Wno-missing-field-initializers -Werror")
endif()
if (CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-pedantic-ms-format")
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pedantic-ms-format")
endif()
set(CMAKE_VERBOSE_MAKEFILE OFF)
include_directories(.)
include_directories(src)
include_directories(src/common)
include_directories(src/compiler)
include_directories(src/data-structures)
include_directories(src/interpreter)
include_directories(src/util)
include_directories(src/std)
include_directories(test)
add_executable(yasl
src/common/opcode.h
src/yasl.c
src/yasl_aux.c
src/main.c
src/compiler/ast.c
src/data-structures/YASL_ByteBuffer.c
src/data-structures/YASL_Buffer.c
src/data-structures/YASL_Table.c
src/compiler/compiler.c
src/compiler/env.c
src/compiler/lexer.c
src/compiler/lexinput.c
src/compiler/middleend.c
src/compiler/parser.c
src/interpreter/upvalue.c
src/interpreter/closure.c
src/interpreter/bool_methods.c
src/interpreter/builtins.c
src/interpreter/float_methods.c
src/util/yasl_float.c
src/interpreter/int_methods.c
src/data-structures/YASL_List.c
src/interpreter/list_methods.c
src/interpreter/table_methods.c
src/interpreter/VM.c
src/interpreter/GC.c
src/interpreter/YASL_Object.c
src/interpreter/refcount.c
src/interpreter/str_methods.c
src/data-structures/LString.c
src/data-structures/YASL_String.c
src/data-structures/YASL_StringSet.c
src/interpreter/userdata.c
src/interpreter/undef_methods.c
src/std/yasl-std-io.c
src/std/yasl-std-math.c
src/std/yasl-std-require.c
src/std/yasl-std-error.c
src/data-structures/YASL_Set.c
src/std/yasl-std-collections.c
src/std/yasl-std-mt.c
src/std/yasl-std-os.c
src/std/yasl-std-try.c
src/util/hash_function.c
src/util/IO.c
src/util/prime.c
src/util/varint.c
src/util/yapp.h
src/yasl_conf.h
src/yasl_error.h
src/interpreter/yasl_types.h
src/yasl_plat.h)
add_library(yaslapi
src/common/opcode.h
src/yasl.c
src/yasl_aux.c
src/compiler/ast.c
src/data-structures/YASL_ByteBuffer.c
src/data-structures/YASL_Buffer.c
src/compiler/compiler.c
src/compiler/env.c
src/compiler/lexer.c
src/compiler/lexinput.c
src/compiler/parser.c
src/compiler/middleend.c
src/util/hash_function.c
src/data-structures/YASL_Table.c
src/interpreter/bool_methods.c
src/interpreter/builtins.c
src/interpreter/float_methods.c
src/interpreter/upvalue.c
src/interpreter/closure.c
src/util/yasl_float.c
src/interpreter/int_methods.c
src/data-structures/YASL_List.c
src/data-structures/LString.c
src/data-structures/YASL_StringSet.c
src/interpreter/list_methods.c
src/interpreter/table_methods.c
src/interpreter/VM.c
src/interpreter/GC.c
src/interpreter/YASL_Object.c
src/interpreter/refcount.c
src/interpreter/str_methods.c
src/data-structures/YASL_String.c
src/interpreter/userdata.c
src/interpreter/undef_methods.c
src/util/prime.c
src/util/IO.c
src/util/varint.c
src/std/yasl-std-collections.c
src/std/yasl-std-error.c
src/std/yasl-std-io.c
src/std/yasl-std-math.c
src/std/yasl-std-require.c
src/data-structures/YASL_Set.c
src/std/yasl-std-mt.c
src/std/yasl-std-os.c
src/std/yasl-std-try.c)
set_property(TARGET yaslapi PROPERTY POSITION_INDEPENDENT_CODE ON)
add_executable(tests
test/integration_tests.c
test/yats.c
test/yasl_test.c
test/unit_tests/test_api/apitest.c
test/unit_tests/test_api/pushtest.c
test/unit_tests/test_api/poptest.c
test/unit_tests/test_lexer/lexertest.c
test/unit_tests/test_env/envtest.c
test/unit_tests/test_compiler/compilertest.c
test/unit_tests/test_compiler/binoptest.c
test/unit_tests/test_compiler/unoptest.c
test/unit_tests/test_compiler/literaltest.c
test/unit_tests/test_compiler/matchtest.c
test/unit_tests/test_compiler/iftest.c
test/unit_tests/test_compiler/whiletest.c
test/unit_tests/test_compiler/fortest.c
test/unit_tests/test_compiler/foreachtest.c
test/unit_tests/test_compiler/foldingtest.c
test/unit_tests/test_compiler/functiontest.c
test/unit_tests/test_compiler/comprehensiontest.c
test/unit_tests/test_compiler/syntaxerrortest.c
test/unit_tests/test_compiler/closuretest.c
test/unit_tests/test_collections/collectiontest.c
test/unit_tests/test_collections/settest.c
test/unit_tests/test_methods/methodtest.c
test/unit_tests/test_methods/listtest.c
test/unit_tests/test_methods/strtest.c
test/unit_tests/test_vm/vmtest.c
test/unit_tests/test_gc/gctest.c
test/unit_tests/test_util/utiltest.c
test/unit_tests/test_api/fntest.c
test/unit_tests/test_api/deltest.c
test/unit_tests/test_api/tablenexttest.c
test/unit_tests/test_api/listitertest.c)
add_library(test_module SHARED
test/test_module.c
)
set_property(TARGET test_module PROPERTY POSITION_INDEPENDENT_CODE ON)
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES ".*MSVC.*")
target_link_libraries(yasl m)
target_link_libraries(yaslapi m)
target_link_libraries(tests m)
endif()
target_link_libraries(tests yaslapi)
target_link_libraries(test_module yaslapi)
if (NOT WIN32)
target_link_libraries(yasl dl)
target_link_libraries(yaslapi dl)
target_link_libraries(tests dl)
target_link_libraries(test_module dl)
endif()