-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
CMakeLists.txt
147 lines (112 loc) · 3.73 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
############################################################
# The One Programming Language #
# #
# File: CMakeLists.txt #
# _ _ #
# / \ |\ | |_ Max Base #
# \_/ | \| |_ Copyright 2021; One Language Contributors #
# #
############################################################
# Project setup
cmake_minimum_required(VERSION 3.19)
set(CMAKE_C_STANDARD 11)
project(One VERSION 0.1.0)
# Setup Shell Variables
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
# Setup CPack, CTest, and enable testing
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
include(CTest)
enable_testing()
# Setup LLVM
find_package(LLVM)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
include_directories(/usr/include)
link_directories(/usr/lib)
llvm_map_components_to_libnames(core)
add_definitions(
-D_GNU_SOURCE
-D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS
)
# Set builtins source and headers
set(BUILTINS_SOURCE
src/builtins/array.c
src/builtins/error.c
src/builtins/file.c
src/builtins/string.c
)
set(BUILTINS_HEADERS
src/builtins/array.h
src/builtins/error.h
src/builtins/file.h
src/builtins/string.h
)
# Set lexer source and headers
set(LEXER_SOURCE
src/lexer/tokenizer/token.c
src/lexer/tokenizer/tokenizer.c
src/lexer/lexer.c
)
set(LEXER_HEADERS
src/lexer/tokenizer/token.h
src/lexer/tokenizer/tokenizer.h
src/lexer/lexer.h
)
# Set AST source and headers
set(AST_SOURCE
src/ast/ast.c
)
set(AST_HEADERS
src/ast/ast.h
)
# Set parser source and headers
set(PARSER_SOURCE
src/parser/parser_token.c
src/parser/parser.c
)
set(PARSER_HEADERS
src/parser/parser_token.h
src/parser/parser.h
)
# Set Main executables for lexer, ast, and parser
set(LEXER_MAIN
src/lexer/main.c
)
set(AST_MAIN
src/ast/main.c
)
set(PARSER_MAIN
src/parser/main.c
)
# Set Tests
set(TESTS_HEADERS
test/test.h
)
set(LEXER_TEST
test/lexer.test.c
)
set(PARSER_TEST
test/parser.test.c
)
set(ARGUMENT_TEST
test/argument.test.c
)
# Create Executables for lexer, ast, and parser
add_executable(lexer ${LEXER_MAIN} ${LEXER_SOURCE} ${LEXER_HEADERS} ${BUILTINS_SOURCE} ${BUILTINS_HEADERS} ${CFLAGS} ${LIBS})
add_executable(ast ${AST_MAIN} ${AST_SOURCE} ${AST_HEADERS} ${LEXER_SOURCE} ${LEXER_HEADERS} ${BUILTINS_SOURCE} ${BUILTINS_HEADERS} ${PARSER_SOURCE} ${PARSER_HEADERS} ${CFLAGS} ${LIBS})
add_executable(parser ${PARSER_MAIN} ${PARSER_SOURCE} ${PARSER_HEADERS} ${LEXER_SOURCE} ${LEXER_HEADERS} ${AST_SOURCE} ${AST_HEADERS} ${BUILTINS_SOURCE} ${BUILTINS_HEADERS} ${CFLAGS} ${LIBS})
# Create Executables for lexer test
add_executable(lexer_test ${LEXER_TEST} ${TEST_HEADERS} ${PARSER_SOURCE} ${PARSER_HEADERS} ${LEXER_SOURCE} ${LEXER_HEADERS} ${AST_SOURCE} ${AST_HEADERS} ${BUILTINS_SOURCE} ${BUILTINS_HEADERS} ${CFLAGS} ${LIBS})
target_compile_options(lexer_test PUBLIC "-D_ONE_TEST_")
add_test(lexer_test lexer_test)
# Create Executables for parser test
add_executable(parser_test ${PARSER_TEST} ${TEST_HEADERS})
add_test(NAME parser_test WORKING_DIRECTORY ../test COMMAND parser_test)
# Create Executables for argument test
add_executable(argument_test ${ARGUMENT_TEST} ${TEST_HEADERS})
add_test(NAME argument_test WORKING_DIRECTORY ../test COMMAND argument_test)