From 7a2c831c59a662bac790df5d611a4276474d297a Mon Sep 17 00:00:00 2001 From: "jinli.zjw" Date: Tue, 26 May 2026 21:55:39 +0800 Subject: [PATCH 1/3] fix(build): make package config relocatable --- CMakeLists.txt | 10 ++- PaimonConfig.cmake.in | 132 +-------------------------------- cmake_modules/BuildUtils.cmake | 4 +- 3 files changed, 12 insertions(+), 134 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1acfd2649..c913644c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,9 +97,9 @@ set(PAIMON_SOURCE_DIR ${PROJECT_SOURCE_DIR}) set(PAIMON_BINARY_DIR ${PROJECT_BINARY_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules") set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/build_support") -set(PAIMON_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") include(GNUInstallDirs) +set(PAIMON_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/Paimon") include(DefineOptions) if(PAIMON_OPTIONAL_INSTALL) @@ -432,11 +432,11 @@ write_basic_package_version_file( configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/PaimonConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/PaimonConfig.cmake" - INSTALL_DESTINATION lib/cmake/Paimon) + INSTALL_DESTINATION ${PAIMON_CMAKE_INSTALL_DIR}) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PaimonConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/PaimonConfigVersion.cmake" - DESTINATION lib/cmake/Paimon) + DESTINATION ${PAIMON_CMAKE_INSTALL_DIR}) config_summary_message() @@ -453,3 +453,7 @@ add_subdirectory(src/paimon/global_index/lucene) add_subdirectory(src/paimon/testing/mock) add_subdirectory(src/paimon/testing/utils) add_subdirectory(test/inte) + +install(EXPORT PaimonTargets + NAMESPACE Paimon:: + DESTINATION ${PAIMON_CMAKE_INSTALL_DIR}) diff --git a/PaimonConfig.cmake.in b/PaimonConfig.cmake.in index eaca7ee4d..8b3ae8d08 100644 --- a/PaimonConfig.cmake.in +++ b/PaimonConfig.cmake.in @@ -12,134 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Main library -add_library(paimon_shared SHARED IMPORTED) -set_target_properties(paimon_shared PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon.so" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) -add_library(paimon_static STATIC IMPORTED) -set_target_properties(paimon_static PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon.a" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) +@PACKAGE_INIT@ -# paimon_parquet_file_format -add_library(paimon_parquet_file_format_shared SHARED IMPORTED) -set_target_properties(paimon_parquet_file_format_shared PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_parquet_file_format.so" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) -add_library(paimon_parquet_file_format_static STATIC IMPORTED) -set_target_properties(paimon_parquet_file_format_static PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_parquet_file_format.a" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) +include("${CMAKE_CURRENT_LIST_DIR}/PaimonTargets.cmake") -# paimon_orc_file_format -add_library(paimon_orc_file_format_shared SHARED IMPORTED) -set_target_properties(paimon_orc_file_format_shared PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_orc_file_format.so" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) -add_library(paimon_orc_file_format_static STATIC IMPORTED) -set_target_properties(paimon_orc_file_format_static PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_orc_file_format.a" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) - -# paimon_local_file_system -add_library(paimon_local_file_system_shared SHARED IMPORTED) -set_target_properties(paimon_local_file_system_shared PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_local_file_system.so" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) -add_library(paimon_local_file_system_static STATIC IMPORTED) -set_target_properties(paimon_local_file_system_static PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_local_file_system.a" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) - -# paimon_avro_file_format -add_library(paimon_avro_file_format_shared SHARED IMPORTED) -set_target_properties(paimon_avro_file_format_shared PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_avro_file_format.so" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) -add_library(paimon_avro_file_format_static STATIC IMPORTED) -set_target_properties(paimon_avro_file_format_static PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_avro_file_format.a" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) - -# paimon_blob_file_format -add_library(paimon_blob_file_format_shared SHARED IMPORTED) -set_target_properties(paimon_blob_file_format_shared PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_blob_file_format.so" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) -add_library(paimon_blob_file_format_static STATIC IMPORTED) -set_target_properties(paimon_blob_file_format_static PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_blob_file_format.a" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) - -# paimon_file_index -add_library(paimon_file_index_shared SHARED IMPORTED) -set_target_properties(paimon_file_index_shared PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_file_index.so" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) -add_library(paimon_file_index_static STATIC IMPORTED) -set_target_properties(paimon_file_index_static PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_file_index.a" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) - -# paimon_global_index -add_library(paimon_global_index_shared SHARED IMPORTED) -set_target_properties(paimon_global_index_shared PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_global_index.so" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) -add_library(paimon_global_index_static STATIC IMPORTED) -set_target_properties(paimon_global_index_static PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_global_index.a" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) - -# paimon_jindo_file_system -add_library(paimon_jindo_file_system_shared SHARED IMPORTED) -set_target_properties(paimon_jindo_file_system_shared PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_jindo_file_system.so" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) -add_library(paimon_jindo_file_system_static STATIC IMPORTED) -set_target_properties(paimon_jindo_file_system_static PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_jindo_file_system.a" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) - -# paimon_lance_file_format -add_library(paimon_lance_file_format_shared SHARED IMPORTED) -set_target_properties(paimon_lance_file_format_shared PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_lance_file_format.so" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) -add_library(paimon_lance_file_format_static STATIC IMPORTED) -set_target_properties(paimon_lance_file_format_static PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_lance_file_format.a" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) - -# paimon_lumina_index -add_library(paimon_lumina_index_shared SHARED IMPORTED) -set_target_properties(paimon_lumina_index_shared PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_lumina_index.so" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) -add_library(paimon_lumina_index_static STATIC IMPORTED) -set_target_properties(paimon_lumina_index_static PROPERTIES - IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libpaimon_lumina_index.a" - INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/include" -) +check_required_components(Paimon) diff --git a/cmake_modules/BuildUtils.cmake b/cmake_modules/BuildUtils.cmake index 0bc75b64b..72ca6d435 100644 --- a/cmake_modules/BuildUtils.cmake +++ b/cmake_modules/BuildUtils.cmake @@ -147,7 +147,7 @@ function(add_paimon_lib LIB_NAME) -Wl,--gc-sections) install(TARGETS ${LIB_NAME}_shared ${INSTALL_IS_OPTIONAL} - EXPORT ${LIB_NAME}_targets + EXPORT PaimonTargets RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -194,7 +194,7 @@ function(add_paimon_lib LIB_NAME) PUBLIC "$") install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL} - EXPORT ${LIB_NAME}_targets + EXPORT PaimonTargets RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} From f614e772622da1bc57066cfb3ffd6c8f3a17275c Mon Sep 17 00:00:00 2001 From: "jinli.zjw" Date: Wed, 27 May 2026 16:48:25 +0800 Subject: [PATCH 2/3] fix(build): update examples package targets --- docs/source/build_system.rst | 32 ++++++++++++++++---------------- examples/CMakeLists.txt | 22 ++++++++++------------ 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/docs/source/build_system.rst b/docs/source/build_system.rst index 462f10107..72bfd8874 100644 --- a/docs/source/build_system.rst +++ b/docs/source/build_system.rst @@ -49,10 +49,10 @@ for data format and file system. find_package(Paimon REQUIRED) add_executable(my_example my_example.cc) - target_link_libraries(my_example PRIVATE arrow_shared - paimon_shared - paimon_parquet_file_format_shared - paimon_local_file_system_shared) + target_link_libraries(my_example PRIVATE Arrow::arrow_shared + Paimon::paimon_shared + Paimon::paimon_parquet_file_format_shared + Paimon::paimon_local_file_system_shared) Available variables and targets ------------------------------- @@ -61,10 +61,10 @@ The directive ``find_package(Paimon REQUIRED)`` instructs CMake to locate a Paimon C++ installation on your system. If successful, it sets ``Paimon_FOUND`` to true if the Paimon C++ libraries were found. -It also defines the following linkable targets (plain strings, not variables): +It also defines the following linkable imported targets: -* ``paimon_shared`` links to the Paimon shared libraries -* ``paimon_static`` links to the Paimon static libraries +* ``Paimon::paimon_shared`` links to the Paimon shared libraries +* ``Paimon::paimon_static`` links to the Paimon static libraries In most cases, it is recommended to use the Paimon shared libraries. @@ -75,21 +75,21 @@ Paimon provides a set of built-in optional plugins that you can link to as neede - File format plugins: - - ``paimon_parquet_file_format_shared`` / ``paimon_parquet_file_format_static`` - - ``paimon_orc_file_format_shared`` / ``paimon_orc_file_format_static`` - - ``paimon_avro_file_format_shared`` / ``paimon_avro_file_format_static`` - - ``paimon_blob_file_format_shared`` / ``paimon_blob_file_format_static`` - - ``paimon_lance_file_format_shared`` / ``paimon_lance_file_format_static`` + - ``Paimon::paimon_parquet_file_format_shared`` / ``Paimon::paimon_parquet_file_format_static`` + - ``Paimon::paimon_orc_file_format_shared`` / ``Paimon::paimon_orc_file_format_static`` + - ``Paimon::paimon_avro_file_format_shared`` / ``Paimon::paimon_avro_file_format_static`` + - ``Paimon::paimon_blob_file_format_shared`` / ``Paimon::paimon_blob_file_format_static`` + - ``Paimon::paimon_lance_file_format_shared`` / ``Paimon::paimon_lance_file_format_static`` - File system plugins: - - ``paimon_local_file_system_shared`` / ``paimon_local_file_system_static`` - - ``paimon_jindo_file_system_shared`` / ``paimon_jindo_file_system_static`` + - ``Paimon::paimon_local_file_system_shared`` / ``Paimon::paimon_local_file_system_static`` + - ``Paimon::paimon_jindo_file_system_shared`` / ``Paimon::paimon_jindo_file_system_static`` - Index plugins: - - ``paimon_file_index_shared`` / ``paimon_file_index_static`` - - ``paimon_lumina_index_shared`` / ``paimon_lumina_index_static`` + - ``Paimon::paimon_file_index_shared`` / ``Paimon::paimon_file_index_static`` + - ``Paimon::paimon_lumina_index_shared`` / ``Paimon::paimon_lumina_index_static`` .. note:: diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 34818475e..6af804775 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,20 +24,18 @@ find_package(Paimon CONFIG REQUIRED) add_executable(read_write_demo read_write_demo.cpp) add_executable(clean_demo clean_demo.cpp) -include_directories(${PAIMON_INCLUDE_DIRS}) - set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed ${CMAKE_EXE_LINKER_FLAGS}") target_link_libraries(read_write_demo - PRIVATE arrow_shared - paimon_shared - paimon_parquet_file_format_shared - paimon_orc_file_format_shared - paimon_local_file_system_shared) + PRIVATE Arrow::arrow_shared + Paimon::paimon_shared + Paimon::paimon_parquet_file_format_shared + Paimon::paimon_orc_file_format_shared + Paimon::paimon_local_file_system_shared) target_link_libraries(clean_demo - PRIVATE arrow_shared - paimon_shared - paimon_parquet_file_format_shared - paimon_orc_file_format_shared - paimon_local_file_system_shared) + PRIVATE Arrow::arrow_shared + Paimon::paimon_shared + Paimon::paimon_parquet_file_format_shared + Paimon::paimon_orc_file_format_shared + Paimon::paimon_local_file_system_shared) From c84168c3dc52abdf41fd8e00d4f2e66c67f99e11 Mon Sep 17 00:00:00 2001 From: "jinli.zjw" Date: Wed, 27 May 2026 18:39:06 +0800 Subject: [PATCH 3/3] fix(build): harden build script paths --- ci/scripts/build_paimon.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ci/scripts/build_paimon.sh b/ci/scripts/build_paimon.sh index f1d0423de..72999406d 100755 --- a/ci/scripts/build_paimon.sh +++ b/ci/scripts/build_paimon.sh @@ -20,7 +20,7 @@ source_dir=${1} enable_sanitizer=${2:-false} check_clang_tidy=${3:-false} build_type=${4:-Debug} -build_dir=${1}/build +build_dir="${source_dir}/build" # Display ccache status if available if command -v ccache &> /dev/null; then @@ -31,8 +31,8 @@ else echo "=== ccache not found, compiling without cache acceleration ===" fi -mkdir ${build_dir} -pushd ${build_dir} +mkdir -p "${build_dir}" +pushd "${build_dir}" ENABLE_LUMINA="ON" ENABLE_LANCE="ON" @@ -62,9 +62,9 @@ if [[ "${enable_sanitizer}" == "true" ]]; then ) fi -cmake "${CMAKE_ARGS[@]}" ${source_dir} -cmake --build . -- -j$(nproc) -ctest --output-on-failure -j $(nproc) +cmake "${CMAKE_ARGS[@]}" "${source_dir}" +cmake --build . -- -j "$(nproc)" +ctest --output-on-failure -j "$(nproc)" if [[ "${check_clang_tidy}" == "true" ]]; then cmake --build . --target check-clang-tidy @@ -78,4 +78,4 @@ fi popd -rm -rf ${build_dir} +rm -rf "${build_dir}"