feat(cmake): add find package modules by zjw1111 · Pull Request #7 · apache/paimon-cpp · GitHub
Skip to content

feat(cmake): add find package modules - #7

Merged
leaves12138 merged 1 commit into
apache:mainfrom
zjw1111:migrate/cmake-find-modules
May 25, 2026
Merged

feat(cmake): add find package modules#7
leaves12138 merged 1 commit into
apache:mainfrom
zjw1111:migrate/cmake-find-modules

Conversation

@zjw1111

@zjw1111 zjw1111 commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Purpose

Linked issue: N/A

Migrate CMake find-package modules from the Alibaba-origin C++ repository into the Apache repository. These modules provide alternate package discovery for Arrow, Avro, GTest, LZ4, ORC, Protobuf, RE2, RapidJSON, Snappy, TBB, ZLIB, fmt, glog, zstd, plus shared FindPackageUtils.cmake helpers.

The migrated files keep their source paths under cmake_modules/. Alibaba-owned headers were converted to the ASF CMake-style license header used in this repository. No files needed original third-party license preservation, and no requested files were skipped.

Tests

  • python3 /home/jinli.zjw/.codex/skills/paimon-cpp-migrate/scripts/check_migration_batch.py --files ...
  • git diff --cached --check
  • Compared migrated file bodies against source files after license-header removal
  • cmake -P cmake_modules/FindPackageUtils.cmake

API and Format

No public C++ API, storage format, or protocol changes.

Documentation

No user-facing documentation changes.

Generative AI tooling

Migrate-by: OpenAI Codex

Copilot AI review requested due to automatic review settings May 22, 2026 10:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a set of alternative CMake Find*Alt.cmake modules (plus shared utilities) to locate common native dependencies via config packages first, then fall back to pkg-config / manual search, while exposing consistent imported targets/variables to the rest of the build.

Changes:

  • Introduces FindPackageUtils.cmake and a paimon_find_target_headers() helper to derive header roots from imported targets.
  • Adds new Find<Dep>Alt.cmake modules for several third-party dependencies (zstd, glog, fmt, ZLIB, TBB, Snappy, RapidJSON, RE2, Protobuf, ORC, LZ4, GTest, Avro, Arrow).
  • Creates imported interface/unknown targets (e.g., zstd, fmt, glog, tbb, etc.) when upstream packages don’t provide the expected canonical target names.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
cmake_modules/FindzstdAlt.cmake Finds zstd via config targets or pkg-config/manual and defines a canonical zstd target + variables
cmake_modules/FindglogAlt.cmake Finds glog via config targets or pkg-config/manual and defines a canonical glog target
cmake_modules/FindfmtAlt.cmake Finds fmt via config targets or pkg-config/manual and defines a canonical fmt target + variables
cmake_modules/FindZLIBAlt.cmake Finds ZLIB via config or manual search and defines a canonical zlib target + variables
cmake_modules/FindTBBAlt.cmake Finds TBB via config targets or pkg-config/manual and defines a canonical tbb target
cmake_modules/FindSnappyAlt.cmake Finds Snappy via config targets or pkg-config/manual and defines a canonical snappy target + variables
cmake_modules/FindRapidJSONAlt.cmake Finds RapidJSON via config targets or manual search and defines a canonical RapidJSON target
cmake_modules/FindRE2Alt.cmake Finds RE2 via config targets or pkg-config/manual and defines/uses re2::re2
cmake_modules/FindProtobufAlt.cmake Finds Protobuf via config targets or pkg-config/manual and defines libprotobuf, libprotoc, protoc targets
cmake_modules/FindPackageUtils.cmake Adds paimon_find_target_headers() utility for extracting header include roots from targets
cmake_modules/FindORCAlt.cmake Finds ORC via config targets or pkg-config/manual and defines orc::orc target with dependency links
cmake_modules/FindLZ4Alt.cmake Finds LZ4 via config targets or pkg-config/manual and defines a canonical lz4 target + variables
cmake_modules/FindGTestAlt.cmake Finds GTest via config targets or manual search and sets a link toolchain list
cmake_modules/FindAvroAlt.cmake Finds avro-cpp via pkg-config/manual and defines canonical avro imported target + variables
cmake_modules/FindArrowAlt.cmake Finds Arrow/Parquet/Dataset/Acero via config targets and defines canonical arrow* targets

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +19 to +26
set(options NO_DEFAULT_PATH)
set(one_value_args)
set(multi_value_args NAMES HINTS PATH_SUFFIXES)
cmake_parse_arguments(ARG
"${options}"
"${one_value_args}"
"${multi_value_args}"
${ARGN})
if(ARG_PATH_SUFFIXES)
list(APPEND _find_args PATH_SUFFIXES ${ARG_PATH_SUFFIXES})
endif()
list(APPEND _find_args NO_DEFAULT_PATH)
Comment on lines +35 to +39
if(_PAIMON_ORC_TARGET)
if(NOT TARGET orc::orc)
add_library(orc::orc INTERFACE IMPORTED)
target_link_libraries(orc::orc INTERFACE ${_PAIMON_ORC_TARGET})
endif()
Comment on lines +52 to +54
get_target_property(ORC_INCLUDE_DIR orc::orc INTERFACE_INCLUDE_DIRECTORIES)
set(ORCAlt_FOUND TRUE)
else()
Comment on lines +42 to +50
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(glogAlt REQUIRED_VARS GLOG_INCLUDE_DIR)

if(glogAlt_FOUND AND NOT TARGET glog)
add_library(glog INTERFACE IMPORTED)
set_target_properties(glog PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${GLOG_INCLUDE_DIR}")
target_link_libraries(glog INTERFACE ${_PAIMON_GLOG_TARGET})
endif()
PROPERTIES IMPORTED_LOCATION "${RE2_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES
"${RE2_INCLUDE_DIR}")
set(RE2_LIBRARIES "${RE2_LIBRARY}")
Comment on lines +32 to +38
paimon_find_target_headers(ZLIB_INCLUDE_DIR
ZLIB::ZLIB
NAMES
zlib.h
HINTS
${ZLIB_INCLUDE_DIRS}
${_PAIMON_ZLIB_FIND_ARGS})
Co-authored-by: Socrates <suxiaogang223@icloud.com>
@zjw1111
zjw1111 force-pushed the migrate/cmake-find-modules branch from e8a748f to b67820f Compare May 25, 2026 05:04
@zjw1111

zjw1111 commented May 25, 2026

Copy link
Copy Markdown
Collaborator Author

@leaves12138 leaves12138 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for migrating the CMake find package modules. I compared all added modules with the source snapshot; they match the staged migration with ASF header normalization. The files have standard ASF headers, no line-ending/trailing-whitespace issues, parse cleanly via a lightweight cmake -P include smoke check, and the PR can merge cleanly into current main.

Non-blocking note: the existing Apache Arrow attribution in LICENSE already lists the earlier CMake build modules, but it does not list these new Find*Alt.cmake modules. I do not see an explicit third-party/adapted marker in these files, so I am not blocking on it, but we may want to keep the build-module attribution list in LICENSE consistent in a follow-up.

LGTM.

@leaves12138
leaves12138 merged commit b12061c into apache:main May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants