-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
426 lines (369 loc) · 15.4 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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
cmake_minimum_required(VERSION 3.14.1)
project(CantianDB)
include(
"${PROJECT_SOURCE_DIR}/build/cmake_include/CMakeListsInclude.txt"
)
include_directories(
"${PROJECT_SOURCE_DIR}/build/include"
"${PROJECT_SOURCE_DIR}/open_source/libaio/include"
"${PROJECT_SOURCE_DIR}/open_source/lz4/include"
"${PROJECT_SOURCE_DIR}/open_source/odbc/include"
"${PROJECT_SOURCE_DIR}/open_source/openssl/include/openssl"
"${PROJECT_SOURCE_DIR}/open_source/openssl/include"
"${PROJECT_SOURCE_DIR}/open_source/pcre/include"
"${PROJECT_SOURCE_DIR}/open_source/zlib/include"
"${PROJECT_SOURCE_DIR}/open_source/Zstandard/include"
"${PROJECT_SOURCE_DIR}/platform/huawei_security/include"
"${PROJECT_SOURCE_DIR}/library/kmc"
"${PROJECT_SOURCE_DIR}/build_dependence/unixODBC/include"
"${PROJECT_SOURCE_DIR}/build_dependence/libaio/include"
"${PROJECT_SOURCE_DIR}/pkg/src/common/variant"
"${PROJECT_SOURCE_DIR}/pkg/src/common"
"${PROJECT_SOURCE_DIR}/pkg/src/driver"
"${PROJECT_SOURCE_DIR}/pkg/src/driver/ctconn"
"${PROJECT_SOURCE_DIR}/pkg/src/protocol"
"${PROJECT_SOURCE_DIR}/pkg/src/server"
"${PROJECT_SOURCE_DIR}/pkg/src/server/params"
"${PROJECT_SOURCE_DIR}/pkg/src/shard"
"${PROJECT_SOURCE_DIR}/pkg/src/shard/rebalance"
"${PROJECT_SOURCE_DIR}/pkg/src/shard/ddl"
"${PROJECT_SOURCE_DIR}/pkg/src/shard/dml"
"${PROJECT_SOURCE_DIR}/pkg/src/shard/route"
"${PROJECT_SOURCE_DIR}/pkg/src/shard/adapter"
"${PROJECT_SOURCE_DIR}/pkg/src/shard/dblink"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/catalog"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/executor"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/json"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/node"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/function"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/optimizer"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/parallel"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/parser"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/parser_ddl"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/plan"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/pl"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/pl/include"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/pl/clang"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/pl/debug"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/pl/meta"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/pl/persist"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/pl/type"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/pl/ast"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/pl/parser"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/pl/common"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/pl/executor"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/verifier"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/backup"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/buffer"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/catalog"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/common"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/daemon"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/flashback"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/include"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/index"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/lob"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/persist"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/replication"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/sequence"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/statistics"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/table"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/tablespace"
"${PROJECT_SOURCE_DIR}/pkg/src/kernel/xact"
"${PROJECT_SOURCE_DIR}/pkg/src/utils"
"${PROJECT_SOURCE_DIR}/pkg/src/utils/gspe"
"${PROJECT_SOURCE_DIR}/pkg/src/utils/ctsql"
"${PROJECT_SOURCE_DIR}/pkg/src/utils/ctbackup"
"${PROJECT_SOURCE_DIR}/pkg/src/ctbox"
"${PROJECT_SOURCE_DIR}/pkg/src/ctrst"
"${PROJECT_SOURCE_DIR}/pkg/src/gbp"
"${PROJECT_SOURCE_DIR}/pkg/src/extproc"
"${PROJECT_SOURCE_DIR}/pkg/src/ctsql/pl/include"
"${PROJECT_SOURCE_DIR}/pkg/src/mec"
"${PROJECT_SOURCE_DIR}/pkg/src/ctc"
"${PROJECT_SOURCE_DIR}/library/xnet/include"
"${PROJECT_SOURCE_DIR}/library/xnet/include/vos_win/vos"
"${PROJECT_SOURCE_DIR}/library/xnet/include/infrastructure"
)
if (UNIX)
execute_process(
COMMAND uname -p
OUTPUT_VARIABLE OS_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(${CMAKE_BUILD_TYPE})
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug"
OR ${CMAKE_BUILD_TYPE} STREQUAL "")
message(STATUS "CMAKE_BUILD_TYPE is Debug")
set(CMAKE_BUILD_TYPE Debug)
add_compile_definitions(_DEBUG)
elseif (${CMAKE_BUILD_TYPE} STREQUAL "Release")
message(STATUS "CMAKE_BUILD_TYPE is Release")
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
else ()
message(STATUS "unknown CMAKE_BUILD_TYPE = " ${CMAKE_BUILD_TYPE})
endif ()
# Use "-fPIC" / "-fPIE" for all targets by default, including static libs
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# CMake doesn't add "-pie" by default for executables
add_link_options(-pie)
execute_process(
COMMAND uname -p
OUTPUT_VARIABLE OS_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(CMAKE_SYSTEM_PROCESSOR ${OS_ARCH})
if (OS_ARCH STREQUAL "aarch64")
message(STATUS "aarch64 CPU")
option(USE_H1620 OFF)
if (USE_H1620)
add_compile_options(-march=armv8-a+crc+lse)
message(STATUS "Toolchain: Build aarch64 USE_H1620")
else ()
add_compile_options(-march=armv8-a+crc)
endif (USE_H1620)
add_compile_options(-mtune=cortex-a72 -fsigned-char -g -ggdb3 -march=armv8-a+crc -funwind-tables)
else ()
message(STATUS "x86_64 CPU")
add_compile_options(-mtune=nocona -fsigned-char -msse4.2 )
endif ()
else ()
set(CMAKE_BUILD_TYPE Debug)
add_compile_definitions(_DEBUG)
endif ()
option(USE32BIT OFF)
if (USE32BIT)
add_compile_options(-m32)
set(CLI_BIT "32")
message(STATUS "Toolchain: Build in 32 bits")
else ()
message(STATUS "Toolchain: Build in 64 bits")
endif (USE32BIT)
if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message("++ 64 bit architecture")
set(ARCHBIT "64")
else ()
message("++ 32 bit architecture")
set(ARCHBIT "32")
add_compile_options(-m32)
endif ()
## BUILD OPT
option(USE_CBOTEST OFF)
if (USE_CBOTEST)
add_compile_definitions(TEST_CBO)
message(STATUS "Toolchain: Build use -DTEST_CBO")
endif (USE_CBOTEST)
option(USE_PROTECT_BUF OFF)
if (USE_PROTECT_BUF)
add_compile_definitions(__PROTECT_BUF__)
message(STATUS "Toolchain: Build use -D__PROTECT_BUF__")
endif (USE_PROTECT_BUF)
option(USE_PROTECT_VM OFF)
if (USE_PROTECT_VM)
add_compile_definitions(__PROTECT_VM__)
message(STATUS "Toolchain: Build use -D__PROTECT_VM__")
endif (USE_PROTECT_VM)
option(USE_CANTIAND_CN OFF)
if (USE_CANTIAND_CN)
add_compile_definitions(__CANTIAND_CN__)
message(STATUS "Toolchain: Build use -D__CANTIAND_CN__")
endif (USE_CANTIAND_CN)
option(USE_TEST_MEM OFF)
if (USE_TEST_MEM)
add_compile_definitions(TEST_MEM)
message(STATUS "Toolchain: Build use -DTEST_MEM")
endif (USE_TEST_MEM)
option(CMS_UT_TEST OFF)
if (CMS_UT_TEST)
add_compile_definitions(CMS_UT_TEST)
message(STATUS "Toolchain: Build use -DCMS_UT_TEST")
endif (CMS_UT_TEST)
option(USE_CRC OFF)
if (USE_CRC)
add_compile_definitions(_DEBUG)
add_compile_definitions(DB_CRC_CHECK)
message(STATUS "Toolchain: Build use -DDB_DEBUG_VERSION -DDB_CRC_CHECK")
endif (USE_CRC)
option(USE_LCOV OFF)
if (USE_LCOV)
add_compile_options(-fprofile-arcs -ftest-coverage)
add_link_options(-fprofile-arcs -ftest-coverage)
add_compile_definitions(_CMS_LCOV_TEST_)
add_compile_definitions(_CANTIAN_LCOV_TEST_)
message(STATUS "Toolchain: Build use -DBUILD_LCOV")
endif (USE_LCOV)
option(USE_LLT OFF)
if (USE_LLT)
add_compile_definitions(_DEBUG)
message(STATUS "Toolchain: Build use -DDB_DEBUG_VERSION ")
endif (USE_LLT)
option(USE_ASAN OFF)
if (USE_ASAN)
add_compile_options(-fsanitize=address -fsanitize-recover=address -fsanitize=undefined -fsanitize-recover=undefined -ggdb -fno-omit-frame-pointer -fno-optimize-sibling-calls)
add_link_options(-fsanitize=address -fsanitize-recover=address -fsanitize=undefined -fsanitize-recover=undefined -ggdb -fno-omit-frame-pointer -fno-optimize-sibling-calls)
message(STATUS "Toolchain: Build with ASAN TEST Configure")
endif (USE_ASAN)
option(USE_TSAN OFF)
if (USE_TSAN)
add_compile_options(-fsanitize=thread -ggdb -fno-omit-frame-pointer)
add_link_options(-fsanitize=thread -ggdb -fno-omit-frame-pointer)
message(STATUS "Toolchain: Build with TSAN TEST Configure")
endif (USE_TSAN)
option(USE_STD_PYZENITH OFF)
if (USE_STD_PYZENITH)
add_compile_definitions(STD_PYZENITH)
message(STATUS "Toolchain: Build use -DSTD_PYZENITH")
endif (USE_STD_PYZENITH)
option(USE_OSS_BUILD OFF)
if (USE_OSS_BUILD)
add_compile_definitions(OSS_BUILD)
message(STATUS "Toolchain: Build use -DOSS_BUILD")
endif (USE_OSS_BUILD)
option(CANTIAN_READ_WRITE OFF)
if (CANTIAN_READ_WRITE)
add_compile_definitions(CANTIAN_READ_WRITE)
message(STATUS "Toolchain: Build with CANTIAN_READ_WRITE")
endif (CANTIAN_READ_WRITE)
if (UNIX)
set_property(TARGET PROPERTY C_STANDARD 99)
add_compile_options(-fPIC -Wall -MMD -fno-strict-aliasing -fsigned-char -fms-extensions)
add_compile_definitions(_GNU_SOURCE _LARGEFILE64_SOURCE KNL_PREFIX _REENTRANT)
add_compile_options(-fvisibility=default -fstack-protector-strong --param ssp-buffer-size=4)
add_link_options(-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now)
set(CMAKE_SKIP_RPATH TRUE)
set(JAVA_INCLUDE_DIR $ENV{JAVA_HOME})
if (NOT PYTHON_INCLUDE_DIR)
if (NOT DEFINED ENV{PYTHON_INCLUDE_DIR})
# environment variable PYTHON_INCLUDE_DIR not found
find_package(PythonLibs REQUIRED)
else ()
set(PYTHON_INCLUDE_DIR $ENV{PYTHON_INCLUDE_DIR})
endif ()
endif ()
include_directories(${PYTHON_INCLUDE_DIR})
endif ()
set(CANTIANDB_LIBRARY "${PROJECT_SOURCE_DIR}/library")
set(CANTIANDB_SRC "${PROJECT_SOURCE_DIR}/pkg/src")
set(OPENSSL_LIB_PATH "${CANTIANDB_LIBRARY}/openssl/lib")
set(SECUREC_LIB_PATH "${CANTIANDB_LIBRARY}/huawei_security/lib")
set(PCRE_LIB_PATH "${CANTIANDB_LIBRARY}/pcre/lib")
set(Z_LIB_PATH "${CANTIANDB_LIBRARY}/zlib/lib")
set(ODBC_LIB_PATH "${CANTIANDB_LIBRARY}/odbc/lib")
set(LZ4_LIB_PATH "${CANTIANDB_LIBRARY}/lz4/lib")
set(ZSTD_LIB_PATH "${CANTIANDB_LIBRARY}/Zstandard/lib")
set(KMC_LIB_PATH "${CANTIANDB_LIBRARY}/kmc/lib")
set(VPP_LIB_PATH "${SECUREC_LIB_PATH}")
set(ZEN_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/output")
set(CANTIANDB_LIB "${ZEN_OUTPUT_PATH}/lib")
set(CANTIANDB_BIN "${ZEN_OUTPUT_PATH}/bin")
option(USE_FUZZASAN OFF)
if (USE_FUZZASAN)
add_compile_options(-fsanitize=address -fsanitize=undefined -fsanitize-coverage=trace-pc,trace-cmp -fno-omit-frame-pointer)
add_link_options(-fsanitize=address -fsanitize=undefined -fsanitize-coverage=trace-pc,trace-cmp -fno-omit-frame-pointer)
message(STATUS "Toolchain: Build with USE_FUZZASAN TEST Configure")
add_compile_definitions(_CANTIAN_FUZZ_TEST_)
endif (USE_FUZZASAN)
if (NOT COMMIT_ID)
execute_process(
COMMAND bash -c "cat ${PROJECT_SOURCE_DIR}/build/conf/git_message.in | grep git_id | awk -F'=' '{print $2}'"
OUTPUT_VARIABLE COMMIT_ID
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif ()
message(STATUS ${COMMIT_ID})
execute_process(
COMMAND bash -c "cat ${PROJECT_SOURCE_DIR}/build/conf/git_message.in | grep gitVersion | awk -F'=' '{print $2}'"
OUTPUT_VARIABLE WHOLE_COMMIT_ID
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS ${WHOLE_COMMIT_ID})
execute_process(
COMMAND bash -c "cat ${PROJECT_SOURCE_DIR}/build/conf/git_message.in | grep driver_commit_id | awk -F'=' '{print $2}'"
OUTPUT_VARIABLE DRIVER_COMMIT_ID
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS ${DRIVER_COMMIT_ID})
execute_process(
COMMAND bash -c "cat ${PROJECT_SOURCE_DIR}/build/conf/git_message.in | grep ctsql_commit_id | awk -F'=' '{print $2}'"
OUTPUT_VARIABLE CTSQL_COMMIT_ID
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS ${CTSQL_COMMIT_ID})
if (UNIX)
message("UNIX Release check")
## OS NAME related, consider to abandon
if (EXISTS "/etc/redhat-release")
execute_process(
COMMAND bash -c "cat /etc/redhat-release | grep '2.0 (SP3)'"
OUTPUT_VARIABLE Euler_SP3
)
execute_process(
COMMAND bash -c "cat /etc/redhat-release | grep '2.0 (SP5)'"
OUTPUT_VARIABLE Euler_SP5
)
execute_process(
COMMAND bash -c "cat /etc/redhat-release | grep '2.0 (SP8)'"
OUTPUT_VARIABLE Euler_SP8
)
execute_process(
COMMAND bash -c "cat /etc/redhat-release | grep 'Red Hat'"
OUTPUT_VARIABLE RED_HAT_OS
)
if (NOT RED_HAT_OS STREQUAL "")
message("REDHAT Release")
add_compile_definitions(RED_HAT)
elseif ((NOT Euler_SP3 STREQUAL "") OR (NOT Euler_SP5 STREQUAL ""))
message("EULER20SP3(SP5) Release")
elseif (NOT Euler_SP8 STREQUAL "")
message("EULER20SP8 Release")
endif ()
elseif (EXISTS "/etc/centos-release")
message("CentOS Release")
elseif (EXISTS "/etc/SuSE-release")
message("SUSE Release")
elseif (EXISTS "/etc/neokylin-release")
add_compile_definitions(RED_HAT)
message("KYLIN Release")
elseif (EXISTS "/etc/openEuler-release")
message("OpenEuler Release")
endif ()
## unzip 3rdparty lib
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar -xvf ${PCRE_LIB_PATH}/libpcre.tar WORKING_DIRECTORY ${PCRE_LIB_PATH}/
)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar -xvf ${Z_LIB_PATH}/libz.tar WORKING_DIRECTORY ${Z_LIB_PATH}/
)
if (NOT USE_OSS_BUILD)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar -xvf ${ODBC_LIB_PATH}/libodbc.tar WORKING_DIRECTORY ${ODBC_LIB_PATH}/
)
endif ()
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar -xvf ${ZSTD_LIB_PATH}/libzstd.tar WORKING_DIRECTORY ${ZSTD_LIB_PATH}/
)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar -xvf ${LZ4_LIB_PATH}/liblz4.tar WORKING_DIRECTORY ${LZ4_LIB_PATH}/
)
endif (UNIX)
set(vpp_libsecurec "libsecurec.a")
set(vpp_libipsi_crypto "libcrypto.a")
set(vpp_libipsi_ssl "libssl.a")
set(hw_kmc_lib "")
set(hw_sdp_lib "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g -ldl -pthread")
add_compile_options(-fno-common)
add_compile_options(-Wtrampolines)
add_compile_options(-Wno-address)
add_compile_options(-freg-struct-return)
add_compile_options(-pipe)
add_link_options(-Wl,-Bsymbolic)
if (UNIX)
add_link_options(-rdynamic)
endif()
link_directories(${CANTIANDB_LIB} "${CANTIANDB_LIBRARY}/protobuf/lib" ${CANTIANDB_LIBRARY} ${OPENSSL_LIB_PATH} ${PCRE_LIB_PATH} ${Z_LIB_PATH} ${ODBC_LIB_PATH} ${VPP_LIB_PATH}
${ZSTD_LIB_PATH} ${KMC_LIB_PATH} ${LZ4_LIB_PATH} ${AES_LIB_PATH})
# add subdir, this should be the last line!!
add_subdirectory(pkg)