Skip to content

Commit 9fb4516

Browse files
committed
chore: add NOTICE LICENSE CODE_OF_CONDUCT etc.
1 parent d7cdfbc commit 9fb4516

File tree

5 files changed

+730
-0
lines changed

5 files changed

+730
-0
lines changed

CMakeLists.txt

Lines changed: 382 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,382 @@
1+
# Copyright 2024-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+
cmake_minimum_required(VERSION 3.16)
16+
message(STATUS "Building using CMake version: ${CMAKE_VERSION}")
17+
18+
# https://cmake.org/cmake/help/latest/policy/CMP0135.html
19+
#
20+
# CMP0135 is for solving re-building and re-downloading.
21+
# We don't have a real problem with the OLD behavior for now
22+
# but we use the NEW behavior explicitly to suppress CMP0135
23+
# warnings.
24+
if(POLICY CMP0135)
25+
cmake_policy(SET CMP0135 NEW)
26+
endif()
27+
28+
if(NOT CMAKE_BUILD_TYPE)
29+
set(CMAKE_BUILD_TYPE
30+
Release
31+
CACHE STRING "Choose the type of build.")
32+
endif()
33+
34+
project(paimon
35+
VERSION 0.9.0
36+
DESCRIPTION "Paimon C++ Project")
37+
38+
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPERCASE_BUILD_TYPE)
39+
40+
set(CMAKE_CXX_STANDARD 17)
41+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
42+
set(CMAKE_CXX_EXTENSIONS OFF)
43+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
44+
45+
option(PAIMON_BUILD_STATIC "Build static library" ON)
46+
option(PAIMON_BUILD_SHARED "Build shared library" ON)
47+
option(PAIMON_BUILD_TESTS "Build tests" OFF)
48+
option(PAIMON_USE_ASAN "Use Address Sanitizer" OFF)
49+
option(PAIMON_USE_TSAN "Use Thread Sanitizer" OFF)
50+
option(PAIMON_USE_UBSAN "Use Undefined Behavior Sanitizer" OFF)
51+
option(PAIMON_ENABLE_AVRO "Whether to enable avro file format" ON)
52+
option(PAIMON_ENABLE_ORC "Whether to enable orc file format" ON)
53+
option(PAIMON_ENABLE_LANCE "Whether to enable lance file format" OFF)
54+
option(PAIMON_ENABLE_JINDO "Whether to enable jindo file system" OFF)
55+
option(PAIMON_ENABLE_LUMINA "Whether to enable lumina vector index" ON)
56+
57+
if(PAIMON_ENABLE_ORC)
58+
add_definitions(-DPAIMON_ENABLE_ORC)
59+
endif()
60+
if(PAIMON_ENABLE_AVRO)
61+
add_definitions(-DPAIMON_ENABLE_AVRO)
62+
endif()
63+
if(PAIMON_ENABLE_LANCE)
64+
add_definitions(-DPAIMON_ENABLE_LANCE)
65+
endif()
66+
if(PAIMON_ENABLE_JINDO)
67+
add_definitions(-DPAIMON_ENABLE_JINDO)
68+
endif()
69+
70+
if(PAIMON_ENABLE_LUMINA)
71+
add_definitions(-DPAIMON_ENABLE_LUMINA)
72+
endif()
73+
74+
add_definitions(-DSNAPPY_CODEC_AVAILABLE)
75+
add_definitions(-DZSTD_CODEC_AVAILABLE)
76+
add_definitions(-DRAPIDJSON_HAS_STDSTRING)
77+
78+
set(CLANG_TIDY_BIN "clang-tidy")
79+
80+
set(PAIMON_SOURCE_DIR ${PROJECT_SOURCE_DIR})
81+
set(PAIMON_BINARY_DIR ${PROJECT_BINARY_DIR})
82+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
83+
set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/build_support")
84+
set(PAIMON_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
85+
86+
include(GNUInstallDirs)
87+
include(DefineOptions)
88+
89+
if(PAIMON_OPTIONAL_INSTALL)
90+
# Don't make the "install" target depend on the "all" target
91+
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
92+
set(INSTALL_IS_OPTIONAL OPTIONAL)
93+
endif()
94+
95+
if(PAIMON_EXTRA_ERROR_CONTEXT)
96+
add_definitions(-DPAIMON_EXTRA_ERROR_CONTEXT)
97+
endif()
98+
99+
if(NOT PAIMON_VERBOSE_LINT)
100+
set(PAIMON_LINT_QUIET "--quiet")
101+
endif()
102+
103+
set(LINT_EXCLUSIONS_FILE ${BUILD_SUPPORT_DIR}/lint_exclusions.txt)
104+
105+
set(LINT_SOURCE_DIRS ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src
106+
${CMAKE_SOURCE_DIR}/test ${CMAKE_SOURCE_DIR}/examples)
107+
108+
set(CLANG_TIDY_OPTIONS
109+
${PAIMON_LINT_QUIET}
110+
--compile_commands
111+
${CMAKE_BINARY_DIR}/compile_commands.json
112+
--exclude_globs
113+
${LINT_EXCLUSIONS_FILE})
114+
115+
if(PAIMON_LINT_GIT_DIFF_MODE)
116+
list(JOIN LINT_SOURCE_DIRS "|" _lint_dir_union)
117+
set(LINT_DIR_REGEX "^(${_lint_dir_union}\/?)")
118+
119+
set(GIT_DIFF_FILE_PATH ${CMAKE_BINARY_DIR}/git_diff_files.txt)
120+
add_custom_target(update_diff_files
121+
# get git-diff file list
122+
COMMAND git diff-index --name-only --diff-filter=a --cached
123+
${PAIMON_LINT_GIT_TARGET_COMMIT} > ${GIT_DIFF_FILE_PATH}
124+
# convert to absolute path
125+
COMMAND sed -i \"s|^|${CMAKE_SOURCE_DIR}/|\" ${GIT_DIFF_FILE_PATH}
126+
# filter with ${LINT_SOURCE_DIRS} dirs
127+
COMMAND sed -nE -i '\\@${LINT_DIR_REGEX}@p' ${GIT_DIFF_FILE_PATH}
128+
COMMENT "Generate git_diff_files.txt for git-diff lint"
129+
BYPRODUCTS ${GIT_DIFF_FILE_PATH})
130+
131+
list(APPEND CLANG_TIDY_OPTIONS --source_file @${GIT_DIFF_FILE_PATH})
132+
else()
133+
list(APPEND CLANG_TIDY_OPTIONS --source_dir ${LINT_SOURCE_DIRS})
134+
endif()
135+
136+
# runs clang-tidy and attempts to fix any warning automatically
137+
add_custom_target(clang-tidy
138+
${PYTHON_EXECUTABLE}
139+
${BUILD_SUPPORT_DIR}/run_clang_tidy.py
140+
--clang_tidy_binary
141+
${CLANG_TIDY_BIN}
142+
${CLANG_TIDY_OPTIONS}
143+
--fix)
144+
145+
# runs clang-tidy and exits with a non-zero exit code if any errors are found.
146+
add_custom_target(check-clang-tidy
147+
${PYTHON_EXECUTABLE}
148+
${BUILD_SUPPORT_DIR}/run_clang_tidy.py
149+
--clang_tidy_binary
150+
${CLANG_TIDY_BIN}
151+
${CLANG_TIDY_OPTIONS})
152+
153+
if(PAIMON_LINT_GIT_DIFF_MODE)
154+
add_dependencies(clang-tidy update_diff_files)
155+
add_dependencies(check-clang-tidy update_diff_files)
156+
endif()
157+
158+
if(UNIX)
159+
add_custom_target(iwyu
160+
${CMAKE_COMMAND}
161+
-E
162+
env
163+
"PYTHON=${PYTHON_EXECUTABLE}"
164+
${BUILD_SUPPORT_DIR}/iwyu/iwyu.sh)
165+
add_custom_target(iwyu-all
166+
${CMAKE_COMMAND}
167+
-E
168+
env
169+
"PYTHON=${PYTHON_EXECUTABLE}"
170+
${BUILD_SUPPORT_DIR}/iwyu/iwyu.sh
171+
all)
172+
endif(UNIX)
173+
174+
include(SetupCxxFlags)
175+
176+
# set compile output directory
177+
string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_SUBDIR_NAME)
178+
179+
# If build in-source, create the latest symlink. If build out-of-source, which
180+
# is preferred, simply output the binaries in the build folder
181+
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
182+
set(BUILD_OUTPUT_ROOT_DIRECTORY
183+
"${CMAKE_CURRENT_BINARY_DIR}/build/${BUILD_SUBDIR_NAME}/")
184+
# Link build/latest to the current build directory, to avoid developers
185+
# accidentally running the latest debug build when in fact they're building
186+
# release builds.
187+
file(MAKE_DIRECTORY ${BUILD_OUTPUT_ROOT_DIRECTORY})
188+
if(NOT APPLE)
189+
set(MORE_ARGS "-T")
190+
endif()
191+
execute_process(COMMAND ln ${MORE_ARGS} -sf ${BUILD_OUTPUT_ROOT_DIRECTORY}
192+
${CMAKE_CURRENT_BINARY_DIR}/build/latest)
193+
else()
194+
set(BUILD_OUTPUT_ROOT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${BUILD_SUBDIR_NAME}/")
195+
endif()
196+
197+
# where to put generated archives (.a files)
198+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}")
199+
set(ARCHIVE_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}")
200+
201+
# where to put generated libraries (.so files)
202+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}")
203+
set(LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}")
204+
205+
# where to put generated binaries
206+
set(EXECUTABLE_OUTPUT_PATH "${BUILD_OUTPUT_ROOT_DIRECTORY}")
207+
208+
include(BuildUtils)
209+
enable_testing()
210+
211+
# Add common flags
212+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_COMMON_FLAGS}")
213+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PAIMON_CXXFLAGS}")
214+
215+
# For any C code, use the same flags. These flags don't contain C++ specific
216+
# flags.
217+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CXX_COMMON_FLAGS} ${PAIMON_CXXFLAGS}")
218+
219+
# Remove --std=c++17 to avoid errors from C compilers
220+
string(REPLACE "-std=c++17" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
221+
222+
# Add C++-only flags, like -std=c++11
223+
set(CMAKE_CXX_FLAGS "${CXX_ONLY_FLAGS} ${CMAKE_CXX_FLAGS}")
224+
225+
include(san-config)
226+
227+
# Code coverage
228+
if("${PAIMON_GENERATE_COVERAGE}")
229+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -DCOVERAGE_BUILD")
230+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -DCOVERAGE_BUILD")
231+
endif()
232+
233+
# CMAKE_CXX_FLAGS now fully assembled
234+
message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
235+
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
236+
237+
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
238+
include_directories(src)
239+
240+
#
241+
# Visibility
242+
#
243+
# For generate_export_header() and add_compiler_export_flags().
244+
include(GenerateExportHeader)
245+
include(ExternalProject)
246+
include(ThirdpartyToolchain)
247+
248+
add_custom_target(paimon_dependencies)
249+
250+
if(PAIMON_STATIC_LINK_LIBS)
251+
add_dependencies(paimon_dependencies ${PAIMON_STATIC_LINK_LIBS})
252+
endif()
253+
254+
set(PAIMON_SHARED_PRIVATE_LINK_LIBS ${PAIMON_STATIC_LINK_LIBS})
255+
256+
add_subdirectory(third_party/roaring_bitmap EXCLUDE_FROM_ALL)
257+
add_subdirectory(third_party/xxhash EXCLUDE_FROM_ALL)
258+
259+
if(PAIMON_ENABLE_LANCE)
260+
add_subdirectory(third_party/lance EXCLUDE_FROM_ALL)
261+
link_directories(third_party/lance/lance_lib/target/release)
262+
install(FILES ${PROJECT_SOURCE_DIR}/third_party/lance/lance_lib/target/release/liblance_lib_rc.so
263+
DESTINATION ${CMAKE_INSTALL_LIBDIR})
264+
endif()
265+
266+
list(APPEND PAIMON_LINK_LIBS ${CMAKE_DL_LIBS})
267+
list(APPEND PAIMON_SHARED_INSTALL_INTERFACE_LIBS ${CMAKE_DL_LIBS})
268+
if(PAIMON_ENABLE_LUMINA)
269+
add_subdirectory(third_party/lumina EXCLUDE_FROM_ALL)
270+
link_directories(third_party/lumina/lib)
271+
install(FILES ${PROJECT_SOURCE_DIR}/third_party/lumina/lib/liblumina.so
272+
DESTINATION ${CMAKE_INSTALL_LIBDIR})
273+
endif()
274+
275+
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
276+
DESTINATION "include"
277+
FILES_MATCHING
278+
PATTERN "*.h")
279+
280+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
281+
set(CMAKE_C_VISIBILITY_PRESET hidden)
282+
283+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
284+
include_directories("${CMAKE_SOURCE_DIR}/third_party/roaring_bitmap")
285+
include_directories("${CMAKE_SOURCE_DIR}/third_party/xxhash")
286+
287+
if(PAIMON_ENABLE_LANCE)
288+
include_directories("${CMAKE_SOURCE_DIR}/third_party/lance")
289+
endif()
290+
291+
if(PAIMON_ENABLE_LUMINA)
292+
include_directories("${CMAKE_SOURCE_DIR}/third_party/lumina/include")
293+
endif()
294+
295+
include_directories(SYSTEM ${ARROW_INCLUDE_DIR})
296+
include_directories(SYSTEM ${TBB_INCLUDE_DIR})
297+
298+
include_directories(SYSTEM ${GLOG_INCLUDE_DIR})
299+
add_compile_definitions("GLOG_USE_GLOG_EXPORT")
300+
301+
set(THREADS_PREFER_PTHREAD_FLAG ON)
302+
find_package(Threads REQUIRED)
303+
set(PAIMON_VERSION_SCRIPT_FLAGS
304+
"-Wl,--version-script=${CMAKE_SOURCE_DIR}/src/paimon/symbols.map")
305+
306+
set(ENV{PAIMON_TEST_DATA} "${CMAKE_SOURCE_DIR}/test/test_data")
307+
308+
if(PAIMON_BUILD_TESTS)
309+
if(NOT PAIMON_ENABLE_ORC)
310+
message(FATAL_ERROR "PAIMON_ENABLE_ORC must be enabled if PAIMON_BUILD_TESTS is enable"
311+
)
312+
endif()
313+
# Adding unit tests part of the "paimon" portion of the test suite
314+
add_custom_target(paimon-tests)
315+
build_gtest()
316+
317+
add_custom_target(unittest
318+
ctest
319+
-j4
320+
-L
321+
unittest
322+
--output-on-failure)
323+
add_compile_options(-fno-access-control)
324+
add_dependencies(unittest paimon-tests)
325+
326+
include_directories(SYSTEM ${GTEST_INCLUDE_DIR})
327+
include_directories("${CMAKE_SOURCE_DIR}/test/")
328+
329+
set(TEST_STATIC_LINK_LIBS
330+
paimon_file_index_static
331+
paimon_global_index_static
332+
paimon_local_file_system_static
333+
paimon_mock_file_format_static
334+
paimon_parquet_file_format_shared
335+
paimon_blob_file_format_shared)
336+
337+
if(PAIMON_ENABLE_LANCE)
338+
list(APPEND TEST_STATIC_LINK_LIBS paimon_lance_file_format_shared)
339+
endif()
340+
if(PAIMON_ENABLE_ORC)
341+
list(APPEND TEST_STATIC_LINK_LIBS paimon_orc_file_format_shared)
342+
endif()
343+
if(PAIMON_ENABLE_AVRO)
344+
list(APPEND TEST_STATIC_LINK_LIBS paimon_avro_file_format_shared)
345+
endif()
346+
if(PAIMON_ENABLE_JINDO)
347+
list(APPEND TEST_STATIC_LINK_LIBS paimon_jindo_file_system_shared)
348+
endif()
349+
if(PAIMON_ENABLE_LUMINA)
350+
list(APPEND TEST_STATIC_LINK_LIBS paimon_lumina_index_shared)
351+
endif()
352+
353+
endif()
354+
355+
include(CMakePackageConfigHelpers)
356+
write_basic_package_version_file(
357+
"${CMAKE_CURRENT_BINARY_DIR}/PaimonConfigVersion.cmake"
358+
VERSION ${PROJECT_VERSION}
359+
COMPATIBILITY AnyNewerVersion)
360+
361+
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/PaimonConfig.cmake.in"
362+
"${CMAKE_CURRENT_BINARY_DIR}/PaimonConfig.cmake"
363+
INSTALL_DESTINATION lib/cmake/Paimon)
364+
365+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PaimonConfig.cmake"
366+
"${CMAKE_CURRENT_BINARY_DIR}/PaimonConfigVersion.cmake"
367+
DESTINATION lib/cmake/Paimon)
368+
369+
config_summary_message()
370+
371+
add_subdirectory(src/paimon)
372+
add_subdirectory(src/paimon/fs/local)
373+
add_subdirectory(src/paimon/fs/jindo)
374+
add_subdirectory(src/paimon/format/blob)
375+
add_subdirectory(src/paimon/format/orc)
376+
add_subdirectory(src/paimon/format/parquet)
377+
add_subdirectory(src/paimon/format/avro)
378+
add_subdirectory(src/paimon/format/lance)
379+
add_subdirectory(src/paimon/global_index/lumina)
380+
add_subdirectory(src/paimon/testing/mock)
381+
add_subdirectory(src/paimon/testing/utils)
382+
add_subdirectory(test/inte)

0 commit comments

Comments
 (0)