-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
167 lines (146 loc) · 4.09 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
#
# MIT License
#
# Copyright (c) 2022 Michael Rolnik
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
cmake_minimum_required(VERSION 3.16)
project(referee)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/submodules/cmake-scripts")
include(code-coverage)
include(formatting)
add_compile_options(-Wno-multichar)
add_compile_options(-g -ggdb)
add_compile_options(-std=c++20)
add_compile_options(-O0)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(ANTLR4_JAR_LOCATION /opt/homebrew/Cellar/antlr/4.10.1/antlr-4.10.1-complete.jar)
set(LLVM_DIR /opt/homebrew/opt/llvm/lib/cmake/llvm )
else()
set(ANTLR4_JAR_LOCATION /usr/local/lib/antlr-4.10.1-complete.jar)
endif()
enable_testing()
find_package(antlr4-runtime REQUIRED)
find_package(antlr4-generator REQUIRED)
find_package(LLVM REQUIRED CONFIG)
find_package(FMT REQUIRED)
add_code_coverage()
antlr4_generate(
referee_parser
${CMAKE_CURRENT_SOURCE_DIR}/core/referee.g4
BOTH
TRUE
TRUE
"referee"
)
include_directories(
.
core
${ANTLR4_INCLUDE_DIR_referee_parser}
${ANTLR4_INCLUDE_DIR}
${PROJECT_BINARY_DIR}
${ANTLR4_INCLUDE_DIR}
${LLVM_INCLUDE_DIRS}
submodules/rapidcsv/src
)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include_directories(
/opt/homebrew/Cellar/googletest/1.11.0/include
/opt/homebrew/Cellar/antlr4-cpp-runtime/4.10.1/include/
)
link_directories(
/opt/homebrew/Cellar/googletest/1.11.0/lib
/opt/homebrew/Cellar/antlr4-cpp-runtime/4.10.1/lib
)
endif()
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
add_definitions(${LLVM_DEFINITIONS_LIST})
llvm_map_components_to_libnames(llvm_libs support core irreader orcjit aarch64asmparser aarch64codegen aarch64info x86asmparser x86codegen x86desc x86disassembler x86info)
file(GLOB_RECURSE ALL_CODE_FILES
${PROJECT_SOURCE_DIR}/core/*.[ch]pp
${PROJECT_SOURCE_DIR}/core/*.[ch]
${PROJECT_SOURCE_DIR}/rdb/*.[h]pp
${PROJECT_SOURCE_DIR}/rdb/*.[h]
)
clang_format(format ${ALL_CODE_FILES})
message( ${ALL_CODE_FILES})
add_library(
core
core/visitors/compile.cpp
core/visitors/canonic.cpp
core/visitors/negated.cpp
core/visitors/typecalc.cpp
core/visitors/printer.cpp
core/visitors/rewrite.cpp
core/visitors/csvHeaders.cpp
core/antlr2ast.cpp
core/syntax.cpp
core/strings.cpp
core/module.cpp
core/utils.cpp
rdb/database.cpp
referee.cpp
${ANTLR4_SRC_FILES_referee_parser}
)
add_executable(
referee
main.cpp
)
add_dependencies(
referee
antlr4_shared
)
target_link_libraries(
referee PUBLIC
fmt::fmt
core
fmt::fmt
antlr4_shared
${llvm_libs}
)
target_code_coverage(referee)
add_executable(
tests
test/main.cpp
test/strings.cpp
test/canonic.cpp
test/logic.cpp
)
target_link_libraries(
tests PUBLIC
fmt::fmt
core
fmt::fmt
gtest
gtest_main
pthread
antlr4_shared
${llvm_libs}
)
target_code_coverage(tests)
add_test(tests tests)
add_executable(
rdb
rdb/database.cpp
rdb/main.cpp
)
target_link_libraries(
rdb
fmt::fmt)