-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
765 lines (676 loc) · 24.4 KB
/
CMakeLists.txt
File metadata and controls
765 lines (676 loc) · 24.4 KB
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
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.28)
message(STATUS "Building using CMake version: ${CMAKE_VERSION}")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS ON) # Big Int is an extension
message(STATUS "CXX standard: ${CMAKE_CXX_STANDARD}")
# The policy allows us to change options without caching.
cmake_policy(SET CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
# Sets new behavior for CMP0135, which controls how timestamps are extracted
# when using ExternalProject_Add():
# https://cmake.org/cmake/help/latest/policy/CMP0135.html
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
endif()
# Set the project name.
project(velox)
# If we are in an active conda env disable search in system paths and add env to
# prefix path
if(DEFINED ENV{CONDA_PREFIX})
if(NOT DEFINED ENV{VELOX_DEPENDENCY_SOURCE} OR "$ENV{VELOX_DEPENDENCY_SOURCE}" STREQUAL "CONDA")
message(STATUS "Using Conda environment: $ENV{CONDA_PREFIX}")
set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE)
list(APPEND CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}")
# Override in case it was set to CONDA
set(ENV{VELOX_DEPENDENCY_SOURCE} AUTO)
elseif(
DEFINED ENV{VELOX_DEPENDENCY_SOURCE}
AND NOT "$ENV{VELOX_DEPENDENCY_SOURCE}" STREQUAL "CONDA"
)
message(STATUS "Overriding Conda environment: $ENV{CONDA_PREFIX}")
endif()
endif()
if(DEFINED ENV{INSTALL_PREFIX})
message(STATUS "Dependency install directory set to: $ENV{INSTALL_PREFIX}")
list(APPEND CMAKE_PREFIX_PATH "$ENV{INSTALL_PREFIX}")
endif()
list(
PREPEND
CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/CMake"
"${PROJECT_SOURCE_DIR}/CMake/third-party"
)
# Include our ThirdPartyToolchain dependencies macros
include(ResolveDependency)
include(VeloxUtils)
include(CMakeDependentOption)
velox_set_with_default(VELOX_DEPENDENCY_SOURCE_DEFAULT VELOX_DEPENDENCY_SOURCE AUTO)
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
# Add all options below
option(
VELOX_BUILD_TESTING
"Enable Velox tests. This will enable all other build options automatically."
ON
)
option(
VELOX_BUILD_MINIMAL
"Build a minimal set of components only. This will override other build options."
OFF
)
option(
VELOX_BUILD_MINIMAL_WITH_DWIO
"Build a minimal set of components, including DWIO (file format readers/writers).
This will override other build options."
OFF
)
option(VELOX_MONO_LIBRARY "Build single unified library." ON)
option(ENABLE_ALL_WARNINGS "Enable -Wall and -Wextra compiler warnings." ON)
option(VELOX_BUILD_SHARED "Build Velox as shared libraries." OFF)
option(VELOX_BUILD_CMAKE_PACKAGE "Build CMake package for Velox." OFF)
option(VELOX_SKIP_WAVE_BRANCH_KERNEL_TEST "Disable Wave branch kernel test." OFF)
# While it's possible to build both in one go we currently want to build either
# static or shared.
cmake_dependent_option(
VELOX_BUILD_STATIC
"Build Velox as static libraries."
ON
"NOT VELOX_BUILD_SHARED"
OFF
)
if(VELOX_BUILD_SHARED AND NOT VELOX_MONO_LIBRARY)
# The large number of targets currently in use within Velox make a shared
# build when not using the mono library brittle and labor intensive
set(VELOX_MONO_LIBRARY ON)
endif()
if(VELOX_BUILD_SHARED)
message(
WARNING
"When building Velox as a shared library it's recommended to build against a shared build of folly to avoid issues with linking of gflags. "
"This is currently NOT being enforced so user discretion is advised."
)
endif()
# option() always creates a BOOL variable so we have to use a normal cache
# variable with STRING type for this option.
#
# * AUTO: Try SYSTEM first fall back to BUNDLED.
# * SYSTEM: Use installed dependencies via find_package.
# * BUNDLED: Build dependencies from source.
set(
VELOX_DEPENDENCY_SOURCE
${VELOX_DEPENDENCY_SOURCE_DEFAULT}
CACHE STRING
"Default source for all dependencies with source builds enabled: AUTO SYSTEM BUNDLED."
)
set(
VELOX_GFLAGS_TYPE
"shared"
CACHE STRING
"Specify whether to find the gflags package as a shared or static package"
)
option(VELOX_ENABLE_EXEC "Build exec." ON)
option(VELOX_ENABLE_AGGREGATES "Build aggregates." ON)
option(VELOX_ENABLE_HIVE_CONNECTOR "Build Hive connector." ON)
option(VELOX_ENABLE_TPCH_CONNECTOR "Build TPC-H connector." ON)
option(VELOX_ENABLE_TPCDS_CONNECTOR "Build TPC-DS connector." ON)
option(VELOX_ENABLE_PRESTO_FUNCTIONS "Build Presto SQL functions." ON)
option(VELOX_ENABLE_SPARK_FUNCTIONS "Build Spark SQL functions." ON)
option(VELOX_ENABLE_ICEBERG_FUNCTIONS "Build Iceberg functions." ON)
option(VELOX_ENABLE_EXPRESSION "Build expression." ON)
option(
VELOX_ENABLE_EXAMPLES
"Build examples. This will enable VELOX_ENABLE_EXPRESSION automatically."
OFF
)
option(VELOX_ENABLE_BENCHMARKS "Enable Velox top level benchmarks." OFF)
option(VELOX_ENABLE_BENCHMARKS_BASIC "Enable Velox basic benchmarks." OFF)
option(VELOX_ENABLE_S3 "Build S3 Connector" OFF)
option(VELOX_ENABLE_GCS "Build GCS Connector" OFF)
option(VELOX_ENABLE_ABFS "Build Abfs Connector" OFF)
option(VELOX_ENABLE_HDFS "Build Hdfs Connector" OFF)
option(VELOX_ENABLE_PARQUET "Enable Parquet support" ON)
option(VELOX_ENABLE_ARROW "Enable Arrow support" OFF)
option(VELOX_ENABLE_GEO "Enable Geospatial support" ON)
option(VELOX_ENABLE_REMOTE_FUNCTIONS "Enable remote function support" OFF)
option(VELOX_ENABLE_CCACHE "Use ccache if installed." ON)
option(VELOX_ENABLE_COMPRESSION_LZ4 "Enable Lz4 compression support." OFF)
option(VELOX_BUILD_TEST_UTILS "Builds Velox test utilities" OFF)
option(VELOX_BUILD_VECTOR_TEST_UTILS "Builds Velox vector test utilities" OFF)
option(VELOX_BUILD_PYTHON_PACKAGE "Builds Velox Python bindings" OFF)
option(VELOX_PYTHON_LEGACY_ONLY "Build only the pyvelox module" OFF)
option(VELOX_BUILD_RUNNER "Builds velox runner" ON)
option(
VELOX_ENABLE_INT64_BUILD_PARTITION_BOUND
"make buildPartitionBounds_ a vector int64 instead of int32 to avoid integer overflow when the hashtable has billions of records"
OFF
)
option(VELOX_SIMDJSON_SKIPUTF8VALIDATION "Skip simdjson utf8 validation in JSON parsing" OFF)
option(VELOX_ENABLE_FAISS "Build faiss vector search support" OFF)
# Explicitly force compilers to generate colored output. Compilers usually do
# this by default if they detect the output is a terminal, but this assumption
# is broken if you use ninja.
option(VELOX_FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." OFF)
if(${VELOX_BUILD_MINIMAL} OR ${VELOX_BUILD_MINIMAL_WITH_DWIO})
# Enable and disable components for velox base build
set(VELOX_BUILD_TESTING OFF)
set(VELOX_ENABLE_PRESTO_FUNCTIONS ON)
set(VELOX_ENABLE_EXPRESSION ON)
set(VELOX_ENABLE_EXEC OFF)
set(VELOX_ENABLE_AGGREGATES OFF)
set(VELOX_ENABLE_HIVE_CONNECTOR OFF)
set(VELOX_ENABLE_TPCH_CONNECTOR OFF)
set(VELOX_ENABLE_TPCDS_CONNECTOR OFF)
set(VELOX_ENABLE_SPARK_FUNCTIONS OFF)
set(VELOX_ENABLE_EXAMPLES OFF)
set(VELOX_ENABLE_S3 OFF)
set(VELOX_ENABLE_GCS OFF)
set(VELOX_ENABLE_ABFS OFF)
else()
if(VELOX_BUILD_CMAKE_PACKAGE)
message(
FATAL_ERROR
"VELOX_BUILD_CMAKE_PACKAGE is only available with "
"VELOX_BUILD_MINIMAL=ON or VELOX_BUILD_MINIMAL_WITH_DWIO=ON for now."
)
endif()
endif()
if(${VELOX_ENABLE_BENCHMARKS})
set(VELOX_ENABLE_BENCHMARKS_BASIC ON)
endif()
if(VELOX_ENABLE_BENCHMARKS_BASIC)
set(VELOX_BUILD_TEST_UTILS ON)
endif()
if(VELOX_ENABLE_CUDF)
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message(FATAL_ERROR "cuDF requires GCC. Found ${CMAKE_CXX_COMPILER_ID}.")
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.3)
message(FATAL_ERROR "cuDF requires GCC >= 13.3. Found GCC ${CMAKE_CXX_COMPILER_VERSION}.")
endif()
message(STATUS "Building curl from source to satisfy cuDF curl version requirement")
set(CURL_SOURCE BUNDLED)
velox_resolve_dependency(CURL)
endif()
if(VELOX_BUILD_TESTING OR VELOX_BUILD_TEST_UTILS)
# cuDF bundles curl since it needs a specific version.
# Use bundled or system curl otherwise.
if(NOT VELOX_ENABLE_CUDF)
velox_set_source(CURL)
velox_resolve_dependency(CURL)
endif()
set(VELOX_ENABLE_DUCKDB ON)
set(VELOX_ENABLE_PARSE ON)
endif()
if(${VELOX_BUILD_TESTING} OR ${VELOX_BUILD_MINIMAL_WITH_DWIO} OR ${VELOX_ENABLE_HIVE_CONNECTOR})
set(VELOX_ENABLE_COMPRESSION_LZ4 ON)
endif()
if(${VELOX_ENABLE_EXAMPLES})
set(VELOX_ENABLE_EXPRESSION ON)
endif()
if(${VELOX_BUILD_PYTHON_PACKAGE})
set(VELOX_ENABLE_PRESTO_FUNCTIONS ON)
set(VELOX_ENABLE_DUCKDB ON)
set(VELOX_ENABLE_EXPRESSION ON)
set(VELOX_ENABLE_PARSE ON)
set(VELOX_ENABLE_EXEC ON)
set(VELOX_ENABLE_AGGREGATES ON)
set(VELOX_ENABLE_SPARK_FUNCTIONS ON)
if(NOT VELOX_PYTHON_LEGACY_ONLY)
set(VELOX_BUILD_RUNNER OFF)
set(VELOX_BUILD_TEST_UTILS ON) # required for velox_exec_test_lib
endif()
endif()
if(${VELOX_ENABLE_DUCKDB})
velox_set_source(DuckDB)
velox_resolve_dependency(DuckDB)
endif()
if(VELOX_ENABLE_FAISS)
velox_set_source(faiss)
velox_resolve_dependency(faiss)
if(NOT TARGET FAISS::faiss)
add_library(FAISS::faiss ALIAS faiss)
endif()
endif()
if(DEFINED ENV{INSTALL_PREFIX})
# Allow installed package headers to be picked up before brew/system package
# headers. We set this after DuckDB bundling since DuckDB uses its own
# dependencies.
include_directories(BEFORE "$ENV{INSTALL_PREFIX}/include")
endif()
# We look for OpenSSL here to cache the result enforce the version across our
# dependencies.
find_package(OpenSSL REQUIRED)
if(
VELOX_ENABLE_CCACHE
AND NOT CMAKE_C_COMPILER_LAUNCHER
AND NOT CMAKE_CXX_COMPILER_LAUNCHER
AND NOT CMAKE_CUDA_COMPILER_LAUNCHER
)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
message(STATUS "Using ccache: ${CCACHE_FOUND}")
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_FOUND})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_FOUND})
set(CMAKE_CUDA_COMPILER_LAUNCHER ${CCACHE_FOUND})
# keep comments as they might matter to the compiler
set(ENV{CCACHE_COMMENTS} "1")
endif()
endif()
if(${VELOX_FORCE_COLORED_OUTPUT})
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()
endif()
if(VELOX_ENABLE_S3)
# Set AWS_ROOT_DIR if you have a custom install location of AWS SDK CPP.
if(AWSSDK_ROOT_DIR)
list(APPEND CMAKE_PREFIX_PATH ${AWSSDK_ROOT_DIR})
endif()
find_package(AWSSDK 1.11.654 REQUIRED COMPONENTS s3;identity-management)
add_definitions(-DVELOX_ENABLE_S3)
endif()
if(VELOX_ENABLE_ABFS)
# Set AZURESDK_ROOT_DIR if you have a custom install location of Azure Storage
# SDK CPP.
if(AZURESDK_ROOT_DIR)
list(APPEND CMAKE_PREFIX_PATH ${AZURESDK_ROOT_DIR})
endif()
# files-datalake is built on blobs
find_package(azure-storage-files-datalake-cpp CONFIG REQUIRED)
find_package(azure-identity-cpp CONFIG REQUIRED)
add_definitions(-DVELOX_ENABLE_ABFS)
endif()
if(VELOX_ENABLE_HDFS)
add_definitions(-DVELOX_ENABLE_HDFS)
# JVM libhdfs requires arrow dependency.
set(VELOX_ENABLE_ARROW ON)
endif()
if(VELOX_ENABLE_PARQUET)
add_definitions(-DVELOX_ENABLE_PARQUET)
# Native Parquet reader requires Apache Thrift and Arrow Parquet writer, which
# are included in Arrow.
set(VELOX_ENABLE_ARROW ON)
endif()
# make buildPartitionBounds_ a vector int64 instead of int32 to avoid integer
# overflow
if(${VELOX_ENABLE_INT64_BUILD_PARTITION_BOUND})
add_compile_definitions(VELOX_ENABLE_INT64_BUILD_PARTITION_BOUND)
endif()
# MacOSX enables two-level namespace by default:
# http://mirror.informatimago.com/next/developer.apple.com/releasenotes/DeveloperTools/TwoLevelNamespaces.html
# Enables -flat_namespace so type_info can be deduplicated across .so boundaries
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_link_options("-Wl,-flat_namespace")
endif()
if(UNIX AND NOT APPLE)
# linker flags, -export-dynamic for rtti
add_link_options("-Wl,-export-dynamic")
endif()
# Required so velox code can be used in a dynamic library
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
# For C++20 support we need GNU GCC11 (or later versions) or Clang/AppleClang 15
# (or later versions) to get support for the used features.
if(
NOT
(
(
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"
AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 11
)
OR
(
(
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"
OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang"
)
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15
)
)
)
message(
FATAL_ERROR
"Unsupported compiler ${CMAKE_CXX_COMPILER_ID} with version ${CMAKE_CXX_COMPILER_VERSION} found."
)
endif()
execute_process(
COMMAND
bash -c
"( source ${CMAKE_CURRENT_SOURCE_DIR}/scripts/setup-helper-functions.sh && echo -n $(get_cxx_flags $ENV{CPU_TARGET}))"
OUTPUT_VARIABLE SCRIPT_CXX_FLAGS
RESULT_VARIABLE COMMAND_STATUS
)
if(COMMAND_STATUS EQUAL "1")
message(FATAL_ERROR "Unable to determine compiler flags!")
endif()
message("Setting CMAKE_CXX_FLAGS=${SCRIPT_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SCRIPT_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D USE_VELOX_COMMON_BASE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D HAS_UNCAUGHT_EXCEPTIONS")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char")
endif()
# Under Ninja, we are able to designate certain targets large enough to require
# restricted parallelism.
if("${MAX_HIGH_MEM_JOBS}")
set_property(GLOBAL PROPERTY JOB_POOLS "high_memory_pool=${MAX_HIGH_MEM_JOBS}")
else()
set_property(GLOBAL PROPERTY JOB_POOLS high_memory_pool=1000)
endif()
if("${MAX_LINK_JOBS}")
set_property(GLOBAL APPEND PROPERTY JOB_POOLS "link_job_pool=${MAX_LINK_JOBS}")
set(CMAKE_JOB_POOL_LINK link_job_pool)
endif()
if(ENABLE_ALL_WARNINGS)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(
KNOWN_COMPILER_SPECIFIC_WARNINGS
"-Wno-range-loop-analysis \
-Wno-mismatched-tags \
-Wno-nullability-completeness"
)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(
KNOWN_COMPILER_SPECIFIC_WARNINGS
"-Wno-implicit-fallthrough \
-Wno-class-memaccess \
-Wno-comment \
-Wno-int-in-bool-context \
-Wno-redundant-move \
-Wno-array-bounds \
-Wno-maybe-uninitialized \
-Wno-unused-result \
-Wno-format-overflow \
-Wno-strict-aliasing"
)
# Avoid compiler bug for GCC 12.2.1
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329
if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "12.2.1")
string(APPEND KNOWN_COMPILER_SPECIFIC_WARNINGS " -Wno-restrict")
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "14.0.0")
string(APPEND KNOWN_COMPILER_SPECIFIC_WARNINGS " -Wno-error=template-id-cdtor")
string(APPEND KNOWN_COMPILER_SPECIFIC_WARNINGS " -Wno-overloaded-virtual")
string(APPEND KNOWN_COMPILER_SPECIFIC_WARNINGS " -Wno-error=tautological-compare")
endif()
endif()
set(
KNOWN_WARNINGS
"-Wno-unused \
-Wno-unused-parameter \
-Wno-sign-compare \
-Wno-ignored-qualifiers \
${KNOWN_COMPILER_SPECIFIC_WARNINGS}"
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra ${KNOWN_WARNINGS}")
endif()
if(VELOX_ENABLE_WAVE OR VELOX_ENABLE_CUDF)
enable_language(CUDA)
# Determine CUDA_ARCHITECTURES automatically.
cmake_policy(SET CMP0104 NEW)
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
# it will fail later in the build otherwise
message(FATAL_ERROR "-DCMAKE_CUDA_ARCHITECTURES= must be set")
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(VELOX_CUDA_DEBUG_FLAGS "$<$<COMPILE_LANGUAGE:CUDA>:-G>")
endif()
find_package(CUDAToolkit REQUIRED)
# Suppress deprecated GPU targets warning for CUDA 12.8.x
if(
CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 12.8.0
AND CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 13.0.0
)
string(APPEND CMAKE_CUDA_FLAGS " -Wno-deprecated-gpu-targets")
endif()
if(VELOX_ENABLE_CUDF)
foreach(arch ${CMAKE_CUDA_ARCHITECTURES})
if(arch LESS 70)
message(
FATAL_ERROR
"CUDA architecture ${arch} is below 70. CUDF requires Volta (SM 70) or newer GPUs."
)
endif()
endforeach()
set(VELOX_ENABLE_ARROW ON)
velox_set_source(cudf)
velox_resolve_dependency(cudf)
if(TARGET aws-cpp-sdk-core)
# Fix for AWS SDK CPP using hardcoded system curl instead of soft link to curl
get_target_property(override_curl_lib aws-cpp-sdk-core INTERFACE_LINK_LIBRARIES)
list(REMOVE_ITEM override_curl_lib "/usr/lib64/libcurl.so")
list(APPEND override_curl_lib "\$<LINK_ONLY:CURL::libcurl>")
set_target_properties(
aws-cpp-sdk-core
PROPERTIES INTERFACE_LINK_LIBRARIES "${override_curl_lib}"
)
endif()
endif()
endif()
# Set after the test of the CUDA compiler. Otherwise, the test fails with
# -latomic not found because it is added right after the compiler exe.
if(
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"
AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER_EQUAL 15
)
set(CMAKE_EXE_LINKER_FLAGS "-latomic")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
execute_process(
COMMAND brew --prefix icu4c
RESULT_VARIABLE BREW_ICU4C
OUTPUT_VARIABLE BREW_ICU4C_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(BREW_ICU4C EQUAL 0 AND EXISTS "${BREW_ICU4C_PREFIX}")
message(STATUS "Found icu4c installed by Homebrew at ${BREW_ICU4C_PREFIX}")
list(APPEND CMAKE_PREFIX_PATH "${BREW_ICU4C_PREFIX}")
else()
list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/icu4c")
endif()
endif()
velox_set_source(ICU)
velox_resolve_dependency(
ICU
COMPONENTS data i18n io uc tu
)
set(
BOOST_INCLUDE_LIBRARIES
atomic
context
date_time
filesystem
program_options
regex
system
thread
)
velox_set_source(Boost)
velox_resolve_dependency(Boost 1.77.0 COMPONENTS ${BOOST_INCLUDE_LIBRARIES})
velox_set_source(gflags)
velox_resolve_dependency(gflags COMPONENTS ${VELOX_GFLAGS_TYPE})
if(NOT TARGET gflags::gflags)
# This is a bit convoluted, but we want to be able to use gflags::gflags as a
# target even when velox is built as a subproject which uses
# `find_package(gflags)` which does not create a globally imported target that
# we can ALIAS.
add_library(gflags::gflags ALIAS gflags)
endif()
if(${gflags_SOURCE} STREQUAL "BUNDLED")
# Allow explicit glog_SOURCE override (e.g. when system glog is built
# against the same gflags version as BUNDLED).
if(DEFINED ENV{glog_SOURCE})
set(glog_SOURCE $ENV{glog_SOURCE})
else()
set(glog_SOURCE BUNDLED)
endif()
else()
set(glog_SOURCE SYSTEM)
endif()
velox_resolve_dependency(glog)
velox_set_source(fmt)
velox_resolve_dependency(fmt 9.0.0)
if(VELOX_ENABLE_COMPRESSION_LZ4)
find_package(lz4 REQUIRED)
endif()
if(${VELOX_BUILD_MINIMAL_WITH_DWIO} OR ${VELOX_ENABLE_HIVE_CONNECTOR})
# DWIO needs all sorts of stream compression libraries.
#
# TODO: make these optional and pluggable.
find_package(ZLIB REQUIRED)
find_package(zstd REQUIRED)
find_package(Snappy REQUIRED)
# Ensure zstd::zstd target exists - handle different zstd package configurations
if(NOT TARGET zstd::zstd)
if(TARGET zstd::libzstd_static)
add_library(zstd::zstd ALIAS zstd::libzstd_static)
elseif(TARGET zstd::libzstd_shared)
add_library(zstd::zstd ALIAS zstd::libzstd_shared)
else()
# Fallback: use Findzstd.cmake to create the target
include(Findzstd)
endif()
endif()
endif()
velox_set_source(re2)
velox_resolve_dependency(re2)
if(${VELOX_BUILD_PYTHON_PACKAGE})
find_package(Python 3.9 COMPONENTS Interpreter Development.Module REQUIRED)
velox_set_source(pybind11)
velox_resolve_dependency(pybind11 2.10.0)
endif()
# DWIO (ORC/DWRF) depends on protobuf.
if(${VELOX_BUILD_MINIMAL_WITH_DWIO} OR ${VELOX_ENABLE_HIVE_CONNECTOR} OR VELOX_ENABLE_GCS)
# Locate or build protobuf.
velox_set_source(Protobuf)
velox_resolve_dependency(Protobuf 3.21.7 REQUIRED)
include_directories(${Protobuf_INCLUDE_DIRS})
endif()
velox_set_source(simdjson)
velox_resolve_dependency(simdjson 4.1.0)
velox_set_source(FastFloat)
velox_resolve_dependency(FastFloat)
velox_set_source(folly)
velox_resolve_dependency(folly)
if(${VELOX_BUILD_TESTING})
# Spark query runner depends on absl, gRPC.
velox_set_source(absl)
velox_resolve_dependency(absl)
# 'gRPC_CARES_PROVIDER' is set as 'package', which means c-ares library needs
# to be installed on the system, instead of being built by gRPC.
velox_set_source(c-ares)
velox_resolve_dependency(c-ares)
velox_set_source(gRPC)
velox_resolve_dependency(gRPC)
endif()
if(VELOX_ENABLE_REMOTE_FUNCTIONS)
# TODO: Move this to use resolve_dependency(). For some reason, FBThrift
# requires clients to explicitly install fizz and wangle.
find_package(fizz CONFIG REQUIRED)
find_package(wangle CONFIG REQUIRED)
find_package(FBThrift CONFIG REQUIRED)
endif()
if(VELOX_ENABLE_GCS)
velox_set_source(google_cloud_cpp_storage)
velox_resolve_dependency(google_cloud_cpp_storage CONFIG 2.22.0 REQUIRED)
add_definitions(-DVELOX_ENABLE_GCS)
endif()
# GCC needs to link a library to enable std::filesystem.
# GCC needs to enable co-routines. We only support compiler that
# support coroutines.
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
# Find Threads library
find_package(Threads REQUIRED)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fcoroutines>)
# Explicitly enable folly coroutines when compiler supports them.
# This is required for folly::coro::AsyncGenerator to work correctly.
add_compile_definitions(FOLLY_HAS_COROUTINES=1)
endif()
if(VELOX_BUILD_TESTING AND NOT VELOX_ENABLE_DUCKDB)
message(
FATAL_ERROR
"Unit tests require duckDB to be enabled (VELOX_ENABLE_DUCKDB=ON or VELOX_BUILD_TESTING=OFF)"
)
endif()
set(VELOX_DISABLE_GOOGLETEST OFF)
if(NOT VELOX_BUILD_TEST_UTILS AND NOT VELOX_BUILD_TESTING)
set(VELOX_DISABLE_GOOGLETEST ON)
add_definitions(-DVELOX_DISABLE_GOOGLETEST)
endif()
# On macOS, search Homebrew for keg-only versions of Bison and Flex. Xcode does
# not provide new enough versions for us to use.
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
execute_process(
COMMAND brew --prefix bison
RESULT_VARIABLE BREW_BISON
OUTPUT_VARIABLE BREW_BISON_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(BREW_BISON EQUAL 0 AND EXISTS "${BREW_BISON_PREFIX}")
message(STATUS "Found Bison keg installed by Homebrew at ${BREW_BISON_PREFIX}")
set(BISON_EXECUTABLE "${BREW_BISON_PREFIX}/bin/bison")
endif()
execute_process(
COMMAND brew --prefix flex
RESULT_VARIABLE BREW_FLEX
OUTPUT_VARIABLE BREW_FLEX_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(BREW_FLEX EQUAL 0 AND EXISTS "${BREW_FLEX_PREFIX}")
message(STATUS "Found Flex keg installed by Homebrew at ${BREW_FLEX_PREFIX}")
set(FLEX_EXECUTABLE "${BREW_FLEX_PREFIX}/bin/flex")
set(FLEX_INCLUDE_DIR "${BREW_FLEX_PREFIX}/include")
endif()
endif()
find_package(BISON 3.0.4 REQUIRED)
find_package(FLEX 2.5.13 REQUIRED)
find_package(double-conversion 3.1.5 REQUIRED)
include_directories(SYSTEM velox)
include_directories(SYSTEM velox/external)
if(NOT VELOX_DISABLE_GOOGLETEST)
velox_set_source(GTest)
velox_resolve_dependency(GTest)
set(VELOX_GTEST_INCUDE_DIR "${gtest_SOURCE_DIR}/include" PARENT_SCOPE)
endif()
velox_set_source(xsimd)
velox_resolve_dependency(xsimd 10.0.0)
velox_set_source(stemmer)
velox_resolve_dependency(stemmer)
if(VELOX_BUILD_TESTING)
set(BUILD_TESTING ON)
include(CTest) # include after project() but before add_subdirectory()
endif()
include_directories(.)
# Adding this down here prevents warnings in dependencies from stopping the
# build
if("${TREAT_WARNINGS_AS_ERRORS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
message("FINAL CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
if(VELOX_ENABLE_ARROW)
velox_set_source(Arrow)
velox_resolve_dependency(Arrow)
endif()
if(VELOX_ENABLE_GEO)
velox_set_source(geos)
velox_resolve_dependency(geos)
endif()
add_subdirectory(velox)