forked from v6d-io/v6d
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
1198 lines (1071 loc) · 46.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
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
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
cmake_minimum_required(VERSION 3.3)
set(VINEYARD_MAJOR_VERSION 0)
set(VINEYARD_MINOR_VERSION 24)
set(VINEYARD_PATCH_VERSION 2)
set(VINEYARD_VERSION ${VINEYARD_MAJOR_VERSION}.${VINEYARD_MINOR_VERSION}.${VINEYARD_PATCH_VERSION})
message(STATUS "Configuring and building vineyard version '${VINEYARD_VERSION}'.")
if(POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0025 NEW)
endif()
if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0048 NEW)
endif()
if(POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
endif()
if(POLICY CMP0104)
cmake_policy(SET CMP0104 OLD)
set(CMAKE_POLICY_DEFAULT_CMP0104 OLD)
endif()
if(POLICY CMP0146)
cmake_policy(SET CMP0146 OLD)
set(CMAKE_POLICY_DEFAULT_CMP0146 OLD)
endif()
project(vineyard LANGUAGES C CXX VERSION ${VINEYARD_VERSION})
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(USE_STATIC_BOOST_LIBS "Build with static-linked boost libraries" OFF)
option(USE_EXTERNAL_ETCD_LIBS "Build with external etcd-cpp-apiv3 library rather than the submodule one" OFF)
option(USE_EXTERNAL_REDIS_LIBS "Build with external redis-plus-plus library rather than the submodule one" ON)
option(USE_EXTERNAL_HIREDIS_LIBS "Build with external hiredis library rather than the submodule one" ON)
option(VINEYARD_USE_ASAN "Using address sanitizer to check memory accessing" OFF)
option(VINEYARD_USE_LTO "Using IPO/LTO support for link-time optimization" OFF)
option(USE_LIBUNWIND "Using libunwind to retrieve the stack backtrace when exception occurs" ON)
option(USE_INCLUDE_WHAT_YOU_USE "Simply the intra-module dependencies with iwyu" OFF)
option(USE_JSON_DIAGNOSTICS "Using json diagnostics to check the validity of metadata" OFF)
option(USE_CUDA "Enabling GPU (CUDA) support" OFF)
option(BUILD_VINEYARD_SERVER "Build vineyard's server" ON)
option(BUILD_VINEYARD_SERVER_REDIS "Enable redis as the metadata backend" OFF)
option(BUILD_VINEYARD_SERVER_ETCD "Enable redis as the metadata backend" ON)
option(BUILD_VINEYARD_SERVER_SPILLING "Enable spilling functionalities in vineyardd" ON)
option(BUILD_VINEYARD_CLIENT "Build vineyard's client" ON)
option(BUILD_VINEYARD_CLIENT_VERBOSE "Build vineyard's client with the most verbose logs" OFF)
option(BUILD_VINEYARD_PYTHON_BINDINGS "Build vineyard's python bindings" ON)
option(BUILD_VINEYARD_PYPI_PACKAGES "Build vineyard's python bindings" OFF)
option(BUILD_VINEYARD_JAVA "Build vineyard's java SDK" OFF)
option(BUILD_VINEYARD_BASIC "Build vineyard's basic data structures" ON)
option(BUILD_VINEYARD_IO "Enable vineyard's IOAdaptor support" ON)
option(BUILD_VINEYARD_GRAPH "Enable vineyard's graph data structures" ON)
option(BUILD_VINEYARD_GRAPH_WITH_GAR "Building vineyard's graph data with GraphAr support" OFF)
option(BUILD_VINEYARD_MALLOC "Build vineyard's implementation for client-side malloc" ON)
option(BUILD_VINEYARD_MALLOC_OVERRIDE "Using the client-side malloc to override the default ones" OFF)
option(BUILD_VINEYARD_FUSE "Enable vineyard's fuse support" OFF)
option(BUILD_VINEYARD_FUSE_PARQUET "Enable vineyard's fuse parquet support" OFF)
option(BUILD_VINEYARD_HOSSEINMOEIN_DATAFRAME "Enable hosseinmoein dataframe support" OFF)
option(BUILD_VINEYARD_LLM_CACHE "Enable kv-state cache support" ON)
option(BUILD_VINEYARD_TESTS "Generate make targets for vineyard tests" ON)
option(BUILD_VINEYARD_TESTS_ALL "Include make targets for vineyard tests to ALL" OFF)
option(BUILD_VINEYARD_BENCHMARKS "Generate make targets for vineyard benchmarks" ON)
option(BUILD_VINEYARD_BENCHMARKS_ALL "Include make targets for vineyard benchmarks to ALL" OFF)
option(BUILD_VINEYARD_COVERAGE "Build vineyard with coverage information, requires build with Debug" OFF)
option(BUILD_VINEYARD_PROFILING "Build vineyard with profiling information" OFF)
include(CheckCXXCompilerFlag)
include(CheckLibraryExists)
include(ExternalProject)
include(GNUInstallDirs)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(ProcessorCount)
ProcessorCount(N)
set(DEFAULT_BUILD_TYPE "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE
STRING "Choose the type of build." FORCE
)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo"
)
else()
message(STATUS "Setting build type to '${CMAKE_BUILD_TYPE}'.")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release" AND
("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang"))
# avoid the llvm-strip: error: unsupported load command (cmd=0x80000034) error
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
if(VINEYARD_USE_LTO AND CMAKE_VERSION VERSION_GREATER "3.9" AND
(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
include(CheckIPOSupported)
check_ipo_supported(RESULT lpo_supported OUTPUT lpo_supported_error)
if(lpo_supported)
message(STATUS "IPO / LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "IPO / LTO not supported: '${lpo_supported_error}'")
endif()
endif()
if(NOT (CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache") AND NOT (CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache"))
find_program(ccache_EXECUTABLE ccache)
if(ccache_EXECUTABLE)
set(CMAKE_C_COMPILER_LAUNCHER ${ccache_EXECUTABLE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${ccache_EXECUTABLE})
add_custom_target(ccache-stats
COMMAND ${ccache_EXECUTABLE} --show-stats
)
else()
add_custom_target(ccache-stats
COMMAND echo "ccache not found."
)
endif(ccache_EXECUTABLE)
else()
add_custom_target(ccache-stats
COMMAND ${ccache_EXECUTABLE} --show-stats
)
endif()
# enable colored diagnostics
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
add_compile_options(-fcolor-diagnostics)
endif()
if(USE_INCLUDE_WHAT_YOU_USE AND NOT CMAKE_CXX_INCLUDE_WHAT_YOU_USE)
find_program(iwyu_EXECUTABLE include-what-you-use)
if(iwyu_EXECUTABLE)
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${iwyu_EXECUTABLE})
else()
message(WARNING "Failed to locate iwyu, please specify with -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE instead")
endif()
endif()
set(DEFAULT_ALLOCATOR "dlmalloc")
set(WITH_ALLOCATOR "${DEFAULT_ALLOCATOR}" CACHE
STRING "Choose the allocator for vineyard server (vineyardd)."
)
set_property(CACHE WITH_ALLOCATOR PROPERTY STRINGS
"dlmalloc" "mimalloc"
)
message(STATUS "Setting the allocator to vineyardd as '${WITH_ALLOCATOR}'.")
# check the cxx abi
include("cmake/CheckGCCABI.cmake")
check_gcc_cxx11abi()
get_directory_property(CURRENT_DEFINITIONS COMPILE_DEFINITIONS)
if(NOT ("${CURRENT_DEFINITIONS} ${CMAKE_CXX_FLAGS}" MATCHES ".*_GLIBCXX_USE_CXX11_ABI.*"))
if(GCC_USE_CXX11_ABI EQUAL 1)
add_compile_options(-D_GLIBCXX_USE_CXX11_ABI=1)
endif()
endif()
# disables messages from sub_directory, see also: https://stackoverflow.com/a/38983571/5080177
function(message)
if (NOT MESSAGE_QUIET)
_message(${ARGN})
endif()
endfunction()
message(STATUS "Vineyard will be installed to: ${CMAKE_INSTALL_PREFIX}")
# reference: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#always-full-rpath
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
if(APPLE)
# the LC_RPATH on Mac seems doesn't support multiple path (separated with `:`)
# fortunately, we just need to take care `lib` on Mac.
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
else()
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64:${CMAKE_INSTALL_PREFIX}/lib/x86_64-linux-gnu")
endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC \
-Wall \
-Wno-attributes \
-Wno-unknown-pragmas"
)
check_cxx_compiler_flag(-Wno-class-conversion W_NO_CLASS_CONVERSION)
check_cxx_compiler_flag(-Wno-class-memaccess W_NO_CLASS_MEMACCESS)
check_cxx_compiler_flag(-Wno-defaulted-function-deleted W_NO_DEFAULTED_FUNCTION_DELETED)
check_cxx_compiler_flag(-Wno-deprecated-declarations W_NO_DEPRECATED_DECLARATIONS)
check_cxx_compiler_flag(-Wno-error=c++11-narrowing W_NO_ERROR_CXX11_NARROWING)
check_cxx_compiler_flag(-Wno-format-truncation W_NO_FORMAT_TRUNCATION)
check_cxx_compiler_flag(-Wno-noexcept-type W_NO_NOEXCEPT_TYPE)
check_cxx_compiler_flag(-Wno-unused-but-set-parameter W_NO_UNUSED_BUT_SET_PARAMETER)
check_cxx_compiler_flag(-Wno-unused-private-field W_NO_UNUSED_PRIVATE_FIELD)
check_cxx_compiler_flag(-Wno-unknown-warning-option W_NO_UNKNOWN_WARNING_OPTION)
check_cxx_compiler_flag(-Wno-enum-constexpr-conversion W_NO_ENUM_CONSTEXPR_CONVERSION)
if(W_NO_CLASS_CONVERSION)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-conversion")
endif()
if(W_NO_CLASS_MEMACCESS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess")
endif()
if(W_NO_DEFAULTED_FUNCTION_DELETED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-defaulted-function-deleted")
endif()
if(W_NO_DEPRECATED_DECLARATIONS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
endif()
if(W_NO_ERROR_CXX11_NARROWING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=c++11-narrowing")
endif()
if(W_NO_FORMAT_TRUNCATION)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format-truncation")
endif()
if(W_NO_NOEXCEPT_TYPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-noexcept-type")
endif()
if(W_NO_UNUSED_BUT_SET_PARAMETER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-parameter")
endif()
if(W_NO_UNUSED_PRIVATE_FIELD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field")
endif()
if(W_NO_UNKNOWN_WARNING_OPTION)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option")
endif()
if(W_NO_ENUM_CONSTEXPR_CONVERSION)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-enum-constexpr-conversion")
endif()
if(BUILD_VINEYARD_COVERAGE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
endif()
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,$ORIGIN:$ORIGIN/../shared-lib")
endif()
if(NOT "${CMAKE_CXX_STANDARD}")
check_cxx_compiler_flag(-std=c++14 HAVE_FLAG_STD_CXX14)
check_cxx_compiler_flag(-std=c++17 HAVE_FLAG_STD_CXX17)
if(HAVE_FLAG_STD_CXX17)
set(CMAKE_CXX_STANDARD 17)
elseif(HAVE_FLAG_STD_CXX14)
set(CMAKE_CXX_STANDARD 14)
else()
set(CMAKE_CXX_STANDARD 11)
endif()
endif()
macro(add_subdirectory_shared directory)
set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS ON)
set(CMAKE_BUILD_TYPE_SAVED "${CMAKE_BUILD_TYPE}")
set(CMAKE_BUILD_TYPE Release)
add_subdirectory(${directory} ${ARGN})
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE_SAVED}")
endmacro()
macro(add_subdirectory_static directory)
set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_BUILD_TYPE_SAVED "${CMAKE_BUILD_TYPE}")
set(CMAKE_BUILD_TYPE Release)
add_subdirectory(${directory} ${ARGN})
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE_SAVED}")
endmacro()
macro(add_subdirectory_shared_debug directory)
set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS ON)
set(CMAKE_BUILD_TYPE_SAVED "${CMAKE_BUILD_TYPE}")
set(CMAKE_BUILD_TYPE Debug)
add_subdirectory(${directory} ${ARGN})
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE_SAVED}")
endmacro()
macro(add_subdirectory_static_debug directory)
set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_BUILD_TYPE_SAVED "${CMAKE_BUILD_TYPE}")
set(CMAKE_BUILD_TYPE Debug)
add_subdirectory(${directory} ${ARGN})
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE_SAVED}")
endmacro()
macro(find_apache_arrow)
# workaround for: https://issues.apache.org/jira/browse/ARROW-11836
if(NOT BUILD_VINEYARD_PYPI_PACKAGES)
find_package(Arrow QUIET)
endif()
if(Arrow_FOUND)
set(ARROW_INCLUDE_DIR)
if (TARGET arrow_shared)
set(ARROW_SHARED_LIB arrow_shared)
endif()
if (TARGET arrow_static)
set(ARROW_STATIC_LIB arrow_static)
endif()
else()
include("cmake/FindArrow.cmake")
if(NOT ARROW_FOUND)
message(FATAL_ERROR "apache-arrow is required, please install it and retry")
endif()
endif()
endmacro(find_apache_arrow)
macro(find_boost)
if(NOT BUILD_SHARED_LIBS AND USE_STATIC_BOOST_LIBS)
set(Boost_USE_STATIC_LIBS ON CACHE BOOL "Use static version of boost libraries.")
set(Boost_USE_STATIC_RUNTIME ON CACHE BOOL "Use static version of boost runtimes.")
endif()
find_package(Boost COMPONENTS system filesystem)
# Make boost::property_tree thread safe.
add_compile_options(-DBOOST_SPIRIT_THREADSAFE)
# Don't depends on the boost::system library.
add_compile_options(-DBOOST_ERROR_CODE_HEADER_ONLY)
add_compile_options(-DBOOST_SYSTEM_NO_DEPRECATED)
# eliminate a lot of warnings for newer version of boost library.
add_compile_options(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
# fixes the std::unary_function error
add_compile_options(-DBOOST_NO_CXX98_FUNCTION_BASE)
add_compile_options(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
endmacro()
macro(find_etcd_cpp_apiv3)
if(USE_EXTERNAL_ETCD_LIBS)
find_package(etcd-cpp-api 0.2.9 QUIET)
if(NOT etcd-cpp-api_FOUND)
message(WARNING "etcd-cpp-apiv3 not found, will use the bundled one from git submodules.")
include("cmake/BuildEtcdCpp.cmake")
endif()
else()
include("cmake/BuildEtcdCpp.cmake")
endif()
endmacro()
macro(find_hiredis)
if(USE_EXTERNAL_HIREDIS_LIBS)
# not use find_package, because maybe we don't have hiredis-config.cmake
find_path(HIREDIS_HEADER_PATH hiredis)
find_library(HIREDIS_LIBRARY hiredis)
if(HIREDIS_HEADER_PATH AND HIREDIS_LIBRARY)
set(HIREDIS_INCLUDE_DIR ${HIREDIS_HEADER_PATH})
set(HIREDIS_LIBRARIES ${HIREDIS_LIBRARY})
else()
message(WARNING "hiredis not found, will use the bundled one from git submodules.")
include("cmake/BuildHiredis.cmake")
endif()
else()
include("cmake/BuildHiredis.cmake")
endif()
endmacro()
macro(find_redis_plus_plus)
if(USE_EXTERNAL_REDIS_LIBS)
# not use find_package, because of hiredis
find_path(REDIS_PLUS_PLUS_HEADER sw)
find_library(REDIS_PLUS_PLUS_LIB redis++)
if(REDIS_PLUS_PLUS_HEADER AND REDIS_PLUS_PLUS_LIB)
set(REDIS_PLUS_PLUS_INCLUDE_DIR "${REDIS_PLUS_PLUS_HEADER}/sw")
set(REDIS_PLUS_PLUS_LIBRARIES ${REDIS_PLUS_PLUS_LIB})
else()
message(WARNING "redis-plus-plus not found, will use the bundled one from git submodules.")
include("cmake/BuildRedisCpp.cmake")
endif()
else()
include("cmake/BuildRedisCpp.cmake")
endif()
endmacro()
macro(find_fuse)
include("cmake/FindFUSE3.cmake")
if(BUILD_VINEYARD_FUSE_PARQUET)
if(NOT ARROW_PARQUET)
message(FATAL_ERROR "Parquet is not enabled in the installed arrow.")
endif()
find_package(Parquet REQUIRED HINTS ${Arrow_DIR})
endif()
endmacro()
macro(find_mimalloc)
set(MI_OVERRIDE OFF CACHE INTERNAL "")
set(MI_OSX_INTERPOSE OFF CACHE INTERNAL "")
set(MI_OSX_ZONE OFF CACHE INTERNAL "")
set(MI_DEBUG_FULL OFF CACHE INTERNAL "")
set(MI_BUILD_SHARED OFF CACHE INTERNAL "")
set(MI_BUILD_STATIC ON CACHE INTERNAL "")
set(MI_BUILD_TESTS OFF CACHE INTERNAL "")
if(NOT TARGET mimalloc-static)
add_subdirectory_static(thirdparty/mimalloc EXCLUDE_FROM_ALL)
# Its a hack that expose the internal API symbols inside the mimalloc library, even when
# we are building a static library.
#
# I have checked the source of all usages of the following two macros and it is safe to
# enable them on Linux and MacOS.
target_compile_options(mimalloc-static PRIVATE -DMI_SHARED_LIB -DMI_SHARED_LIB_EXPORT)
endif()
endmacro()
macro(find_glog)
include("cmake/FindGlog.cmake")
endmacro()
macro(find_gflags)
include("cmake/FindGFlags.cmake")
endmacro()
macro(find_libcuckoo)
# install libcuckoo
install(DIRECTORY "${PROJECT_SOURCE_DIR}/thirdparty/libcuckoo/libcuckoo"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/vineyard/contrib
PATTERN "*.hh"
)
include_directories($<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/thirdparty/libcuckoo>
$<INSTALL_INTERFACE:include/vineyard/contrib>
)
endmacro()
macro(find_libunwind)
if(USE_LIBUNWIND)
include("cmake/FindLibUnwind.cmake")
endif()
endmacro()
macro(find_nlohmann_json)
# include nlohmann/json
add_definitions(-DJSON_USE_GLOBAL_UDLS=1)
add_definitions(-DJSON_USE_IMPLICIT_CONVERSIONS=0)
add_definitions(-DJSON_DISABLE_ENUM_SERIALIZATION=0)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND USE_JSON_DIAGNOSTICS)
add_definitions(-DJSON_DIAGNOSTICS=1)
else()
add_definitions(-DJSON_DIAGNOSTICS=0)
endif()
add_definitions(-DJSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON=0)
install(DIRECTORY "${PROJECT_SOURCE_DIR}/thirdparty/nlohmann-json/single_include"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/vineyard/contrib
PATTERN "*.hpp"
)
include_directories(BEFORE SYSTEM
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/thirdparty/nlohmann-json>
$<INSTALL_INTERFACE:include/vineyard/contrib>
)
endmacro()
macro(find_openssl_libraries)
if (APPLE)
# If we're on OS X check for Homebrew's copy of OpenSSL instead of Apple's
if (NOT OpenSSL_DIR)
find_program(HOMEBREW brew)
if (HOMEBREW STREQUAL "HOMEBREW-NOTFOUND")
message(WARNING "Homebrew not found: not using Homebrew's OpenSSL")
if (NOT OPENSSL_ROOT_DIR)
message(WARNING "Use -DOPENSSL_ROOT_DIR for non-Apple OpenSSL")
endif()
else()
execute_process(COMMAND brew --prefix openssl
OUTPUT_VARIABLE OPENSSL_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
endif()
endif()
find_package(OpenSSL ${ARGN})
if (OPENSSL_FOUND)
include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})
endif()
endmacro()
macro(find_pthread)
# find pthread
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads)
endmacro()
macro(find_cuda)
# find cuda runtime library
set(CUDA_USE_STATIC_CUDA_RUNTIME ON)
find_package(CUDA REQUIRED)
endmacro(find_cuda)
macro(find_zstd)
# include zstd
set(ZSTD_LEGACY_SUPPORT OFF CACHE INTERNAL "")
set(ZSTD_MULTITHREAD_SUPPORT OFF CACHE INTERNAL "")
set(ZSTD_BUILD_PROGRAMS OFF CACHE INTERNAL "")
set(ZSTD_BUILD_CONTRIB OFF CACHE INTERNAL "")
set(ZSTD_BUILD_TESTS OFF CACHE INTERNAL "")
set(ZSTD_BUILD_SHARED OFF CACHE INTERNAL "")
set(ZSTD_BUILD_STATIC ON CACHE INTERNAL "")
set(ZSTD_BUILD_COMPRESSION ON CACHE INTERNAL "")
set(ZSTD_BUILD_DECOMPRESSION ON CACHE INTERNAL "")
set(ZSTD_BUILD_DICTBUILDER OFF CACHE INTERNAL "")
set(ZSTD_BUILD_DEPRECATED OFF CACHE INTERNAL "")
set(ZSTDLIB_VISIBLE "hidden" CACHE STRING "" FORCE)
set(ZSTDERRORLIB_VISIBLE "hidden" CACHE STRING "" FORCE)
set(ZDICTLIB_VISIBLE "hidden" CACHE STRING "" FORCE)
set(ZSTDLIB_STATIC_API "hidden" CACHE STRING "" FORCE)
set(ZDICTLIB_STATIC_API "hidden" CACHE STRING "" FORCE)
if (NOT TARGET libzstd_static)
set(CMAKE_MODULE_PATH_ORIGINAL ${CMAKE_MODULE_PATH})
if(${CMAKE_VERSION} VERSION_LESS "3.18")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
endif()
add_subdirectory_static(thirdparty/zstd/build/cmake EXCLUDE_FROM_ALL)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH_ORIGINAL})
endif()
endmacro()
macro(find_common_libraries)
find_glog()
find_libcuckoo()
find_libunwind()
find_pthread()
find_nlohmann_json()
find_zstd()
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
include_directories(SYSTEM ${GLOG_INCLUDE_DIR})
endmacro()
# find openssl first since apache-arrow may requires that (on MacOS, installed by brew)
find_openssl_libraries(QUIET)
find_common_libraries()
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/modules)
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/thirdparty)
# build profiling library
if(BUILD_VINEYARD_PROFILING)
add_definitions(-DWITH_PROFILING)
include("cmake/FindGperftools.cmake")
endif()
if(${LIBUNWIND_FOUND})
add_definitions(-DWITH_LIBUNWIND)
endif ()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/static-lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/shared-lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
macro(target_add_link_options target scope)
set(options)
set(oneValueArgs)
set(multiValueArgs OPTIONS)
cmake_parse_arguments(target_add_link_options "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(${CMAKE_VERSION} VERSION_LESS "3.13")
target_link_libraries(${target} INTERFACE ${target_add_link_options_OPTIONS})
else()
target_link_options(${target} ${scope} ${target_add_link_options_OPTIONS})
endif()
endmacro()
macro(target_enable_sanitizer target visibility)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND VINEYARD_USE_ASAN)
message(STATUS "Vineyardd will be built with -fsanitize=address")
target_compile_options(${target} ${visibility} -fsanitize=address)
target_add_link_options(${target} ${visibility} OPTIONS -fsanitize=address)
endif()
endmacro()
macro(target_add_debuginfo target)
target_compile_options(${target} PRIVATE -g)
endmacro()
macro(install_vineyard_target target)
install(TARGETS ${target}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
endmacro()
macro(install_export_vineyard_target target)
install(TARGETS ${target}
EXPORT vineyard-targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
endmacro()
macro(install_vineyard_headers header_path)
if(${ARGC} GREATER_EQUAL 2)
set(install_headers_destination "${ARGV1}")
else()
set(install_headers_destination "include/vineyard")
endif()
install(DIRECTORY ${header_path}
DESTINATION ${install_headers_destination} # target directory
FILES_MATCHING # install only matched files
PATTERN "*.h" # select header files
PATTERN "*.hpp" # select C++ template header files
PATTERN "*.vineyard-mod" # select vineyard template files
PATTERN "*/thirdparty/*" EXCLUDE # exclude thirdparty
)
endmacro()
install_vineyard_headers("${PROJECT_SOURCE_DIR}/src/common")
set(VINEYARD_INSTALL_LIBS)
# resolve targets dependencies
if(BUILD_VINEYARD_PYPI_PACKAGES)
set(BUILD_VINEYARD_PYTHON_BINDINGS ON)
endif()
if(BUILD_VINEYARD_FUSE_PARQUET)
set(BUILD_VINEYARD_FUSE ON)
endif()
if(BUILD_VINEYARD_FUSE)
set(BUILD_VINEYARD_BASIC ON)
endif()
if(BUILD_VINEYARD_GRAPH)
set(BUILD_VINEYARD_BASIC ON)
set(BUILD_VINEYARD_IO ON)
endif()
if(BUILD_VINEYARD_HOSSEINMOEIN_DATAFRAME)
set(BUILD_VINEYARD_BASIC ON)
endif()
if(BUILD_VINEYARD_IO)
set(BUILD_VINEYARD_BASIC ON)
endif()
if(BUILD_VINEYARD_BASIC OR BUILD_VINEYARD_IO OR BUILD_VINEYARD_MIGRATION OR BUILD_VINEYARD_PYTHON_BINDINGS)
set(BUILD_VINEYARD_CLIENT ON)
find_apache_arrow()
include_directories(SYSTEM ${ARROW_INCLUDE_DIR})
endif()
if(BUILD_VINEYARD_MALLOC)
find_mimalloc()
set(BUILD_VINEYARD_CLIENT ON)
endif()
add_custom_target(vineyard_tests)
add_custom_target(vineyard_benchmarks)
add_custom_target(vineyard_codegen)
add_custom_target(vineyard_codegen_java)
include("cmake/GenerateVineyard.cmake")
include("cmake/GenerateVineyardJava.cmake")
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
find_library(RDMACM_LIB rdmacm)
find_library(IBVERBS_LIB ibverbs)
find_library(RT_LIB rt)
if (NOT RT_LIB)
message(FATAL_ERROR "Missing librt, please install it and retry")
endif()
set(FABRIC_MAKEFILE "${CMAKE_SOURCE_DIR}/thirdparty/libfabric/Makefile")
if(IBVERBS_LIB AND RDMACM_LIB)
set(RDMA_LIBS ${RDMACM_LIB} ${IBVERBS_LIB} ${RT_LIB})
add_custom_command(
OUTPUT ${FABRIC_MAKEFILE}
COMMAND ./autogen.sh > /dev/null
COMMAND ./configure --disable-usnic
--disable-psm3
--disable-opx
--disable-dmabuf_peer_mem
--disable-hook_hmem
--disable-hook_debug
--disable-trace
--disable-rxm
--disable-psm2
--disable-xpmem
--disable-shm
--disable-rxd
--disable-perf
--disable-efa
--disable-mrail
--enable-verbs > /dev/null
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/thirdparty/libfabric
)
else()
set(RDMA_LIBS ${RT_LIB})
add_custom_command(
OUTPUT ${FABRIC_MAKEFILE}
COMMAND ./autogen.sh > /dev/null
COMMAND ./configure --disable-usnic
--disable-psm3
--disable-opx
--disable-dmabuf_peer_mem
--disable-hook_hmem
--disable-hook_debug
--disable-trace
--disable-rxm
--disable-psm2
--disable-xpmem
--disable-shm
--disable-rxd
--disable-perf
--disable-efa
--disable-mrail
--disable-verbs > /dev/null
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/thirdparty/libfabric
)
endif()
add_custom_target(
fabric_configure
DEPENDS ${FABRIC_MAKEFILE}
)
add_custom_target(
fabric ALL
COMMAND make CFLAGS+="-fPIC" -j$(nproc) > /dev/null
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_SOURCE_DIR}/thirdparty/libfabric/src/.libs/libfabric.a ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libfabric.a
DEPENDS fabric_configure
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/thirdparty/libfabric
)
set(LIBFABRIC "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libfabric.a")
set(LIBFABRIC_VERSION_SCRIPT "${CMAKE_SOURCE_DIR}/src/common/rdma/libfabric.map")
install(DIRECTORY "${PROJECT_SOURCE_DIR}/thirdparty/libfabric/include"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/vineyard/contrib/libfabric
PATTERN "*.h"
)
include_directories(BEFORE SYSTEM
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/thirdparty/libfabric/include>
$<INSTALL_INTERFACE:include/vineyard/contrib>
)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libfabric.a)
endif()
# boost is only required by some components
if(BUILD_VINEYARD_SERVER OR BUILD_VINEYARD_IO OR BUILD_VINEYARD_GRAPH)
find_boost()
endif()
# build vineyardd
if(BUILD_VINEYARD_SERVER)
find_gflags()
find_mimalloc()
if(BUILD_VINEYARD_SERVER_REDIS)
find_hiredis()
find_redis_plus_plus()
endif()
if(BUILD_VINEYARD_SERVER_ETCD)
find_etcd_cpp_apiv3()
find_openssl_libraries(REQUIRED)
endif()
if(BUILD_VINEYARD_SERVER_SPILLING)
find_apache_arrow()
endif()
if(USE_CUDA)
find_cuda()
endif()
file(GLOB_RECURSE SERVER_SRC_FILES "src/server/*.cc"
"src/common/compression/*.cc"
"src/common/memory/*.cc"
"src/common/util/*.cc"
"src/common/memory/gpu/*.cc"
"src/common/rdma/*.cc"
)
if(BUILD_VINEYARD_SERVER_REDIS)
list(APPEND SERVER_SRC_FILES "thirdparty/redis-plus-plus-shim/recipes/redlock.cpp")
endif()
add_executable(vineyardd ${SERVER_SRC_FILES})
target_add_debuginfo(vineyardd)
target_compile_options(vineyardd PRIVATE -DBUILD_VINEYARDD)
target_link_libraries(vineyardd PRIVATE ${Boost_LIBRARIES}
${CMAKE_DL_LIBS}
${GFLAGS_LIBRARIES}
${GLOG_LIBRARIES}
libzstd_static
mimalloc-static
)
target_include_directories(vineyardd PRIVATE ${GFLAGS_INCLUDE_DIR})
if(BUILD_VINEYARD_SERVER_REDIS)
target_compile_options(vineyardd PRIVATE -DBUILD_VINEYARDD_REDIS)
target_include_directories(vineyardd PRIVATE ${HIREDIS_INCLUDE_DIR}
${REDIS_PLUS_PLUS_INCLUDE_DIR}
)
target_link_libraries(vineyardd PRIVATE ${HIREDIS_LIBRARIES}
${REDIS_PLUS_PLUS_LIBRARIES}
)
endif()
if(BUILD_VINEYARD_SERVER_ETCD)
target_compile_options(vineyardd PRIVATE -DBUILD_VINEYARDD_ETCD)
target_include_directories(vineyardd PRIVATE ${ETCD_CPP_INCLUDE_DIR})
target_link_libraries(vineyardd PRIVATE ${CPPREST_LIB}
${ETCD_CPP_LIBRARIES}
${OPENSSL_LIBRARIES}
)
endif()
if(BUILD_VINEYARD_SERVER_SPILLING)
target_compile_options(vineyardd PRIVATE -DBUILD_VINEYARDD_SPILLING)
target_include_directories(vineyardd PRIVATE ${ARROW_INCLUDE_DIR})
if(ARROW_SHARED_LIB)
target_link_libraries(vineyardd PRIVATE ${ARROW_SHARED_LIB})
else()
target_link_libraries(vineyardd PRIVATE ${ARROW_STATIC_LIB})
endif()
endif()
if(USE_CUDA)
target_compile_options(vineyardd PRIVATE -DENABLE_CUDA)
target_include_directories(vineyardd PRIVATE ${CUDA_INCLUDE_DIRS})
target_link_libraries(vineyardd PRIVATE ${CUDA_LIBRARIES})
endif()
if(${LIBUNWIND_FOUND})
target_link_libraries(vineyardd PRIVATE ${LIBUNWIND_LIBRARIES})
endif()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_link_libraries(vineyardd PRIVATE ${LIBFABRIC} ${RDMA_LIBS})
set_target_properties(vineyardd PROPERTIES LINK_FLAGS "-Wl,--version-script=${LIBFABRIC_VERSION_SCRIPT}")
add_dependencies(vineyardd fabric)
endif()
install_vineyard_target(vineyardd)
if(NOT BUILD_SHARED_LIBS)
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(vineyardd PRIVATE -static-libgcc -static-libstdc++ -Os)
target_add_link_options(vineyardd PRIVATE OPTIONS -static-libgcc -static-libstdc++ -Os)
endif()
target_link_libraries(vineyardd PRIVATE ${GRPC_GRPC++_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY})
endif()
if(BUILD_VINEYARD_PROFILING)
target_include_directories(vineyardd PRIVATE ${Gperftools_INCLUDE_DIRS})
target_link_libraries(vineyardd PRIVATE ${Gperftools_LIBRARIES})
endif()
message(STATUS "Vineyard will use '${WITH_ALLOCATOR}' by default for shared memory allocation")
# bundle dlmalloc and mimalloc at the same time
target_compile_options(vineyardd PRIVATE -DWITH_DLMALLOC -DWITH_MIMALLOC)
if(WITH_ALLOCATOR STREQUAL "dlmalloc")
target_compile_options(vineyardd PRIVATE -DDEFAULT_ALLOCATOR=dlmalloc)
endif()
if(WITH_ALLOCATOR STREQUAL "mimalloc")
target_compile_options(vineyardd PRIVATE -DDEFAULT_ALLOCATOR=mimalloc)
endif()
endif()
# build vineyard-client
if(BUILD_VINEYARD_CLIENT)
# build vineyard registry library, it can only be a shared library, as a singleton.
add_library(vineyard_internal_registry SHARED "src/client/ds/factory/registry.cc")
target_link_libraries(vineyard_internal_registry PRIVATE ${CMAKE_DL_LIBS})
if(BUILD_VINEYARD_PYPI_PACKAGES)
target_compile_options(vineyard_internal_registry PRIVATE -Os)
target_add_link_options(vineyard_internal_registry PRIVATE OPTIONS -Os)
target_add_link_options(vineyard_internal_registry PRIVATE OPTIONS -Os)
endif()
install_export_vineyard_target(vineyard_internal_registry)
target_add_link_options(vineyard_internal_registry PRIVATE
OPTIONS -Wl,-rpath,.:$ORIGIN:${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64
)
set_target_properties(vineyard_internal_registry PROPERTIES CXX_VISIBILITY_PRESET "hidden")
# build the vineyard client library
file(GLOB CLIENT_SRC_FILES "src/client/*.cc"
"src/client/ds/*.cc"
"src/common/compression/*.cc"
"src/common/memory/*.cc"
"src/common/util/*.cc"
"src/common/memory/gpu/*.cc"
"src/common/rdma/*.cc"
)
# the vineyard_client can only be a shared library, since the ObjectFactory
# is a singleton.
add_library(vineyard_client ${CLIENT_SRC_FILES})
target_add_debuginfo(vineyard_client)
target_link_libraries(vineyard_client PUBLIC ${CMAKE_DL_LIBS}
Threads::Threads
)
target_link_libraries(vineyard_client PRIVATE libzstd_static)
if(USE_CUDA)
find_cuda()
target_compile_options(vineyard_client PRIVATE -DENABLE_CUDA)
target_include_directories(vineyard_client PRIVATE ${CUDA_INCLUDE_DIRS})
target_link_libraries(vineyard_client PRIVATE ${CUDA_LIBRARIES})
endif()
# make sure `vineyard_internal_registry` been built.
add_dependencies(vineyard_client vineyard_internal_registry)
if(${LIBUNWIND_FOUND})
target_link_libraries(vineyard_client PRIVATE ${LIBUNWIND_LIBRARIES})
endif()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_link_libraries(vineyard_client PRIVATE ${LIBFABRIC} ${RDMA_LIBS})
set_target_properties(vineyard_client PROPERTIES LINK_FLAGS "-Wl,--version-script=${LIBFABRIC_VERSION_SCRIPT}")
add_dependencies(vineyard_client fabric)
endif()
if(BUILD_VINEYARD_CLIENT_VERBOSE)
target_compile_options(vineyard_client PRIVATE -DWITH_VERBOSE)
endif()
if(BUILD_VINEYARD_PYPI_PACKAGES)
target_compile_options(vineyard_client PRIVATE -Os)
target_add_link_options(vineyard_client PRIVATE OPTIONS -Os)
if(APPLE)
target_compile_options(vineyard_client PRIVATE -fvisibility=hidden)
endif()
endif()
file(GLOB_RECURSE VINEYARD_CLIENT_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/src"
"client/*.h")
if(BUILD_VINEYARD_JAVA AND VINEYARD_CLIENT_HEADERS)
vineyard_generate_java(
OUT_VAR VINEYARD_JAVA_GENERATES
VINEYARD_MODULES ${VINEYARD_CLIENT_HEADERS}
)
else()
set(VINEYARD_JAVA_GENERATES)
endif()
add_custom_target(vineyard_client_gen_java
DEPENDS ${VINEYARD_JAVA_GENERATES}
COMMENT "Running java code generation for vineyard_client."
)
if(VINEYARD_JAVA_GENERATES)
add_dependencies(vineyard_codegen_java vineyard_client_gen_java)
endif()
install_export_vineyard_target(vineyard_client)
install_vineyard_headers("${PROJECT_SOURCE_DIR}/src/client")
list(APPEND VINEYARD_INSTALL_LIBS vineyard_client)
endif()
if (BUILD_VINEYARD_PYTHON_BINDINGS)
set(PYBIND11_PYTHON_VERSION 3)
if(NOT (CMAKE_VERSION VERSION_LESS "3.27"))
set(PYBIND11_FINDPYTHON ON)
endif()
add_subdirectory_static(thirdparty/pybind11)
endif()
macro(setup_pybind11_module target relpath)
target_add_debuginfo(${target})
target_link_libraries(${target} PRIVATE vineyard_client)
target_include_directories(${target} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/pybind11/include")
target_compile_options(${target} PRIVATE -Wno-unused-value)
set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/shared-lib")
if(UNIX AND NOT APPLE)
target_add_link_options(${target} PRIVATE OPTIONS -Wl,--exclude-libs=ALL)
endif()
if(BUILD_VINEYARD_PYPI_PACKAGES AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${target} PRIVATE -static)
target_add_link_options(${target} PRIVATE OPTIONS -static)
else()
target_compile_options(${target} PRIVATE -Os)
target_add_link_options(${target} PRIVATE OPTIONS -Os)
endif()
file(RELATIVE_PATH RELATIVE_BUILD_PATH "${PROJECT_SOURCE_DIR}/python/vineyard" "${CMAKE_BINARY_DIR}/shared-lib")
if(UNIX AND NOT APPLE)
set_target_properties(${target} PROPERTIES
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH TRUE
INSTALL_RPATH ".:\$ORIGIN:\$ORIGIN/${relpath}/:${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64:${INSTALL_RPATH}")
endif()
if(APPLE)
set_target_properties(${target} PROPERTIES
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH TRUE
INSTALL_RPATH ".;@loader_path;@loader_path/${relpath}/;${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib64;${INSTALL_RPATH}")
endif()
endmacro()
if(BUILD_VINEYARD_PYTHON_BINDINGS)
pybind11_add_module(_C MODULE "python/client.cc"
"python/core.cc"