This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathCMakeLists.txt
327 lines (315 loc) · 11.3 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
cmake_minimum_required(VERSION 3.14)
project(Seq)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden -pedantic -Wall -Wno-return-type-c-linkage -Wno-gnu-zero-variadic-macro-arguments")
set(CMAKE_CXX_FLAGS_DEBUG "-g -fno-limit-debug-info")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
include_directories(.)
include_directories(compiler)
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
# set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(LLVM REQUIRED)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
include(${CMAKE_SOURCE_DIR}/scripts/deps.cmake)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
if(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/../lib/seq")
set(STATIC_LIBCPP "")
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib/seq")
set(STATIC_LIBCPP "-static-libstdc++")
endif()
add_executable(peg2cpp compiler/util/peg2cpp.cpp compiler/util/peglib.h)
target_link_libraries(peg2cpp Threads::Threads)
add_custom_command(
OUTPUT seq_rules.cpp
COMMAND peg2cpp ${CMAKE_SOURCE_DIR}/compiler/parser/peg/grammar.peg seq_rules.cpp seq
DEPENDS peg2cpp compiler/parser/peg/grammar.peg)
add_custom_command(
OUTPUT omp_rules.cpp
COMMAND peg2cpp ${CMAKE_SOURCE_DIR}/compiler/parser/peg/openmp.peg omp_rules.cpp omp
DEPENDS peg2cpp compiler/parser/peg/openmp.peg)
# Seq runtime library
set(SEQRT_FILES
runtime/lib.h
runtime/lib.cpp
runtime/exc.cpp
runtime/sw/ksw2.h
runtime/sw/ksw2_extd2_sse.cpp
runtime/sw/ksw2_exts2_sse.cpp
runtime/sw/ksw2_extz2_sse.cpp
runtime/sw/ksw2_gg2_sse.cpp
runtime/sw/intersw.h
runtime/sw/intersw.cpp)
add_library(seqrt SHARED ${SEQRT_FILES})
add_dependencies(seqrt bz2 liblzma zlibstatic gc htslib backtrace)
set_source_files_properties(runtime/sw/intersw.cpp PROPERTIES COMPILE_FLAGS -mavx)
target_include_directories(seqrt PRIVATE ${backtrace_SOURCE_DIR} "${gc_SOURCE_DIR}/include" runtime)
target_link_libraries(seqrt PRIVATE omp backtrace ${STATIC_LIBCPP} LLVMSupport)
if(APPLE)
target_link_libraries(seqrt PRIVATE
-Wl,-force_load,$<TARGET_FILE:bz2>
-Wl,-force_load,$<TARGET_FILE:liblzma>
-Wl,-force_load,$<TARGET_FILE:zlibstatic>
-Wl,-force_load,$<TARGET_FILE:gc>
-Wl,-force_load,$<TARGET_FILE:htslib> )
else()
target_link_libraries(seqrt PRIVATE
-Wl,--whole-archive
$<TARGET_FILE:bz2>
$<TARGET_FILE:liblzma>
$<TARGET_FILE:zlibstatic>
$<TARGET_FILE:gc>
$<TARGET_FILE:htslib>
-Wl,--no-whole-archive)
endif()
add_custom_command(TARGET seqrt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:omp> ${CMAKE_BINARY_DIR})
# Seq compiler library
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
set(SEQ_HPPFILES
compiler/dsl/dsl.h
compiler/dsl/plugins.h
compiler/parser/ast.h
compiler/parser/ast/expr.h
compiler/parser/ast/stmt.h
compiler/parser/ast/types.h
compiler/parser/cache.h
compiler/parser/common.h
compiler/parser/ctx.h
compiler/parser/peg/peg.h
compiler/parser/peg/rules.h
compiler/parser/parser.h
compiler/parser/visitors/doc/doc.h
compiler/parser/visitors/format/format.h
compiler/parser/visitors/simplify/simplify.h
compiler/parser/visitors/simplify/simplify_ctx.h
compiler/parser/visitors/translate/translate.h
compiler/parser/visitors/translate/translate_ctx.h
compiler/parser/visitors/typecheck/typecheck.h
compiler/parser/visitors/typecheck/typecheck_ctx.h
compiler/parser/visitors/visitor.h
compiler/seq/pipeline.h
compiler/seq/revcomp.h
compiler/seq/seq.h
compiler/sir/analyze/analysis.h
compiler/sir/analyze/dataflow/cfg.h
compiler/sir/analyze/dataflow/dominator.h
compiler/sir/analyze/dataflow/reaching.h
compiler/sir/analyze/module/global_vars.h
compiler/sir/analyze/module/side_effect.h
compiler/sir/attribute.h
compiler/sir/base.h
compiler/sir/const.h
compiler/sir/dsl/codegen.h
compiler/sir/dsl/nodes.h
compiler/sir/flow.h
compiler/sir/func.h
compiler/sir/instr.h
compiler/sir/llvm/coro/CoroCleanup.h
compiler/sir/llvm/coro/CoroEarly.h
compiler/sir/llvm/coro/CoroElide.h
compiler/sir/llvm/coro/CoroInstr.h
compiler/sir/llvm/coro/CoroInternal.h
compiler/sir/llvm/coro/CoroSplit.h
compiler/sir/llvm/coro/Coroutines.h
compiler/sir/llvm/llvisitor.h
compiler/sir/llvm/llvm.h
compiler/sir/module.h
compiler/sir/sir.h
compiler/sir/transform/cleanup/canonical.h
compiler/sir/transform/cleanup/dead_code.h
compiler/sir/transform/cleanup/global_demote.h
compiler/sir/transform/cleanup/replacer.h
compiler/sir/transform/folding/const_fold.h
compiler/sir/transform/folding/const_prop.h
compiler/sir/transform/folding/folding.h
compiler/sir/transform/folding/rule.h
compiler/sir/transform/lowering/imperative.h
compiler/sir/transform/lowering/pipeline.h
compiler/sir/transform/manager.h
compiler/sir/transform/parallel/openmp.h
compiler/sir/transform/parallel/schedule.h
compiler/sir/transform/pass.h
compiler/sir/transform/pythonic/dict.h
compiler/sir/transform/pythonic/io.h
compiler/sir/transform/pythonic/str.h
compiler/sir/transform/rewrite.h
compiler/sir/types/types.h
compiler/sir/util/cloning.h
compiler/sir/util/context.h
compiler/sir/util/format.h
compiler/sir/util/inlining.h
compiler/sir/util/irtools.h
compiler/sir/util/iterators.h
compiler/sir/util/matching.h
compiler/sir/util/operator.h
compiler/sir/util/outlining.h
compiler/sir/util/packs.h
compiler/sir/util/visitor.h
compiler/sir/value.h
compiler/sir/var.h
compiler/util/common.h
compiler/util/peglib.h
compiler/util/fmt/chrono.h
compiler/util/fmt/color.h
compiler/util/fmt/compile.h
compiler/util/fmt/core.h
compiler/util/fmt/format-inl.h
compiler/util/fmt/format.h
compiler/util/fmt/locale.h
compiler/util/fmt/ostream.h
compiler/util/fmt/posix.h
compiler/util/fmt/printf.h
compiler/util/fmt/ranges.h)
set(SEQ_CPPFILES
compiler/dsl/plugins.cpp
compiler/parser/ast/expr.cpp
compiler/parser/ast/stmt.cpp
compiler/parser/ast/types.cpp
compiler/parser/cache.cpp
compiler/parser/common.cpp
compiler/parser/peg/peg.cpp
compiler/parser/parser.cpp
compiler/parser/visitors/doc/doc.cpp
compiler/parser/visitors/format/format.cpp
compiler/parser/visitors/simplify/simplify.cpp
compiler/parser/visitors/simplify/simplify_ctx.cpp
compiler/parser/visitors/simplify/simplify_expr.cpp
compiler/parser/visitors/simplify/simplify_stmt.cpp
compiler/parser/visitors/translate/translate.cpp
compiler/parser/visitors/translate/translate_ctx.cpp
compiler/parser/visitors/typecheck/typecheck.cpp
compiler/parser/visitors/typecheck/typecheck_ctx.cpp
compiler/parser/visitors/typecheck/typecheck_expr.cpp
compiler/parser/visitors/typecheck/typecheck_infer.cpp
compiler/parser/visitors/typecheck/typecheck_stmt.cpp
compiler/parser/visitors/visitor.cpp
compiler/seq/pipeline.cpp
compiler/seq/revcomp.cpp
compiler/seq/seq.cpp
compiler/sir/attribute.cpp
compiler/sir/analyze/analysis.cpp
compiler/sir/analyze/dataflow/cfg.cpp
compiler/sir/analyze/dataflow/dominator.cpp
compiler/sir/analyze/dataflow/reaching.cpp
compiler/sir/analyze/module/global_vars.cpp
compiler/sir/analyze/module/side_effect.cpp
compiler/sir/base.cpp
compiler/sir/const.cpp
compiler/sir/dsl/nodes.cpp
compiler/sir/flow.cpp
compiler/sir/func.cpp
compiler/sir/instr.cpp
compiler/sir/llvm/coro/CoroCleanup.cpp
compiler/sir/llvm/coro/CoroEarly.cpp
compiler/sir/llvm/coro/CoroElide.cpp
compiler/sir/llvm/coro/CoroFrame.cpp
compiler/sir/llvm/coro/CoroSplit.cpp
compiler/sir/llvm/coro/Coroutines.cpp
compiler/sir/llvm/llvisitor.cpp
compiler/sir/module.cpp
compiler/sir/transform/cleanup/canonical.cpp
compiler/sir/transform/cleanup/dead_code.cpp
compiler/sir/transform/cleanup/global_demote.cpp
compiler/sir/transform/cleanup/replacer.cpp
compiler/sir/transform/folding/const_fold.cpp
compiler/sir/transform/folding/const_prop.cpp
compiler/sir/transform/folding/folding.cpp
compiler/sir/transform/lowering/imperative.cpp
compiler/sir/transform/lowering/pipeline.cpp
compiler/sir/transform/manager.cpp
compiler/sir/transform/parallel/openmp.cpp
compiler/sir/transform/parallel/schedule.cpp
compiler/sir/transform/pass.cpp
compiler/sir/transform/pythonic/dict.cpp
compiler/sir/transform/pythonic/io.cpp
compiler/sir/transform/pythonic/str.cpp
compiler/sir/types/types.cpp
compiler/sir/util/cloning.cpp
compiler/sir/util/format.cpp
compiler/sir/util/inlining.cpp
compiler/sir/util/irtools.cpp
compiler/sir/util/matching.cpp
compiler/sir/util/outlining.cpp
compiler/sir/util/visitor.cpp
compiler/sir/value.cpp
compiler/sir/var.cpp
compiler/util/common.cpp
compiler/util/fmt/format.cpp)
add_library(seq SHARED ${SEQ_HPPFILES})
target_sources(seq PRIVATE ${SEQ_CPPFILES} seq_rules.cpp omp_rules.cpp)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set_source_files_properties(seq_rules.cpp compiler/parser/peg/peg.cpp PROPERTIES COMPILE_FLAGS "-O2")
endif()
llvm_map_components_to_libnames(LLVM_LIBS
AllTargetsAsmParsers
AllTargetsCodeGens
AllTargetsDescs
AllTargetsInfos
AggressiveInstCombine
Analysis
AsmParser
BitWriter
CodeGen
Core
Extensions
IPO
IRReader
InstCombine
Instrumentation
MC
MCJIT
ObjCARCOpts
OrcJIT
Remarks
ScalarOpts
Support
Target
TransformUtils
Vectorize
Passes)
if(APPLE)
target_link_libraries(seq PRIVATE ${LLVM_LIBS} dl seqrt)
else()
target_link_libraries(seq PRIVATE ${STATIC_LIBCPP} ${LLVM_LIBS} dl seqrt)
endif()
# Seq command-line tool
add_executable(seqc runtime/main.cpp)
target_link_libraries(seqc ${STATIC_LIBCPP} seq Threads::Threads)
# Seq test
# Download and unpack googletest at configure time
include(FetchContent)
FetchContent_Declare(googletest
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
set(SEQ_TEST_CPPFILES
test/main.cpp
test/sir/analyze/dominator.cpp
test/sir/analyze/reaching.cpp
test/sir/base.cpp
test/sir/constant.cpp
test/sir/flow.cpp
test/sir/func.cpp
test/sir/instr.cpp
test/sir/module.cpp
test/sir/transform/manager.cpp
test/sir/types/types.cpp
test/sir/util/matching.cpp
test/sir/value.cpp
test/sir/var.cpp
test/types.cpp)
add_executable(seqtest ${SEQ_TEST_CPPFILES})
target_include_directories(seqtest PRIVATE test/sir "${gc_SOURCE_DIR}/include")
target_link_libraries(seqtest seq seqrt gtest_main)
target_compile_definitions(seqtest PRIVATE TEST_DIR="${CMAKE_CURRENT_SOURCE_DIR}/test")
include(GoogleTest)
gtest_discover_tests(seqtest)
enable_testing()