-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
227 lines (197 loc) · 6.29 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
cmake_minimum_required(VERSION 3.5)
project(protodb)
set(CMAKE_CXX_STANDARD 17)
set(LIBXML_AVAILABLE false)
set(ENABLE_PERFBENCHMARKING false)
set(USE_DATA_VERSIONING true)
set(USE_HYRISE false)
set(TUPLE_STREAM_REQUIRED true)
### common flags
# TODO add -Wall -Wextra
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -rdynamic -fno-omit-frame-pointer -march=native -Wno-unknown-pragmas")
### set up boost
##################
### boost ########
##################
if(APPLE)
list(APPEND CMAKE_PREFIX_PATH /usr/local/opt/boost/lib/cmake/Boost-1.72.0)
endif(APPLE)
find_package(Boost)
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} )
##################
### llvm #########
##################
if(APPLE)
list(APPEND CMAKE_PREFIX_PATH /usr/local/opt/llvm@7)
find_package(LLVM 7.1 REQUIRED CONFIG)
else(NOT APPLE)
find_package(LLVM 7 REQUIRED CONFIG)
endif(APPLE)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
llvm_map_components_to_libnames(LLVM_LIBS
support
core
irreader
ExecutionEngine
nativecodegen
X86AsmParser
mcjit
Passes
InstCombine
ScalarOpts
)
##################
### vendor #######
##################
include("${CMAKE_SOURCE_DIR}/vendor/googletest.cmake")
include("${CMAKE_SOURCE_DIR}/vendor/gflags.cmake")
if(ENABLE_PERFBENCHMARKING)
include("${CMAKE_SOURCE_DIR}/vendor/perfevent.cmake")
endif(ENABLE_PERFBENCHMARKING)
if(USE_HYRISE)
include("${CMAKE_SOURCE_DIR}/vendor/hyrise.cmake")
endif(USE_HYRISE)
##################
### config #######
##################
include_directories(.
${LLVM_INCLUDE_DIRS}
${GFLAGS_INCLUDE_DIR}
${HYRISE_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/include/tardisdb
)
add_definitions(${LLVM_DEFINITIONS})
##################
### libraries ####
##################
if(NOT USE_HYRISE)
include(tools/sqlParser/local.cmake)
endif(NOT USE_HYRISE)
include(tools/semanticalAnalyser/local.cmake)
include(tools/queryCompiler/local.cmake)
include(tools/queryExecutor/local.cmake)
if(LIBXML_AVAILABLE)
include(tools/wikiParser/local.cmake)
endif(LIBXML_AVAILABLE)
if (DEFINED PISTACHE_INCLUDE)
include_directories("${PISTACHE_INCLUDE}")
endif()
if (DEFINED PISTACHE_LIBRARY_PATH)
link_directories("${PISTACHE_LIBRARY_PATH}")
endif()
##################
### tests ########
##################
include("${CMAKE_SOURCE_DIR}/test/local.cmake")
##################
### tools ########
##################
add_executable(sql sql.cpp)
target_link_libraries(sql readline dblib queryCompiler queryExecutor)
add_executable(server server.cpp)
target_link_libraries(server dblib queryCompiler queryExecutor pistache pthread)
##################
### benchmark ####
##################
add_executable(semanticalBench benchmark/semanticalBench.cpp)
target_link_libraries(semanticalBench dblib queryCompiler queryExecutor gflags pthread)
if(LIBXML_AVAILABLE)
target_compile_definitions(semanticalBench PUBLIC -D LIBXML_AVAILABLE=true)
target_link_libraries(semanticalBench wikiparser)
endif(LIBXML_AVAILABLE)
if(USE_DATA_VERSIONING)
target_compile_definitions(semanticalBench PUBLIC -D USE_DATA_VERSIONING=true)
endif(USE_DATA_VERSIONING)
if(ENABLE_PERFBENCHMARKING)
target_compile_definitions(semanticalBench PUBLIC -D PERF_AVAILABLE=true)
endif(ENABLE_PERFBENCHMARKING)
##################
### DBLIB ########
##################
file(GLOB_RECURSE ALGEBRA_FILES "algebra/*.cpp" "algebra/*.hpp" "algebra/*.tcc")
file(GLOB_RECURSE CODEGEN_FILES "codegen/*.cpp" "codegen/*.hpp" "codegen/*.tcc")
file(GLOB_RECURSE FOUNDATIONS_FILES "foundations/*.cpp" "foundations/*.hpp" "foundations/*.tcc")
file(GLOB_RECURSE NATIVE_FILES "native/*.cpp" "native/*.hpp" "native/*.tcc")
file(GLOB_RECURSE SQL_FILES "sql/*.cpp" "sql/*.hpp" "sql/*.tcc")
file(GLOB_RECURSE QUERIES_FILES "queries/*.cpp" "queries/*.hpp" "queries/*.tcc")
#file(GLOB_RECURSE TESTS_FILES "tests/*.cpp" "tests/*.hpp" "tests/*.tcc")
file(GLOB_RECURSE UTILS_FILES "utils/*.cpp" "utils/*.hpp" "utils/*.tcc")
set(THIRD_PARTY_FILES third_party/hexdump.cpp third_party/hexdump.hpp)
set(DB_LIB_SOURCE_FILES
${ALGEBRA_FILES}
${CODEGEN_FILES}
${FOUNDATIONS_FILES}
${NATIVE_FILES}
${SQL_FILES}
${QUERIES_FILES}
${QUERY_COMPILER_FILES}
${UTILS_FILES}
${THIRD_PARTY_FILES}
)
set(TEST_SOURCE_FILES
tests/types_test.cpp
tests/groupby_test.cpp
tests/tests.cpp
tests/tests.hpp
)
### default schema file
get_filename_component(SCHEMA_FILE schemas/schema.sql ABSOLUTE)
### database loader generation
set(LOADER_FILE loader_generated.cpp)
add_custom_command(
OUTPUT ${LOADER_FILE}
COMMAND schema_parser ${SCHEMA_FILE} > ${LOADER_FILE}
DEPENDS ${SCHEMA_FILE} schema_parser
COMMENT "Generating database loader"
VERBATIM
)
add_custom_target(
GenerateLoader ALL
DEPENDS ${LOADER_FILE}
)
### all generated files
set(GENERATED_SOURCE_FILES ${LOADER_FILE})
### main library
add_library(dblib ${DB_LIB_SOURCE_FILES})
if(TUPLE_STREAM_REQUIRED)
target_compile_definitions(dblib PUBLIC -D TUPLE_STREAM_REQUIRED=true)
endif(TUPLE_STREAM_REQUIRED)
if(USE_DATA_VERSIONING)
target_compile_definitions(dblib PUBLIC -D USE_DATA_VERSIONING=true)
endif(USE_DATA_VERSIONING)
target_link_libraries(dblib semanticalAnalyser LLVM dl)
if(USE_HYRISE)
target_compile_definitions(dblib PUBLIC -D USE_HYRISE=true)
target_link_libraries(dblib hyriselib)
else(NOT USE_HYRISE)
target_compile_definitions(dblib PUBLIC -D USE_HYRISE=false)
target_link_libraries(dblib sqlparser)
endif(USE_HYRISE)
### main application
add_executable(protodb main.cpp ${GENERATED_SOURCE_FILES} ${TEST_SOURCE_FILES})
target_link_libraries(protodb dblib queryCompiler queryExecutor)
### set up dependencies
add_dependencies(GenerateLoader schema_parser)
add_dependencies(protodb GenerateLoader)
### sub projects
add_subdirectory(schema_parser)
### benchmarks
set(RD_BENCH_SOURCE_FILES
benchmark/random.cpp
)
add_executable(rd_bench ${RD_BENCH_SOURCE_FILES})
target_link_libraries(rd_bench dblib)
##################
### install ######
##################
MACRO(INSTALL_HEADERS_WITH_DIRECTORY HEADER_LIST)
FOREACH(HEADER ${${HEADER_LIST}})
get_filename_component(DIR ${HEADER} DIRECTORY)
install(FILES ${HEADER} DESTINATION include/${DIR})
ENDFOREACH(HEADER)
ENDMACRO(INSTALL_HEADERS_WITH_DIRECTORY)
file(GLOB_RECURSE HS RELATIVE ${CMAKE_SOURCE_DIR} "*.hpp" "*.tcc")
INSTALL_HEADERS_WITH_DIRECTORY(HS)
install(TARGETS dblib DESTINATION lib)
install(TARGETS sql protodb rd_bench DESTINATION bin)