forked from OpenAtomFoundation/pika
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
530 lines (488 loc) · 11.8 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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
cmake_minimum_required(VERSION 3.10)
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
set(CMAKE_CXX_STANDARD 17)
project(pika)
set(CMAKE_CXX_FLAGS "-pthread -Wl,--no-as-needed -ldl")
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(EP_BASE_SUFFIX "buildtrees")
set_property(DIRECTORY PROPERTY EP_BASE ${CMAKE_CURRENT_SOURCE_DIR}/${EP_BASE_SUFFIX})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules/")
set(STAGED_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/deps)
set(CMAKE_UTILS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/utils)
set(INSTALL_INCLUDEDIR ${STAGED_INSTALL_PREFIX}/include)
set(INSTALL_LIBDIR ${STAGED_INSTALL_PREFIX}/lib)
set(INSTALL_LIBDIR_64 ${STAGED_INSTALL_PREFIX}/lib64)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${STAGED_INSTALL_PREFIX})
execute_process(COMMAND sh ${CMAKE_UTILS_DIR}/Get_OS_Version.sh
OUTPUT_VARIABLE OS_VERSION)
message(STATUS "${PROJECT_NAME} staged install: ${STAGED_INSTALL_PREFIX}")
message(STATUS "Current platform: ${OS_VERSION} ")
cmake_host_system_information(RESULT CPU_CORE QUERY NUMBER_OF_LOGICAL_CORES)
message(STATUS "Cpu core ${CPU_CORE}")
include(protogen.cmake)
include(ExternalProject)
ExternalProject_Add(gtest
URL
https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz
URL_HASH
MD5=e82199374acdfda3f425331028eb4e2a
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
BUILD_ALWAYS
1
BUILD_COMMAND
make -j${CPU_CORE}
)
if (${OS_VERSION} MATCHES "CentOS")
set(GTEST_LIBRARY ${INSTALL_LIBDIR_64}/libgtest.a)
else ()
set(GTEST_LIBRARY ${INSTALL_LIBDIR}/libgtest.a)
endif ()
set(GTEST_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
ExternalProject_Add(gflags
URL
https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz
URL_HASH
MD5=1a865b93bacfa963201af3f75b7bd64c
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
BUILD_ALWAYS
1
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DGFLAGS_NAMESPACE=gflags
-DBUILD_STATIC_LIBS=ON
-DBUILD_SHARED_LIBS=OFF
BUILD_COMMAND
make -j${CPU_CORE}
)
set(GFLAGS_LIBRARY ${INSTALL_LIBDIR}/libgflags.a)
set(GFLAGS_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
ExternalProject_Add(unwind
DEPENDS
URL
http://download.savannah.nongnu.org/releases/libunwind/libunwind-1.6.2.tar.gz
URL_HASH
MD5=f625b6a98ac1976116c71708a73dc44a
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
CONFIGURE_COMMAND
<SOURCE_DIR>/configure --prefix=${STAGED_INSTALL_PREFIX} --enable-minidebuginfo=no --enable-zlibdebuginfo=no
BUILD_IN_SOURCE
1
BUILD_COMMAND
make -j${CPU_CORE}
INSTALL_COMMAND
make install
)
set(LIBUNWIND_LIBRARY ${INSTALL_LIBDIR}/libunwind.a)
set(LIBUNWIND_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
ExternalProject_Add(glog
DEPENDS
gflags
gtest
unwind
URL
https://github.com/google/glog/archive/refs/tags/v0.6.0.tar.gz
URL_HASH
MD5=c98a6068bc9b8ad9cebaca625ca73aa2
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
BUILD_ALWAYS
1
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DWITH_GFLAGS=ON
-DBUILD_TESTING=OFF
-DBUILD_SHARED_LIBS=OFF
-DWITH_UNWIND=ON
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
BUILD_COMMAND
make -j${CPU_CORE}
)
set(GLOG_LIBRARY ${INSTALL_LIBDIR}/libglog.a)
set(GLOG_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
ExternalProject_Add(snappy
DEPENDS
URL
https://github.com/google/snappy/archive/refs/tags/1.1.7.tar.gz
URL_HASH
MD5=ee9086291c9ae8deb4dac5e0b85bf54a
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DSNAPPY_BUILD_TESTS=OFF
-DBUILD_STATIC_LIBS=ON
-DBUILD_SHARED_LIBS=OFF
BUILD_ALWAYS
1
BUILD_COMMAND
make -j${CPU_CORE}
)
if (${OS_VERSION} MATCHES "CentOS")
set(SNAPPY_LIBRARY ${INSTALL_LIBDIR_64}/libsnappy.a)
else ()
set(SNAPPY_LIBRARY ${INSTALL_LIBDIR}/libsnappy.a)
endif ()
set(SNAPPY_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
ExternalProject_Add(zstd
DEPENDS
URL
https://github.com/facebook/zstd/releases/download/v1.5.4/zstd-1.5.4.tar.gz
URL_HASH
MD5=2352b1f9ccc7446641046bb3d440c3ed
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
SOURCE_SUBDIR
build/cmake
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DBUILD_TESTING=OFF
-DZSTD_BUILD_STATIC=ON
-DZSTD_BUILD_SHARED=OFF
BUILD_ALWAYS
1
BUILD_COMMAND
make -j${CPU_CORE}
)
if (${OS_VERSION} MATCHES "CentOS")
set(ZSTD_LIBRARY ${INSTALL_LIBDIR_64}/libzstd.a)
else ()
set(ZSTD_LIBRARY ${INSTALL_LIBDIR}/libzstd.a)
endif ()
set(ZSTD_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
ExternalProject_Add(lz4
DEPENDS
URL
https://github.com/lz4/lz4/archive/refs/tags/v1.9.4.tar.gz
URL_HASH
MD5=e9286adb64040071c5e23498bf753261
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
SOURCE_SUBDIR
build/cmake
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DBUILD_TESTING=OFF
-DBUILD_STATIC_LIBS=ON
-DBUILD_SHARED_LIBS=OFF
BUILD_ALWAYS
1
BUILD_COMMAND
make -j${CPU_CORE}
)
if (${OS_VERSION} MATCHES "CentOS")
set(LZ4_LIBRARY ${INSTALL_LIBDIR_64}/liblz4.a)
else ()
set(LZ4_LIBRARY ${INSTALL_LIBDIR}/liblz4.a)
endif ()
set(LZ4_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
ExternalProject_Add(zlib
DEPENDS
URL
https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.gz
URL_HASH
MD5=9b8aa094c4e5765dabf4da391f00d15c
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
BUILD_ALWAYS
1
BUILD_COMMAND
make -j${CPU_CORE}
)
set(ZLIB_LIBRARY ${INSTALL_LIBDIR}/libz.a)
set(ZLIB_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
ExternalProject_Add(gperftools
DEPENDS
unwind
URL
https://github.com/gperftools/gperftools/releases/download/gperftools-2.10/gperftools-2.10.tar.gz
URL_HASH
MD5=62bf6c76ba855ed580de5e139bd2a483
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DGPERFTOOLS_BUILD_STATIC=ON
-DEFAULT_BUILD_MINIMAL=ON
BUILD_COMMAND
make -j${CPU_CORE}
)
if (${OS_VERSION} MATCHES "CentOS")
set(TCMALLOC_LIBRARY ${INSTALL_LIBDIR_64}/liblibtcmalloclz4.a)
else ()
set(TCMALLOC_LIBRARY ${INSTALL_LIBDIR}/libtcmalloc.a)
endif ()
set(TCMALLOC_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
ExternalProject_Add(jemalloc
DEPENDS
URL
https://github.com/jemalloc/jemalloc/archive/refs/tags/5.3.0.tar.gz
URL_HASH
MD5=594dd8e0a1e8c1ef8a1b210a1a5aff5b
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
CONFIGURE_COMMAND
<SOURCE_DIR>/autogen.sh --prefix=${STAGED_INSTALL_PREFIX}
BUILD_IN_SOURCE
1
BUILD_COMMAND
make -j${CPU_CORE}
BUILD_ALWAYS
1
INSTALL_COMMAND
make install
)
set(JEMALLOC_LIBRARY ${INSTALL_LIBDIR}/libjemalloc.a)
set(JEMALLOC_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
ExternalProject_Add(protobuf
DEPENDS
zlib
URL
https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-cpp-3.17.3.tar.gz
URL_HASH
MD5=3fe4c2647e0991c014a386a896d0a116
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
SOURCE_SUBDIR
cmake
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DBUILD_SHARED_LIBS=FALSE
-Dprotobuf_BUILD_TESTS=FALSE
BUILD_IN_SOURCE
1
BUILD_ALWAYS
1
BUILD_COMMAND
make -j${CPU_CORE}
)
set(PROTOBUF_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
set(PROTOBUF_LIBRARY ${INSTALL_LIBDIR}/libprotobuf.a)
set(PROTOBUF_PROTOC ${STAGED_INSTALL_PREFIX}/bin/protoc)
ExternalProject_Add(rocksdb
DEPENDS
gflags
gtest
snappy
zstd
lz4
zlib
gperftools
jemalloc
URL
https://github.com/facebook/rocksdb/archive/refs/tags/v7.7.3.tar.gz
URL_HASH
MD5=3c5d371a8bd8340b1975ad016151709d
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
BUILD_ALWAYS
1
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
-DWITH_BENCHMARK=OFF
-DWITH_BENCHMARK_TOOLS=OFF
-DWITH_TOOLS=OFF
-DWITH_CORE_TOOLS=OFF
-DWITH_TESTS=OFF
-DWITH_TRACE_TOOLS=OFF
-DWITH_EXAMPLES=OFF
-DROCKSDB_BUILD_SHARED=OFF
-DWITH_JEMALLOC=ON
-DWITH_LZ4=ON
-DWITH_SNAPPY=ON
-DWITH_ZLIB=ON
-DWITH_ZSTD=ON
-DWITH_GFLAGS=ON
BUILD_COMMAND
make -j${CPU_CORE}
)
if (${OS_VERSION} MATCHES "CentOS")
set(ROCKSDB_LIBRARY ${INSTALL_LIBDIR_64}/librocksdb.a)
else ()
set(ROCKSDB_LIBRARY ${INSTALL_LIBDIR}/librocksdb.a)
endif ()
set(ROCKSDB_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
set(ROCKSDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${EP_BASE_SUFFIX}/Source/rocksdb)
add_subdirectory(src/slash)
add_subdirectory(src/pink)
add_subdirectory(src/blackwidow)
aux_source_directory(src DIR_SRCS)
# # generate version
string(TIMESTAMP TS "%Y-%m-%d %H:%M:%S" UTC)
set(PIKA_BUILD_DATE "${TS}" CACHE STRING "the time we first built pika")
find_package(Git)
if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE PIKA_GIT_SHA COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD)
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE PIKA_GIT_MOD COMMAND "${GIT_EXECUTABLE}" diff-index HEAD --quiet)
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE PIKA_GIT_DATE COMMAND "${GIT_EXECUTABLE}" log -1 --date=format:"%Y-%m-%d %T" --format="%ad")
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE PIKA_GIT_TAG RESULT_VARIABLE rv COMMAND "${GIT_EXECUTABLE}" symbolic-ref -q --short HEAD OUTPUT_STRIP_TRAILING_WHITESPACE)
if(rv AND NOT rv EQUAL 0)
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE PIKA_GIT_TAG COMMAND "${GIT_EXECUTABLE}" describe --tags --exact-match OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
else()
set(PIKA_GIT_SHA 0)
set(PIKA_GIT_MOD 1)
endif()
string(REGEX REPLACE "[^0-9a-fA-F]+" "" PIKA_GIT_SHA "${PIKA_GIT_SHA}")
string(REGEX REPLACE "[^0-9: /-]+" "" PIKA_GIT_DATE "${PIKA_GIT_DATE}")
message("pika GIT_SHA = ${PIKA_GIT_SHA}")
message("pika GIT_MOD = ${PIKA_GIT_MOD}")
message("pika GIT_DATE = ${PIKA_GIT_DATE}")
message("pika GIT_TAG = ${PIKA_GIT_TAG}")
message("pika BUILD_DATE = ${PIKA_BUILD_DATE}")
set(PIKA_BUILD_VERSION_CC ${CMAKE_BINARY_DIR}/pika_build_version.cc)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/build_version.cc.in ${PIKA_BUILD_VERSION_CC} @ONLY)
set(PROTO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pika_inner_message.proto)
custom_protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
message("pika PROTO_SRCS = ${PROTO_SRCS}")
message("pika PROTO_HDRS = ${PROTO_HDRS}")
add_executable(${PROJECT_NAME}
${DIR_SRCS}
${PROTO_SRCS}
${PROTO_HDRS}
${PIKA_BUILD_VERSION_CC})
target_link_directories(${PROJECT_NAME}
PUBLIC ${INSTALL_LIBDIR_64}
PUBLIC ${INSTALL_LIBDIR})
add_dependencies(${PROJECT_NAME}
gflags
gtest
unwind
glog
snappy
zstd
lz4
zlib
gperftools
jemalloc
rocksdb
protobuf
slash
pink
blackwidow)
target_include_directories(${PROJECT_NAME}
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
PUBLIC ${PROJECT_SOURCE_DIR}
${INSTALL_INCLUDEDIR}
)
target_link_libraries(${PROJECT_NAME}
blackwidow
pink
slash
libglog.a
librocksdb.a
libprotobuf.a
libgflags.a
libsnappy.a
libzstd.a
liblz4.a
libz.a
libunwind.a
libjemalloc.a)