Skip to content

Commit b213696

Browse files
authored
Merge branch 'main' into feat/spill-test
2 parents f441ff9 + f400933 commit b213696

22 files changed

Lines changed: 1686 additions & 26 deletions

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ if(PAIMON_BUILD_TESTS)
365365
endif()
366366
# Adding unit tests part of the "paimon" portion of the test suite
367367
add_custom_target(paimon-tests)
368-
build_gtest()
368+
resolve_dependency(GTest)
369369
370370
add_custom_target(unittest
371371
ctest
@@ -422,6 +422,8 @@ if(PAIMON_BUILD_TESTS)
422422
endif()
423423
endif()
424424
425+
paimon_print_dependency_resolution_summary()
426+
425427
include(CMakePackageConfigHelpers)
426428
write_basic_package_version_file(
427429
"${CMAKE_CURRENT_BINARY_DIR}/PaimonConfigVersion.cmake"

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,65 @@ $ cd build
140140
$ cmake ..
141141
$ make
142142
```
143+
144+
### Third-party dependencies
145+
146+
Paimon C++ can either build selected third-party dependencies from bundled
147+
sources or use libraries that are already installed on the system. The default
148+
mode is `AUTO`, which tries system packages first and falls back to bundled
149+
sources when they are not found.
150+
151+
```
152+
$ cmake -B build -DPAIMON_DEPENDENCY_SOURCE=AUTO
153+
```
154+
155+
The supported dependency source values are:
156+
157+
* `AUTO`: use a system package when available, otherwise build bundled sources.
158+
* `BUNDLED`: always build bundled sources.
159+
* `SYSTEM`: require system packages and fail if they are not found.
160+
161+
You can also override individual dependencies. The supported dependency set
162+
includes Arrow/Parquet, ORC, Protobuf, Avro, RE2, fmt, RapidJSON, TBB, glog,
163+
GoogleTest, and compression libraries.
164+
165+
```
166+
$ cmake -B build \
167+
-DPAIMON_DEPENDENCY_SOURCE=AUTO \
168+
-DArrow_SOURCE=SYSTEM \
169+
-DArrow_ROOT=/opt/arrow \
170+
-Dzstd_SOURCE=BUNDLED
171+
```
172+
173+
Use `PAIMON_PACKAGE_PREFIX` to provide one common prefix for dependencies whose
174+
own `<Package>_ROOT` variable is not set.
175+
176+
```
177+
$ cmake -B build \
178+
-DPAIMON_DEPENDENCY_SOURCE=SYSTEM \
179+
-DPAIMON_PACKAGE_PREFIX=/opt/paimon-deps
180+
```
181+
182+
Package-manager-specific modes are intentionally out of scope for this first
183+
dependency source interface. They can still be used through standard CMake
184+
mechanisms such as `CMAKE_PREFIX_PATH` or `CMAKE_TOOLCHAIN_FILE`, while Paimon
185+
keeps the dependency source values limited to `AUTO`, `BUNDLED`, and `SYSTEM`.
186+
187+
When `Arrow_SOURCE` is explicitly set to `SYSTEM` or `BUNDLED`, the compression
188+
dependencies default to the same source unless individually overridden. Mixing
189+
system and bundled copies of transitive dependencies can cause ABI conflicts,
190+
so prefer keeping Arrow and its compression dependencies from the same source
191+
unless you have a specific reason to override them.
192+
193+
When `ORC_SOURCE` is explicitly set, `Protobuf_SOURCE` defaults to the same
194+
source unless individually overridden. In `AUTO` mode, Paimon prechecks for a
195+
system ORC installation and defaults Protobuf to `SYSTEM` only when system ORC
196+
is found; otherwise Protobuf stays bundled with bundled ORC.
197+
198+
CMake prints a dependency resolution summary during configuration showing the
199+
requested source, actual source, compatibility target, and search root for each
200+
resolved dependency.
201+
143202
## Contributing
144203

145204
Paimon-cpp is an active open-source project and we welcome people who want to contribute or share good ideas!

cmake_modules/BuildUtils.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ function(add_paimon_lib LIB_NAME)
5252
# Generate a single "objlib" from all C++ modules and link
5353
# that "objlib" into each library kind, to avoid compiling twice
5454
add_library(${LIB_NAME}_objlib OBJECT ${ARG_SOURCES})
55+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
56+
target_compile_options(${LIB_NAME}_objlib PRIVATE -Wno-global-constructors)
57+
endif()
5558
# Necessary to make static linking into other shared libraries work properly
5659
set_property(TARGET ${LIB_NAME}_objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
5760
if(ARG_DEPENDENCIES)
5861
# In static-only builds, some dependency names are still declared as
5962
# *_shared. Map them to *_static when the shared target is unavailable.
63+
set(_paimon_objlib_link_deps)
6064
set(_paimon_objlib_deps)
6165
foreach(_paimon_dep IN LISTS ARG_DEPENDENCIES)
6266
set(_paimon_mapped_dep "${_paimon_dep}")
@@ -65,14 +69,24 @@ function(add_paimon_lib LIB_NAME)
6569
"${_paimon_dep}")
6670
endif()
6771
if(TARGET ${_paimon_mapped_dep})
72+
get_target_property(_paimon_is_internal_lib ${_paimon_mapped_dep}
73+
PAIMON_INTERNAL_LIBRARY)
6874
list(APPEND _paimon_objlib_deps ${_paimon_mapped_dep})
75+
if(NOT _paimon_is_internal_lib)
76+
list(APPEND _paimon_objlib_link_deps ${_paimon_mapped_dep})
77+
endif()
78+
unset(_paimon_is_internal_lib)
6979
endif()
7080
unset(_paimon_mapped_dep)
7181
endforeach()
7282
if(_paimon_objlib_deps)
7383
add_dependencies(${LIB_NAME}_objlib ${_paimon_objlib_deps})
7484
endif()
85+
if(_paimon_objlib_link_deps)
86+
target_link_libraries(${LIB_NAME}_objlib PRIVATE ${_paimon_objlib_link_deps})
87+
endif()
7588
unset(_paimon_objlib_deps)
89+
unset(_paimon_objlib_link_deps)
7690
unset(_paimon_dep)
7791
endif()
7892
set(LIB_DEPS $<TARGET_OBJECTS:${LIB_NAME}_objlib>)
@@ -103,6 +117,7 @@ function(add_paimon_lib LIB_NAME)
103117
target_include_directories(${LIB_NAME}_shared PRIVATE ${ARG_PRIVATE_INCLUDES})
104118
endif()
105119

120+
set_property(TARGET ${LIB_NAME}_shared PROPERTY PAIMON_INTERNAL_LIBRARY TRUE)
106121
set_target_properties(${LIB_NAME}_shared
107122
PROPERTIES LIBRARY_OUTPUT_DIRECTORY
108123
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
@@ -157,6 +172,7 @@ function(add_paimon_lib LIB_NAME)
157172

158173
set(LIB_NAME_STATIC ${LIB_NAME})
159174

175+
set_property(TARGET ${LIB_NAME}_static PROPERTY PAIMON_INTERNAL_LIBRARY TRUE)
160176
set_target_properties(${LIB_NAME}_static
161177
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY
162178
"${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}"

cmake_modules/DefineOptions.cmake

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,107 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
138138

139139
option(PAIMON_BUILD_CONFIG_SUMMARY_JSON
140140
"Summarize build configuration in a JSON file" ON)
141+
142+
#----------------------------------------------------------------------
143+
set_option_category("Dependencies")
144+
145+
define_option_string(PAIMON_DEPENDENCY_SOURCE
146+
"Default third-party dependency source"
147+
"AUTO"
148+
AUTO
149+
BUNDLED
150+
SYSTEM)
151+
152+
define_option_string(PAIMON_PACKAGE_PREFIX
153+
"Default prefix used to find third-party packages" "")
154+
155+
define_option(PAIMON_DEPENDENCY_USE_SHARED
156+
"Prefer shared libraries for system third-party packages" OFF)
157+
158+
define_option_string(Arrow_SOURCE
159+
"Dependency source for Apache Arrow"
160+
""
161+
AUTO
162+
BUNDLED
163+
SYSTEM)
164+
define_option_string(zstd_SOURCE
165+
"Dependency source for zstd"
166+
""
167+
AUTO
168+
BUNDLED
169+
SYSTEM)
170+
define_option_string(Snappy_SOURCE
171+
"Dependency source for Snappy"
172+
""
173+
AUTO
174+
BUNDLED
175+
SYSTEM)
176+
define_option_string(LZ4_SOURCE
177+
"Dependency source for LZ4"
178+
""
179+
AUTO
180+
BUNDLED
181+
SYSTEM)
182+
define_option_string(ZLIB_SOURCE
183+
"Dependency source for ZLIB"
184+
""
185+
AUTO
186+
BUNDLED
187+
SYSTEM)
188+
define_option_string(RE2_SOURCE
189+
"Dependency source for RE2"
190+
""
191+
AUTO
192+
BUNDLED
193+
SYSTEM)
194+
define_option_string(Protobuf_SOURCE
195+
"Dependency source for Protobuf"
196+
""
197+
AUTO
198+
BUNDLED
199+
SYSTEM)
200+
define_option_string(ORC_SOURCE
201+
"Dependency source for Apache ORC"
202+
""
203+
AUTO
204+
BUNDLED
205+
SYSTEM)
206+
define_option_string(fmt_SOURCE
207+
"Dependency source for fmt"
208+
""
209+
AUTO
210+
BUNDLED
211+
SYSTEM)
212+
define_option_string(RapidJSON_SOURCE
213+
"Dependency source for RapidJSON"
214+
""
215+
AUTO
216+
BUNDLED
217+
SYSTEM)
218+
define_option_string(TBB_SOURCE
219+
"Dependency source for TBB"
220+
""
221+
AUTO
222+
BUNDLED
223+
SYSTEM)
224+
define_option_string(glog_SOURCE
225+
"Dependency source for glog"
226+
""
227+
AUTO
228+
BUNDLED
229+
SYSTEM)
230+
define_option_string(Avro_SOURCE
231+
"Dependency source for Avro C++"
232+
""
233+
AUTO
234+
BUNDLED
235+
SYSTEM)
236+
define_option_string(GTest_SOURCE
237+
"Dependency source for GoogleTest"
238+
""
239+
AUTO
240+
BUNDLED
241+
SYSTEM)
141242
endif()
142243

143244
macro(validate_config)

cmake_modules/FindArrowAlt.cmake

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Copyright 2026-present Alibaba Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
set(_PAIMON_ARROW_ROOTS ${Arrow_ROOT} ${ARROW_ROOT} ${PAIMON_PACKAGE_PREFIX})
16+
list(REMOVE_ITEM _PAIMON_ARROW_ROOTS "")
17+
if(_PAIMON_ARROW_ROOTS)
18+
set(_PAIMON_ARROW_FIND_ARGS HINTS ${_PAIMON_ARROW_ROOTS} NO_DEFAULT_PATH)
19+
endif()
20+
21+
find_package(Arrow CONFIG QUIET ${_PAIMON_ARROW_FIND_ARGS})
22+
find_package(Parquet CONFIG QUIET ${_PAIMON_ARROW_FIND_ARGS})
23+
find_package(ArrowDataset CONFIG QUIET ${_PAIMON_ARROW_FIND_ARGS})
24+
find_package(ArrowAcero CONFIG QUIET ${_PAIMON_ARROW_FIND_ARGS})
25+
26+
function(_paimon_select_first_target OUT_VAR)
27+
foreach(_target IN LISTS ARGN)
28+
if(TARGET ${_target})
29+
set(${OUT_VAR}
30+
${_target}
31+
PARENT_SCOPE)
32+
return()
33+
endif()
34+
endforeach()
35+
endfunction()
36+
37+
if(PAIMON_DEPENDENCY_USE_SHARED)
38+
_paimon_select_first_target(_PAIMON_ARROW_TARGET Arrow::arrow_shared Arrow::arrow)
39+
_paimon_select_first_target(_PAIMON_PARQUET_TARGET Parquet::parquet_shared
40+
Parquet::parquet)
41+
_paimon_select_first_target(_PAIMON_ARROW_DATASET_TARGET
42+
ArrowDataset::arrow_dataset_shared
43+
Arrow::arrow_dataset_shared ArrowDataset::arrow_dataset)
44+
_paimon_select_first_target(_PAIMON_ARROW_ACERO_TARGET ArrowAcero::arrow_acero_shared
45+
Arrow::arrow_acero_shared ArrowAcero::arrow_acero)
46+
else()
47+
_paimon_select_first_target(_PAIMON_ARROW_TARGET Arrow::arrow_static Arrow::arrow)
48+
_paimon_select_first_target(_PAIMON_PARQUET_TARGET Parquet::parquet_static
49+
Parquet::parquet)
50+
_paimon_select_first_target(_PAIMON_ARROW_DATASET_TARGET
51+
ArrowDataset::arrow_dataset_static
52+
Arrow::arrow_dataset_static ArrowDataset::arrow_dataset)
53+
_paimon_select_first_target(_PAIMON_ARROW_ACERO_TARGET ArrowAcero::arrow_acero_static
54+
Arrow::arrow_acero_static ArrowAcero::arrow_acero)
55+
endif()
56+
57+
include(FindPackageHandleStandardArgs)
58+
find_package_handle_standard_args(
59+
ArrowAlt REQUIRED_VARS _PAIMON_ARROW_TARGET _PAIMON_PARQUET_TARGET
60+
_PAIMON_ARROW_DATASET_TARGET _PAIMON_ARROW_ACERO_TARGET)
61+
62+
if(ArrowAlt_FOUND)
63+
get_target_property(ARROW_INCLUDE_DIR ${_PAIMON_ARROW_TARGET}
64+
INTERFACE_INCLUDE_DIRECTORIES)
65+
66+
if(NOT TARGET arrow)
67+
add_library(arrow INTERFACE IMPORTED)
68+
if(ARROW_INCLUDE_DIR)
69+
set_target_properties(arrow PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
70+
"${ARROW_INCLUDE_DIR}")
71+
endif()
72+
target_link_libraries(arrow INTERFACE ${_PAIMON_ARROW_TARGET})
73+
endif()
74+
75+
if(NOT TARGET arrow_acero)
76+
add_library(arrow_acero INTERFACE IMPORTED)
77+
target_link_libraries(arrow_acero INTERFACE ${_PAIMON_ARROW_ACERO_TARGET} arrow)
78+
endif()
79+
80+
if(NOT TARGET arrow_dataset)
81+
add_library(arrow_dataset INTERFACE IMPORTED)
82+
target_link_libraries(arrow_dataset INTERFACE ${_PAIMON_ARROW_DATASET_TARGET}
83+
arrow_acero)
84+
endif()
85+
86+
if(NOT TARGET parquet)
87+
add_library(parquet INTERFACE IMPORTED)
88+
target_link_libraries(parquet INTERFACE ${_PAIMON_PARQUET_TARGET} arrow_dataset)
89+
endif()
90+
endif()
91+
92+
unset(_PAIMON_ARROW_ACERO_TARGET)
93+
unset(_PAIMON_ARROW_DATASET_TARGET)
94+
unset(_PAIMON_ARROW_FIND_ARGS)
95+
unset(_PAIMON_ARROW_ROOTS)
96+
unset(_PAIMON_ARROW_TARGET)
97+
unset(_PAIMON_PARQUET_TARGET)

0 commit comments

Comments
 (0)