-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
262 lines (221 loc) · 9.2 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
cmake_minimum_required(VERSION 3.15)
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/third_party)
set(PROJECT_NAME qikkDB)
project(${PROJECT_NAME} LANGUAGES C CXX CUDA)
set(CMAKE_CXX_STANDARD 17)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(GetGitRevisionDescription)
get_git_head_revision(GIT_BRANCH GIT_COMMIT_HASH)
git_describe(GIT_VERSION --tags)
if(GIT_VERSION MATCHES "^R[0-9]+\.[0-9]+$")
set(GIT_BRANCH "")
else(GIT_VERSION MATCHES "^R[0-9]+\.[0-9]+$")
string(REGEX REPLACE "^refs/heads/" " " GIT_BRANCH "${GIT_BRANCH}")
if("${GIT_BRANCH}" STREQUAL "")
set(GIT_BRANCH "detached")
endif("${GIT_BRANCH}" STREQUAL "")
endif(GIT_VERSION MATCHES "^R[0-9]+\.[0-9]+$")
git_local_changes(GIT_IS_DIRTY)
if(GIT_IS_DIRTY STREQUAL "DIRTY")
set(GIT_VERSION ${GIT_VERSION}-dirty)
endif(GIT_IS_DIRTY STREQUAL "DIRTY")
configure_file(
${CMAKE_SOURCE_DIR}/qikkDB/Version.h.in
${CMAKE_BINARY_DIR}/generated/Version.h
)
include_directories(${CMAKE_BINARY_DIR}/generated)
if(WIN32)
add_definitions(-D_WIN32_WINNT=0x601 -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS -D_CRT_SECURE_NO_WARNINGS)
endif(WIN32)
# Find include dirs
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
if(WIN32)
set(prefix "lib")
set(suffix ".lib")
elseif(APPLE)
set(prefix "lib")
set(suffix ".a")
else()
set(prefix "lib")
set(suffix ".a")
endif()
###### Google Protocol Buffers external project ########
set(PROTOBUF_TAR_GZ https://github.com/protocolbuffers/protobuf/archive/v3.10.0.tar.gz)
ExternalProject_Add(
protobuf-external
PREFIX protobuf
URL ${PROTOBUF_TAR_GZ}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/protobuf
CMAKE_CACHE_ARGS
"-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
"-Dprotobuf_BUILD_TESTS:BOOL=OFF"
"-Dprotobuf_BUILD_EXAMPLES:BOOL=OFF"
"-Dprotobuf_WITH_ZLIB:BOOL=OFF"
"-Dprotobuf_BUILD_PROTOC_BINARIES:BOOL=OFF"
"-Dprotobuf_BUILD_SHARED_LIBS:BOOL=OFF"
"-Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=ON"
"-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}"
"-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}"
"-DCMAKE_MAKE_PROGRAM:STRING=${CMAKE_MAKE_PROGRAM}"
# other project specific parameters
SOURCE_SUBDIR cmake
BUILD_ALWAYS 1
STEP_TARGETS build
INSTALL_COMMAND ""
)
EXternalProject_Get_Property(protobuf-external source_dir)
include_directories(${source_dir}/src)
link_directories(${CMAKE_CURRENT_BINARY_DIR}/protobuf)
###### Google Protocol Buffers external project end ########
###### YAML-CPP external project ########
set(YAML_CPP_TAR_GZ https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.6.3.tar.gz)
ExternalProject_Add(
yaml-cpp-external
PREFIX yaml-cpp
URL ${YAML_CPP_TAR_GZ}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/yaml-cpp
CMAKE_CACHE_ARGS
"-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
"-DYAML_MSVC_SHARED_RT:BOOL=OFF"
"-DYAML_CPP_BUILD_TESTS:BOOL=OFF"
# other project specific parameters
BUILD_ALWAYS 1
STEP_TARGETS build
INSTALL_COMMAND ""
)
EXternalProject_Get_Property(yaml-cpp-external source_dir)
include_directories(${source_dir}/include)
link_directories(${CMAKE_CURRENT_BINARY_DIR}/yaml-cpp)
###### YAML-CPP external project end ########
###### JSONCPP external project ########
string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_upper )
set(JSONCPP_TAR_GZ https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz)
set(JSONCPP_CMAKE_CACHE_ARGS
"-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
"-DBUILD_STATIC_LIBS:BOOL=ON"
"-DBUILD_SHARED_LIBS:BOOL=OFF"
"-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:STRING=${CMAKE_CURRENT_BINARY_DIR}/jsoncpp"
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY:STRING=${CMAKE_CURRENT_BINARY_DIR}/jsoncpp"
"-DJSONCPP_WITH_TESTS:BOOL=OFF"
"-DJSONCPP_WITH_POST_BUILD_UNITTEST:BOOL=OFF"
"-DJSONCPP_WITH_PKGCONFIG_SUPPORT:BOOL=OFF"
"-DJSONCPP_WITH_CMAKE_PACKAGE:BOOL=OFF")
set(JSONCPP_CMAKE_ARGS "")
IF(MSVC)
set(JSONCPP_CMAKE_ARGS
"-DCMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_upper}=${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_upper}} /MT$<$<CONFIG:Debug>:d>"
"-DCMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_upper}=${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_upper}} /MT$<$<CONFIG:Debug>:d>"
"-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreaded$<$<CONFIG:Debug>:Debug>")
ENDIF(MSVC)
ExternalProject_Add(
jsoncpp-external
PREFIX jsoncpp
URL ${JSONCPP_TAR_GZ}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/jsoncpp
CMAKE_ARGS
${JSONCPP_CMAKE_ARGS}
# other project specific parameters
CMAKE_CACHE_ARGS
${JSONCPP_CMAKE_CACHE_ARGS}
BUILD_ALWAYS 1
STEP_TARGETS build
INSTALL_COMMAND ""
)
EXternalProject_Get_Property(jsoncpp-external source_dir)
include_directories(${source_dir}/include)
link_directories(${CMAKE_CURRENT_BINARY_DIR}/jsoncpp)
###### JSONCPP external project end ########
###### Antlr4 external project ########
add_definitions(-DANTLR4CPP_STATIC)
set(ANTLR4_WITH_STATIC_CRT ON)
# add external build for antlrcpp
include(ExternalAntlr4Cpp)
# add antrl4cpp artifacts to project environment
include_directories(${ANTLR4_INCLUDE_DIRS})
###### Antlr4 external project ########
###### Google Test external project ########
string( TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_lower )
IF(CMAKE_BUILD_TYPE_lower STREQUAL "debug")
message("DEBUG MODE")
set(GTEST_MAIN_BUILD_PATH third_party/src/googletest-build/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_maind${suffix} )
set(GTEST_BUILD_PATH third_party/src/googletest-build/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtestd${suffix} )
ELSE(CMAKE_BUILD_TYPE_lower STREQUAL "debug")
set(GTEST_MAIN_BUILD_PATH third_party/src/googletest-build/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${suffix} )
set(GTEST_BUILD_PATH third_party/src/googletest-build/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${suffix} )
ENDIF(CMAKE_BUILD_TYPE_lower STREQUAL "debug")
ExternalProject_Add(
googletest
URL https://github.com/google/googletest/archive/release-1.8.1.zip
# TIMEOUT 10
# # Force separate output paths for debug and release builds to allow easy
# # identification of correct lib in subsequent TARGET_LINK_LIBRARIES commands
# CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs
# -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs
# -Dgtest_force_shared_crt=ON
# Disable install step
CMAKE_CACHE_ARGS
"-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
"-DBUILD_GMOCK:BOOL=OFF"
"-DINSTALL_GTEST:BOOL=OFF"
"-Dgtest_force_shared_crt:BOOL=OFF"
"-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}"
"-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}"
"-DCMAKE_MAKE_PROGRAM:STRING=${CMAKE_MAKE_PROGRAM}"
INSTALL_COMMAND ""
# Wrap download, configure and build steps in a script to log output
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
BUILD_BYPRODUCTS ${GTEST_MAIN_BUILD_PATH} ${GTEST_BUILD_PATH}
)
ExternalProject_Get_Property(googletest source_dir)
set(GTEST_INCLUDE_DIR ${source_dir}/googletest/include)
# Library
ExternalProject_Get_Property(googletest binary_dir)
IF(CMAKE_BUILD_TYPE_lower STREQUAL "debug")
message("DEBUG MODE")
set(GTEST_MAIN_LIBRARY_PATH ${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_maind${suffix} )
set(GTEST_MAIN_LIBRARY gtest_maind)
ELSE(CMAKE_BUILD_TYPE_lower STREQUAL "debug")
set(GTEST_MAIN_LIBRARY_PATH ${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${suffix} )
set(GTEST_MAIN_LIBRARY gtest_main)
ENDIF(CMAKE_BUILD_TYPE_lower STREQUAL "debug")
add_library(${GTEST_MAIN_LIBRARY} UNKNOWN IMPORTED)
set_property(TARGET ${GTEST_MAIN_LIBRARY} PROPERTY IMPORTED_LOCATION
${GTEST_MAIN_LIBRARY_PATH} )
add_dependencies(${GTEST_MAIN_LIBRARY} googletest)
IF(CMAKE_BUILD_TYPE_lower STREQUAL "debug")
set(GTEST_LIBRARY_PATH ${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtestd${suffix} )
set(GTEST_LIBRARY gtestd)
ELSE(CMAKE_BUILD_TYPE_lower STREQUAL "debug")
set(GTEST_LIBRARY_PATH ${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${suffix} )
set(GTEST_LIBRARY gtest)
ENDIF(CMAKE_BUILD_TYPE_lower STREQUAL "debug")
add_library(${GTEST_LIBRARY} UNKNOWN IMPORTED)
set_property(TARGET ${GTEST_LIBRARY} PROPERTY IMPORTED_LOCATION
${GTEST_LIBRARY_PATH} )
add_dependencies(${GTEST_LIBRARY} googletest)
###### Google Test external project ########
set(Boost_USE_STATIC_LIBS ON)
IF(MSVC)
set(Boost_USE_STATIC_RUNTIME ON)
ELSE(MSVC)
set(Boost_USE_STATIC_RUNTIME OFF)
ENDIF(MSVC)
find_package(Boost 1.66.0 COMPONENTS log_setup log system filesystem iostreams REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(.)
include_directories(messages)
include_directories(Types)
include_directories(GpuSqlParser)
add_subdirectory(qikkDB)
add_subdirectory(qikkDB_test)
add_custom_target(make-databases-dir ALL COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/databases")
add_custom_target(make-test-databases-dir ALL COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/test_databases")
add_custom_target(copy-default-config ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/configuration
${CMAKE_CURRENT_BINARY_DIR}/configuration)
enable_testing()
add_test(NAME ${PROJECT_NAME}_test COMMAND ${PROJECT_NAME}_test)