-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
124 lines (91 loc) · 3.28 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
cmake_minimum_required(VERSION 3.20)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(llvm)
include(poco)
include(fmt)
project(kaleidoscope LANGUAGES CXX)
include_directories(/usr/include/c++/11)
link_directories(/usr/lib32)
link_libraries(stdc++)
add_compile_options(-std=c++2a
-ggdb3
-Wall
-O3)
################ LEXER ################
add_library(lexer
SHARED
${kaleidoscope_SOURCE_DIR}/src/compiler/lexer/lexer.cpp)
set_target_properties(lexer
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY lib)
################ PARSER ################
add_library(parser
SHARED
${kaleidoscope_SOURCE_DIR}/src/compiler/parser/parser.cpp)
target_include_directories(parser
PRIVATE
${kaleidoscope_SOURCE_DIR}/src/compiler/lexer
${kaleidoscope_SOURCE_DIR}/src)
target_link_libraries(parser
PRIVATE
lexer)
set_target_properties(parser
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY lib)
################ CODEGEN ################
add_library(codegen
SHARED
${kaleidoscope_SOURCE_DIR}/src/compiler/codegen/codegen.cpp)
target_include_directories(codegen
PUBLIC
${kaleidoscope_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/toolstack/include)
target_link_directories(codegen
PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/toolstack/lib/)
add_dependencies(codegen
llvm-project-install)
target_link_libraries(codegen
PUBLIC
parser
LLVM)
target_link_options(codegen
PUBLIC
"-Wl,-rpath=${CMAKE_CURRENT_BINARY_DIR}/toolstack/lib")
set_target_properties(codegen
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY lib)
################ DRIVER ################
add_library(driver
SHARED
${kaleidoscope_SOURCE_DIR}/src/compiler/driver/driver.cpp)
target_include_directories(driver
PUBLIC
${kaleidoscope_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/toolstack/include)
target_link_directories(driver
PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/toolstack/lib)
add_dependencies(driver
poco-install
fmt-project-install)
target_link_libraries(driver
PUBLIC
fmt
lexer
parser
codegen
LLVM
lldELF
lldCommon
PocoFoundation
z)
target_link_options(driver
PUBLIC
"-Wl,-rpath=${CMAKE_CURRENT_BINARY_DIR}/toolstack/lib")
set_target_properties(driver
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY lib)
add_subdirectory(test)