-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
714 lines (636 loc) · 26 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
cmake_minimum_required(VERSION 3.23 FATAL_ERROR)
project(${SKBUILD_PROJECT_NAME} LANGUAGES C CXX)
# External Packages
include(FetchContent)
# Debug Helpers
include(CMakePrintHelpers)
# LTO Support
include(CheckIPOSupported)
check_ipo_supported(LANGUAGES CXX)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
set (X86 TRUE)
else()
set (X86 FALSE)
endif()
# ------------------------- Enable Compilation Caches -------------------------
# Enable CCache or SCCache if Found
# CCache is very useful when developing C++ code, because on
# rebuild it will only recompile the cpp files that have been modified.
# SCCache is similar, but supports remote S3 caches
# We use CCache for local development and SCCache for CI
# Note that SCCache doesn't handle linking, so we skip for both
find_program(CCACHE_EXECUTABLE "ccache")
find_program(SCCACHE_EXECUTABLE "sccache")
if ((NOT DEFINED ENV{DISABLE_CCACHE}) AND CCACHE_EXECUTABLE)
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
set(CMAKE_C_COMPILER_LAUNCHER ccache)
elseif ((NOT DEFINED ENV{DISABLE_SCCACHE}) AND SCCACHE_EXECUTABLE)
set(CMAKE_CXX_COMPILER_LAUNCHER sccache)
set(CMAKE_C_COMPILER_LAUNCHER sccache)
endif()
# ---------------------------- Enable C++ Linting ----------------------------
# Clang-Tidy is only available on MacOS as we use GCC on Linux
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if (LINUX)
message(STATUS "Clang-Tidy is not used on Linux")
set(CLANG_TIDY_COMMAND "")
elseif (CLANG_TIDY_EXE)
message(STATUS "Found Clang-Tidy: ${CLANG_TIDY_EXE}")
set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" "--checks=.clang-tidy" "--fix-errors")
else()
message(STATUS "Clang-Tidy was not found")
set(CLANG_TIDY_COMMAND "")
endif()
# ----------------------------- Declare Dependencies -------------------------
# We need to do this before setting CMake Options so they aren't propagated
set(BUILD_WITH_V8 "$ENV{BUILD_WITH_V8}")
cmake_print_variables(BUILD_WITH_V8)
if (BUILD_WITH_V8)
# Needed for Prix64 to be defined in g++/Centos
add_compile_definitions("__STDC_FORMAT_MACROS")
include(FetchContent)
FetchContent_Declare(
v8
GIT_REPOSITORY https://github.com/bnoordhuis/v8-cmake.git
GIT_TAG "tags/11.6.189.4"
)
FetchContent_MakeAvailable(v8)
endif()
# Download and Build 'fmt' from Git Directly
set(FMT_TEST OFF CACHE INTERNAL "disabling fmt tests")
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 10.2.1
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(fmt)
set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON)
# If we're building dependencies (not getting them from conda), we need to build AWS SDK
if("$ENV{CONDA_PREFIX}" STREQUAL "")
set(BUILD_ONLY "core" CACHE INTERNAL "only build core")
set(ENABLE_TESTING OFF CACHE INTERNAL "disabling fmt tests")
FetchContent_Declare(
AWSSDK
GIT_REPOSITORY https://github.com/aws/aws-sdk-cpp
GIT_TAG 1.11.472
OVERRIDE_FIND_PACKAGE
)
FetchContent_MakeAvailable(AWSSDK)
find_package(AWSSDK REQUIRED COMPONENTS core)
install(TARGETS aws-cpp-sdk-core DESTINATION "${SKBUILD_PLATLIB_DIR}")
unset(BUILD_ONLY)
unset(ENABLE_TESTING)
endif()
# ----------------------------- Download Apache Datasketches -------------------------
include(ExternalProject)
ExternalProject_Add(datasketches
GIT_REPOSITORY https://github.com/apache/datasketches-cpp.git
GIT_TAG 5.0.2
GIT_SHALLOW true
GIT_SUBMODULES ""
INSTALL_DIR /tmp/datasketches-prefix
CMAKE_ARGS -DBUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=/tmp/datasketches-prefix
# Override the install command to add DESTDIR
# This is necessary to work around an oddity in the RPM (but not other) package
# generation, as CMake otherwise picks up the Datasketch files when building
# an RPM for a dependent package. (RPM scans the directory for files in addition to installing
# those files referenced in an "install" rule in the cmake file)
INSTALL_COMMAND "${CMAKE_COMMAND}" -E env DESTDIR= ${CMAKE_COMMAND} --build . --target install
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_INSTALL ON
LOG_OUTPUT_ON_FAILURE ON
)
ExternalProject_Get_property(datasketches INSTALL_DIR)
set(datasketches_INSTALL_DIR ${INSTALL_DIR})
message("Source dir of datasketches = ${datasketches_INSTALL_DIR}")
# Add boost as a dependency
find_package(Boost 1.85 REQUIRED COMPONENTS json)
include_directories(${Boost_INCLUDE_DIRS})
# ---------------------------- Set CMake Options -----------------------------
# Use RelWithDebInfo Mode by Default
cmake_print_variables(CMAKE_BUILD_TYPE)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to RelWithDebInfo")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
# Ensure We are Inside a Conda Environment
if (NOT DEFINED ENV{CONDA_PREFIX})
message(FATAL_ERROR "Please activate a Conda Environment before building Bodo")
endif()
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Don't use GCC / Clang Extensions, only C++ Standard
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF)
# Get Pretty Color diagnostics in Ninja and C++ Compiler
# Same as enabling `-fcolor-diagnostics` by default
set(CMAKE_COLOR_DIAGNOSTICS ON)
# Export compile_commands.json for ClangD
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Enable -Werror by Default
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
# Ignore CFLAGS and CXXFLAGS from Conda
set(CMAKE_C_FLAGS "")
set(CMAKE_CXX_FLAGS "")
# Enable Link-Time Optimizations (LTO)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
endif()
# ----------------------- Set Compiler Args for Targets -----------------------
# Default Compiler Args
add_compile_options(
"-Wno-c99-designator" # Check if still necessary?
"-Wno-return-type-c-linkage" # Check if still necessary?
"-Wno-macro-redefined" # Check if still necessary?
"-Wno-implicit-const-int-float-conversion" # Necessary for DataSketches
"-fwrapv" # Conda used to force-add. Remove in follow up PR
"-fstack-protector-strong" # Conda used to force-add. Remove in follow up PR
"-D_FORTIFY_SOURCE=2" # Conda used to force-add. Remove in follow up PR
)
if (LINUX AND X86)
add_compile_options(
# -march=haswell is used to enable AVX2 support (required by SIMD bloom filter implementation)
"-march=haswell"
# Avoid GCC errors for using int64 in allocations
"-Wno-alloc-size-larger-than"
# Avoid GCC errors for unknown pragmas like "region"
"-Wno-error=unknown-pragmas")
endif()
# Debug Compiler Args
if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "DebugSanitize")
add_compile_options(
"-g"
"-O1"
"-fno-omit-frame-pointer"
)
endif()
# Debug with Sanitizer Flags
if (CMAKE_BUILD_TYPE STREQUAL "DebugSanitize")
add_compile_options(
"-fsanitize=address"
"-fsanitize=undefined"
)
add_link_options(
"-fsanitize=address"
"-fsanitize=undefined"
)
endif()
# Release Compiler Args
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_compile_options(
"-O3"
"-ftree-vectorize"
# Encourages LTO & increase obfuscations
$<$<COMPILE_LANGUAGE:CXX>:-fvisibility=hidden>
)
endif()
# ------------------------ Find Libraries + Compilers ------------------------
# Build Package + Program Dependencies
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
find_program(CYTHON_EXECUTABLE "cython" REQUIRED)
# Include for All Targets in General
set(CONDA_INCLUDE_DIR "$ENV{CONDA_PREFIX}/include")
cmake_print_variables(CONDA_INCLUDE_DIR)
set(CONDA_LIB_DIR "$ENV{CONDA_PREFIX}/lib")
cmake_print_variables(CONDA_LIB_DIR)
# This is supposed to work, but isn't. I don't know why
# include_directories(SYSTEM "${CONDA_INCLUDE_DIR}")
# Similarly, the following line doesn't work
# target_include_directories(ext SYSTEM PRIVATE ${CONDA_INCLUDE_DIR})
# In both cases, I'm certain that CMake believes that the directory is included
# But the Ninja file and GCC / Clang command doesn't include the directory
# TODO: Figure out what's going on here
# As an alternative, we can manually construct the generated arguments
# and append to the CMAKE_*_FLAGS variables directly
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem ${CONDA_INCLUDE_DIR}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${CONDA_INCLUDE_DIR}")
# Vendor MPICH
if(DEFINED ENV{BODO_VENDOR_MPICH})
message(STATUS "Downloading MPICH")
execute_process(COMMAND ${Python_EXECUTABLE} -m pip download mpich==${MPICH_VERSION} -i https://pypi.anaconda.org/mpi4py/simple --default-timeout=100)
execute_process(COMMAND unzip "mpich-*.whl" "mpich*.data/*" -d mpich-tmp-extract-dir)
file(GLOB MPICH_DATA_DIR "mpich-tmp-extract-dir/mpich-*.data/data/*")
file(COPY ${MPICH_DATA_DIR} DESTINATION "${SKBUILD_DATA_DIR}" FOLLOW_SYMLINK_CHAIN
FILE_PERMISSIONS OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE GROUP_WRITE)
file(GLOB MPICH_WHEEL "mpich-*.whl")
file(REMOVE_RECURSE ${MPICH_WHEEL} mpich-tmp-extract-dir)
message(STATUS "Moved MPICH to ${SKBUILD_DATA_DIR}")
set(MPICH_INCLUDE_DIR "${SKBUILD_DATA_DIR}/include")
set(MPICH_LIB_DIR "${SKBUILD_DATA_DIR}/lib")
else()
set(MPICH_INCLUDE_DIR "${CONDA_INCLUDE_DIR}")
set(MPICH_LIB_DIR "${CONDA_LIB_DIR}")
endif()
cmake_print_variables(MPICH_INCLUDE_DIR)
# Vendor MPI4Py
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/bodo/mpi4py")
message(STATUS "Copying MPI4Py to Source Directory")
# Extract the location of the site-packages directory containing mpi4py
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c "import mpi4py; print(mpi4py.__path__[0])"
OUTPUT_VARIABLE MPI4PY_PACKAGE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
file(COPY ${MPI4PY_PACKAGE_DIR} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/bodo/")
endif()
message(STATUS "Copying MPI4Py to Bodo Directory")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/bodo/mpi4py" DESTINATION "${SKBUILD_PLATLIB_DIR}/bodo/")
# Find PyArrow Include and Lib Directory
# TODO: Use Arrow Directories from Conda Instead if Available
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c "import pyarrow; print(pyarrow.get_include())"
OUTPUT_VARIABLE PYARROW_INCLUDE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# PyArrow on Pip bundles the Arrow shared libraries, but named as lib*.EXT.VERSION
# I.E. libarrow.so.1700 instead of the expected libarrow.so
# Thus, we need PyArrow to create symlinks to the correct names
# They have a helper function to do this, and it should be a NOOP with PyArrow on Conda
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c "import pyarrow; pyarrow.create_library_symlinks(); print(pyarrow.get_library_dirs()[0])"
OUTPUT_VARIABLE PYARROW_LIB_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
cmake_print_variables(PYARROW_INCLUDE_DIR)
cmake_print_variables(PYARROW_LIB_DIR)
# Numpy Include Directory is provided by scikit-build-core
# through `Python_NumPy_INCLUDE_DIR`
cmake_print_variables(Python_NumPy_INCLUDE_DIR)
# Combine All 2 Includes
set(BASE_INCLUDE_DIRS ${PYARROW_INCLUDE_DIR} ${Python_NumPy_INCLUDE_DIR} ${MPICH_INCLUDE_DIR})
# ------------------------ Cython Target - bodo.io.csv_json_reader -----------------------
add_custom_command(
OUTPUT bodo/io/csv_json_reader.cpp
DEPENDS bodo/io/csv_json_reader.pyx
VERBATIM
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND "${CYTHON_EXECUTABLE}" --cplus -3 --output-file "bodo/io/csv_json_reader.cpp" "bodo/io/csv_json_reader.pyx"
COMMAND "${CMAKE_COMMAND}" -E copy "bodo/io/csv_json_reader.cpp" "${CMAKE_CURRENT_BINARY_DIR}/bodo/io/csv_json_reader.cpp"
COMMENT "Cythonizing Source bodo/io/csv_json_reader.pyx into bodo/io/csv_json_reader.cpp"
)
python_add_library(csv_json_reader
MODULE WITH_SOABI
"bodo/io/_csv_json_reader.cpp"
"bodo/io/csv_json_reader.cpp"
)
target_include_directories(csv_json_reader PRIVATE ${BASE_INCLUDE_DIRS} "${CMAKE_CURRENT_SOURCE_DIR}/bodo/io/" "${CMAKE_CURRENT_BINARY_DIR}/bodo/io/")
target_link_directories(csv_json_reader PRIVATE ${PYARROW_LIB_DIR} ${CONDA_LIB_DIR} ${MPICH_LIB_DIR})
target_link_libraries(csv_json_reader PRIVATE arrow arrow_python mpi)
install(TARGETS csv_json_reader DESTINATION "bodo/io/")
# ------------------------ Cython Target - bodo.io.pyarrow_wrappers ---------------
add_custom_command(
OUTPUT bodo/io/pyarrow_wrappers.cpp
DEPENDS bodo/io/pyarrow_wrappers.pyx
VERBATIM
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND "${CYTHON_EXECUTABLE}" --cplus -3 --output-file "bodo/io/pyarrow_wrappers.cpp" "bodo/io/pyarrow_wrappers.pyx"
COMMAND "${CMAKE_COMMAND}" -E copy "bodo/io/pyarrow_wrappers.cpp" "${CMAKE_CURRENT_BINARY_DIR}/bodo/io/pyarrow_wrappers.cpp"
COMMENT "Cythonizing Source bodo/io/pyarrow_wrappers.pyx into bodo/io/pyarrow_wrappers.cpp"
)
set(pyarrow_wrappers_sources "bodo/io/pyarrow_wrappers.cpp" "bodo/io/arrow_compat.cpp")
python_add_library(pyarrow_wrappers MODULE WITH_SOABI "${pyarrow_wrappers_sources}")
target_include_directories(pyarrow_wrappers PRIVATE ${BASE_INCLUDE_DIRS})
target_link_directories(pyarrow_wrappers PRIVATE ${PYARROW_LIB_DIR} ${CONDA_LIB_DIR} ${MPICH_LIB_DIR})
target_link_libraries(pyarrow_wrappers PRIVATE arrow arrow_python arrow_dataset mpi)
install(TARGETS pyarrow_wrappers DESTINATION "bodo/io/")
# ----------------------- Cython Target - bodo.io._hdfs -----------------------
add_custom_command(
OUTPUT bodo/io/_hdfs.cpp
DEPENDS bodo/io/_hdfs.pyx
VERBATIM
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND "${CYTHON_EXECUTABLE}" --cplus -3 --output-file "bodo/io/_hdfs.cpp" "bodo/io/_hdfs.pyx"
COMMAND cp "bodo/io/_hdfs.cpp" "${CMAKE_CURRENT_BINARY_DIR}/bodo/io/_hdfs.cpp"
COMMENT "Cythonizing Source bodo/io/_hdfs.pyx into bodo/io/_hdfs.cpp"
)
python_add_library(_hdfs MODULE WITH_SOABI "bodo/io/_hdfs.cpp")
target_include_directories(_hdfs PUBLIC ${BASE_INCLUDE_DIRS})
target_link_directories(_hdfs PRIVATE ${PYARROW_LIB_DIR} ${CONDA_LIB_DIR})
target_link_libraries(_hdfs PRIVATE arrow arrow_python)
install(TARGETS _hdfs DESTINATION "bodo/io/")
# ---------------------- Cython Target - bodo.io.tracing ----------------------
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Release"))
set(BODO_DEV_BUILD "1")
else()
set(BODO_DEV_BUILD "0")
endif()
add_custom_command(
OUTPUT bodo/utils/tracing.c
DEPENDS bodo/utils/tracing.pyx
VERBATIM
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND "${CYTHON_EXECUTABLE}" -3 -E "BODO_DEV_BUILD=${BODO_DEV_BUILD}" --output-file "${CMAKE_CURRENT_BINARY_DIR}/bodo/utils/tracing.c" "bodo/utils/tracing.pyx"
COMMENT "Cythonizing Source bodo/utils/tracing.pyx into bodo/utils/tracing.c"
)
python_add_library(tracing MODULE WITH_SOABI "bodo/utils/tracing.c")
target_include_directories(tracing PRIVATE ${MPICH_INCLUDE_DIR})
target_link_directories(tracing PRIVATE ${CONDA_LIB_DIR} ${MPICH_LIB_DIR})
target_link_libraries(tracing PRIVATE mpi)
install(TARGETS tracing DESTINATION "bodo/utils/")
# ---------------------- Cython Target - bodo.memory -----------------------
add_custom_command(
OUTPUT bodo/memory.cpp
DEPENDS bodo/memory.pyx
VERBATIM
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND "${CYTHON_EXECUTABLE}" --cplus -3 --output-file "${CMAKE_CURRENT_BINARY_DIR}/bodo/memory.cpp" "bodo/memory.pyx"
COMMENT "Cythonizing Source bodo/memory.pyx into bodo/memory.cpp"
)
python_add_library(memory MODULE WITH_SOABI "bodo/memory.cpp")
target_include_directories(memory PRIVATE ${BASE_INCLUDE_DIRS} "${CMAKE_CURRENT_SOURCE_DIR}/bodo/")
target_link_directories(memory PRIVATE ${PYARROW_LIB_DIR} ${CONDA_LIB_DIR})
target_link_libraries(memory PRIVATE arrow arrow_python)
install(TARGETS memory DESTINATION "bodo/")
# ---------------------- Cython Target - bodo.tests.memory_tester -----------------------
add_custom_command(
OUTPUT bodo/tests/memory_tester.cpp
DEPENDS bodo/tests/memory_tester.pyx
VERBATIM
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND "${CYTHON_EXECUTABLE}" --cplus -3 --output-file "${CMAKE_CURRENT_BINARY_DIR}/bodo/tests/memory_tester.cpp" "bodo/tests/memory_tester.pyx"
COMMENT "Cythonizing Source bodo/tests/memory_tester.pyx into bodo/tests/memory_tester.cpp"
)
python_add_library(
memory_tester
MODULE WITH_SOABI
"bodo/tests/memory_tester.cpp"
"bodo/libs/_memory.cpp"
"bodo/libs/_operator_pool.cpp"
"bodo/libs/_utils.cpp"
"bodo/libs/_storage_manager.cpp"
"bodo/libs/_memory_budget.cpp"
)
target_include_directories(memory_tester PRIVATE ${BASE_INCLUDE_DIRS} "${CMAKE_CURRENT_SOURCE_DIR}/bodo/tests/")
target_link_directories(memory_tester PRIVATE ${PYARROW_LIB_DIR} ${CONDA_LIB_DIR} ${MPICH_LIB_DIR})
target_link_libraries(memory_tester PRIVATE mpi arrow arrow_python fmt::fmt)
if(NOT(CMAKE_BUILD_TYPE STREQUAL "Release"))
target_compile_definitions(
memory_tester
PRIVATE
# Required when using boost::stacktrace for debugging
"BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED=1"
)
endif()
install(TARGETS memory_tester DESTINATION "bodo/tests/")
# ---------------------- Cython Target - bodo.transforms.type_inference.native_typer -----------------------
add_custom_command(
OUTPUT bodo/transforms/type_inference/native_typer.cpp
DEPENDS bodo/transforms/type_inference/native_typer.pyx
VERBATIM
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND "${CYTHON_EXECUTABLE}" --cplus -3 --output-file "${CMAKE_CURRENT_BINARY_DIR}/bodo/transforms/type_inference/native_typer.cpp" "bodo/transforms/type_inference/native_typer.pyx"
COMMENT "Cythonizing Source bodo/transforms/type_inference/native_typer.pyx into bodo/transforms/type_inference/native_typer.cpp"
)
python_add_library(
native_typer
MODULE WITH_SOABI
"bodo/transforms/type_inference/native_typer.cpp"
"bodo/transforms/type_inference/type.cpp"
"bodo/transforms/type_inference/typeinfer.cpp"
"bodo/transforms/type_inference/ir.cpp"
)
target_include_directories(native_typer PRIVATE ${BASE_INCLUDE_DIRS} "${CMAKE_CURRENT_SOURCE_DIR}/bodo/transforms/type_inference/" "${CMAKE_CURRENT_BINARY_DIR}/bodo/transforms/type_inference/")
target_link_directories(native_typer PRIVATE ${CONDA_LIB_DIR})
target_link_libraries(native_typer PRIVATE fmt::fmt)
install(TARGETS native_typer DESTINATION "bodo/transforms/type_inference/")
# ------------------------- Main Bodo Extension -------------------------
set(sources_list
"bodo/io/_csv_json_writer.cpp"
"bodo/io/_fs_io.cpp"
"bodo/io/_hdfs_reader.cpp"
"bodo/io/_io.cpp"
"bodo/io/_s3_reader.cpp"
"bodo/io/arrow.cpp"
"bodo/io/arrow_reader.cpp"
"bodo/io/iceberg_parquet_reader.cpp"
"bodo/io/iceberg_parquet_write.cpp"
"bodo/io/json_col_parser.cpp"
"bodo/io/parquet_reader.cpp"
"bodo/io/parquet_write.cpp"
"bodo/io/snowflake_reader.cpp"
"bodo/io/timestamptz_parser.cpp"
"bodo/io/arrow_compat.cpp"
"bodo/io/iceberg_helpers.cpp"
"bodo/libs/_array.cpp"
"bodo/libs/_array_build_buffer.cpp"
"bodo/libs/_array_hash.cpp"
"bodo/libs/_array_operations.cpp"
"bodo/libs/_array_utils.cpp"
"bodo/libs/_base64.cpp"
"bodo/libs/_bodo_common.cpp"
"bodo/libs/_bodo_tdigest.cpp"
"bodo/libs/_bodo_to_arrow.cpp"
"bodo/libs/_datetime_ext.cpp"
"bodo/libs/_datetime_utils.cpp"
"bodo/libs/_decimal_ext.cpp"
"bodo/libs/_distributed.cpp"
"bodo/libs/groupby/_groupby.cpp"
"bodo/libs/groupby/_groupby_agg_funcs.cpp"
"bodo/libs/groupby/_groupby_col_set.cpp"
"bodo/libs/groupby/_groupby_common.cpp"
"bodo/libs/groupby/_groupby_do_apply_to_column.cpp"
"bodo/libs/groupby/_groupby_eval.cpp"
"bodo/libs/groupby/_groupby_ftypes.cpp"
"bodo/libs/groupby/_groupby_groups.cpp"
"bodo/libs/groupby/_groupby_mode.cpp"
"bodo/libs/groupby/_groupby_mpi_exscan.cpp"
"bodo/libs/groupby/_groupby_update.cpp"
"bodo/libs/_hash_join.cpp"
"bodo/libs/_nested_loop_join_impl.cpp"
"bodo/libs/_nested_loop_join.cpp"
"bodo/libs/_interval_join.cpp"
"bodo/libs/_join_hashing.cpp"
"bodo/libs/_lead_lag.cpp"
"bodo/libs/_crypto_funcs.cpp"
"bodo/libs/_memory.cpp"
"bodo/libs/_memory_budget.cpp"
"bodo/libs/_memory_budget_pymod.cpp"
"bodo/libs/vendored/_murmurhash3.cpp"
"bodo/libs/_quantile_alg.cpp"
"bodo/libs/_lateral.cpp"
"bodo/libs/_shuffle.cpp"
"bodo/libs/_str_ext.cpp"
"bodo/libs/iceberg_transforms.cpp"
"bodo/libs/streaming/_join.cpp"
"bodo/libs/streaming/_nested_loop_join.cpp"
"bodo/libs/streaming/_groupby.cpp"
"bodo/libs/streaming/_sort.cpp"
"bodo/libs/streaming/_window.cpp"
"bodo/libs/_dict_builder.cpp"
"bodo/libs/_table_builder_utils.cpp"
"bodo/libs/_table_builder.cpp"
"bodo/libs/_chunked_table_builder.cpp"
"bodo/libs/_listagg.cpp"
"bodo/libs/_operator_pool.cpp"
"bodo/libs/window/_window_aggfuncs.cpp"
"bodo/libs/window/_window_calculator.cpp"
"bodo/libs/window/_window_compute.cpp"
"bodo/libs/streaming/_dict_encoding.cpp"
"bodo/libs/streaming/_shuffle.cpp"
"bodo/libs/_storage_manager.cpp"
"bodo/libs/_utils.cpp"
"bodo/libs/_uuid.cpp"
"bodo/libs/_query_profile_collector.cpp"
"bodo/libs/_pymemory.cpp"
"bodo/libs/_theta_sketches.cpp"
"bodo/libs/_puffin.cpp"
"bodo/libs/_io_cpu_thread_pool.cpp"
)
if (BUILD_WITH_V8)
set(sources_list "${sources_list}"
"bodo/libs/_javascript_udf.cpp")
endif()
# Some files cannot be compiled with -Werror=implict-fallthrough, but we want
# the flag to be enabled for most files, so we create an exclude list of files
# that are incomptible
set(allow_implicit_fallthrough_list
"bodo/io/arrow.cpp"
"bodo/io/iceberg_parquet_write.cpp"
"bodo/libs/_puffin.cpp"
"bodo/libs/_theta_sketches.cpp"
"bodo/libs/vendored/_murmurhash3.cpp"
)
# TODO: Replace with ctest when integrating Catch2
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Release") AND NOT DEFINED ENV{BODO_SKIP_CPP_TESTS})
set(test_list
"bodo/tests/test_framework.cpp"
"bodo/tests/test_example.cpp"
"bodo/tests/test_external_sort.cpp"
"bodo/tests/test_dict_builder.cpp"
"bodo/tests/test_groupby_common.cpp"
"bodo/tests/test_groupby.cpp"
"bodo/tests/test_window.cpp"
"bodo/tests/test_json_col_reader.cpp"
"bodo/tests/test_memory_budget.cpp"
"bodo/tests/test_pinnable.cpp"
"bodo/tests/test_schema.cpp"
"bodo/tests/test_table_builder.cpp"
"bodo/tests/test_table_generator.cpp"
"bodo/tests/test_test_framework.cpp"
"bodo/tests/test_timestamptz_parser.cpp"
"bodo/tests/test_nested_array.cpp"
"bodo/tests/test_streaming/test_shuffle.cpp"
"bodo/tests/test_streaming/test_groupby_shuffle.cpp"
"bodo/tests/test_timestamptz_array.cpp"
"bodo/tests/test_query_profile_collector.cpp"
"bodo/tests/test_theta_sketches.cpp"
"bodo/tests/test_puffin.cpp"
"bodo/tests/test_iceberg/test_iceberg_rest_aws_credentials_provider.cpp"
"bodo/tests/test_sorted_window_computation.cpp"
"bodo/tests/test_thread_pool.cpp"
"bodo/tests/test_datatypes.cpp"
)
if (BUILD_WITH_V8)
set(test_list "${test_list}"
"bodo/tests/test_javascript.cpp"
)
endif()
list(APPEND sources_list "${test_list}")
list(APPEND allow_implicit_fallthrough_list
"bodo/tests/test_puffin.cpp"
"bodo/tests/test_theta_sketches.cpp")
endif()
if("$ENV{NO_HDF5}" STREQUAL "1")
set(NO_HDF5 TRUE)
else()
list(APPEND sources_list "bodo/io/_hdf5.cpp")
set(NO_HDF5 FALSE)
endif()
cmake_print_variables(NO_HDF5)
python_add_library(ext MODULE WITH_SOABI "${sources_list}")
# Dependency Includes Are `-isystem` to Suppress Warnings
target_include_directories(ext SYSTEM PRIVATE ${BASE_INCLUDE_DIRS})
target_link_directories(ext PRIVATE ${CONDA_LIB_DIR} ${MPICH_LIB_DIR})
if (CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_options(ext PRIVATE "-Wno-unknown-pragmas")
elseif (DEFINED ENV{BODO_SKIP_CPP_TESTS})
# Remove the IS_TESTING flag.
target_compile_definitions(
ext
PRIVATE
# Required when using boost::stacktrace for debugging
"BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED=1"
)
else()
target_compile_definitions(
ext
PRIVATE
# Required when using boost::stacktrace for debugging
"BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED=1"
"IS_TESTING=1"
)
endif()
# Enable erroring on implicit fallthrough in switch/case statements this is
# critical because we use switch/case statements to handle variants of code for
# different array types in a lot of places.
list(APPEND error_on_fallthrough ${sources_list})
# TODO(aneesh) [BSE-3514] avoid having files exempt from implicit-fallthrough
list(REMOVE_ITEM error_on_fallthrough ${allow_implicit_fallthrough_list})
SET_SOURCE_FILES_PROPERTIES(
${error_on_fallthrough}
PROPERTIES
COMPILE_FLAGS "-Werror=implicit-fallthrough"
)
# This file includes pyarrow_wrappers_api.h which is generated by Cython
# and the compiler can't tell that the functions are used
SET_SOURCE_FILES_PROPERTIES(
"bodo/io/arrow_compat.cpp"
PROPERTIES
COMPILE_FLAGS "-Wno-unused-function"
)
target_compile_options(
ext
PRIVATE
# -fno-strict-aliasing required by bloom filter implementation (see comment
# in simd-block-fixed-fpp.h about violating strict aliasing rules)
"-fno-strict-aliasing"
"-Wall"
)
target_link_directories(ext PRIVATE ${PYARROW_LIB_DIR} "${Python_NumPy_INCLUDE_DIR}/../lib")
target_include_directories(ext PRIVATE ${datasketches_INSTALL_DIR}/include/DataSketches)
target_link_libraries(ext PRIVATE
pthread
npymath
mpi
arrow
arrow_python
arrow_dataset
parquet
fmt::fmt
zstd
aws-cpp-sdk-core
${Boost_LIBRARIES}
)
set(IS_PLATFORM "$ENV{IS_BODO_PLATFORM}")
cmake_print_variables(IS_PLATFORM)
# Build with our fork of Arrow
if (IS_PLATFORM OR DEFINED ENV{USE_BODO_ARROW_FORK})
target_compile_definitions(ext PRIVATE "USE_BODO_ARROW_FORK=1")
endif()
if (BUILD_WITH_V8)
message(STATUS "Building with V8")
target_link_libraries(ext PRIVATE
v8_libbase
v8_libplatform
v8_base_without_compiler
v8_compiler
v8_initializers
v8-bytecodes-builtin-list
v8_torque_generated
v8_snapshot
v8_libsampler
dl)
target_include_directories(ext PRIVATE "${v8_SOURCE_DIR}/v8")
target_compile_definitions(ext PRIVATE "BUILD_WITH_V8=1")
endif()
if(NO_HDF5)
target_compile_definitions(ext PRIVATE "NO_HDF5=1")
else()
target_link_libraries(ext PRIVATE hdf5)
endif()
set_target_properties(ext PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
add_dependencies(ext csv_json_reader _hdfs tracing pyarrow_wrappers datasketches)
install(TARGETS ext DESTINATION "bodo/")