Skip to content

refactor(cmake): CMake configuration files for improved readability#904

Open
SYaoJun wants to merge 2 commits intoapache:mainfrom
SYaoJun:0304_cmake_format
Open

refactor(cmake): CMake configuration files for improved readability#904
SYaoJun wants to merge 2 commits intoapache:mainfrom
SYaoJun:0304_cmake_format

Conversation

@SYaoJun
Copy link
Contributor

@SYaoJun SYaoJun commented Mar 4, 2026

Reason for this PR

fix: #903

  1. add cmake-format in pre-commit
  2. format all related cmake configuartion files
  3. enable CI check cmake-format

cmake-format.py referred to arrow cmake-format.py

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@codecov-commenter
Copy link

codecov-commenter commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.60%. Comparing base (b4bc86c) to head (b651f58).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #904   +/-   ##
=========================================
  Coverage     80.60%   80.60%           
  Complexity      615      615           
=========================================
  Files            94       94           
  Lines         10709    10709           
  Branches       1055     1055           
=========================================
  Hits           8632     8632           
  Misses         1837     1837           
  Partials        240      240           
Flag Coverage Δ
cpp 70.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SYaoJun SYaoJun force-pushed the 0304_cmake_format branch from b9e155d to 7afcd33 Compare March 4, 2026 15:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Introduces cmake-format to standardize formatting of CMake configuration across the repository (per #903), and applies the formatter to existing CMakeLists/cmake modules to improve readability and enforce consistency via automation.

Changes:

  • Add cmake-format as a pre-commit hook and run it in CI.
  • Reformat multiple CMakeLists.txt and .cmake modules across C++, Python, and Java build integrations.
  • Add a repository-level cmake-format configuration file.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
python/CMakeLists.txt Reformats Python build CMakeLists for consistent indentation/wrapping.
maven-projects/java/cmake/graphar-cpp.cmake Reformats Java-side ExternalProject build helper for GraphAr C++.
maven-projects/java/CMakeLists.txt Reformats Java JNI CMakeLists (options/globs/custom commands).
cpp/test/CMakeLists.txt Reformats test macro and link/include blocks for readability.
cpp/src/CMakeLists.txt Reformats core library build rules and Arrow linking blocks.
cpp/graphar-config-version.in.cmake Minor formatting adjustment in version check logic.
cpp/examples/CMakeLists.txt Reformats example discovery/build loop and link logic.
cpp/cmake/apache-arrow.cmake Reformats Arrow ExternalProject build configuration and target setup.
cpp/benchmarks/CMakeLists.txt Reformats benchmark macro and linking logic.
cpp/CMakeLists.txt Reformats top-level C++ project configuration and build options.
cmake-format.py Adds a cmake-format configuration file for consistent formatting rules.
.pre-commit-config.yaml Adds cmake-format hook to enforce formatting locally.
.github/workflows/ci.yml Adds CI step to run cmake-format via pre-commit.

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

Comment on lines +99 to +102
"-DARROW_JSON=ON"
"-DARROW_PYTHON=OFF"
"-DARROW_BUILD_BENCHMAKRS=OFF"
"-DARROW_BUILD_TESTS=OFF"
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

The Arrow CMake option name is misspelled as ARROW_BUILD_BENCHMAKRS (missing "R"). This will be ignored by Arrow and may accidentally build benchmarks. Use the correct ARROW_BUILD_BENCHMARKS option name in the CMake args list.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

accepted

Comment on lines +93 to +97
"-DARROW_PARQUET=ON"
"-DARROW_WITH_RE2=OFF"
"-DARROW_WITH_UTF8PROC=OFF"
"-DARROW_WITH_RE2=OFF"
"-DARROW_FILESYSTEM=ON"
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

GAR_ARROW_CMAKE_ARGS includes -DARROW_WITH_RE2=OFF twice. This duplication is redundant and can make it harder to audit the Arrow build configuration; remove the duplicate entry to keep the option list unambiguous.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

good suggestion!

Comment on lines +51 to 55
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.10
hooks:
- id: cmake-format

Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

The cmake-format hook is added, but the repository config file is named cmake-format.py and isn't referenced here. cmake-format typically auto-discovers .cmake-format.py/.cmake-format.yaml, so this setup may run with default formatting settings in CI and on contributors' machines. Rename the config to .cmake-format.py or pass the config explicitly via hook args (e.g., --config-files cmake-format.py).

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cmake-format.py also can find it.

Comment on lines +306 to +308
message(ERROR
"The OpenSSL must be greater than or equal to 1.1.0, current version is ${OPENSSL_VERSION}"
)
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

message(ERROR ...) isn't a valid CMake message mode and will itself error when this branch is hit. If the intent is to stop configuration when OpenSSL < 1.1.0 is detected, use message(FATAL_ERROR ...) (or SEND_ERROR if you want to continue processing).

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@SYaoJun SYaoJun force-pushed the 0304_cmake_format branch 2 times, most recently from dbac2b9 to 3b66a94 Compare March 10, 2026 15:31
@SYaoJun SYaoJun force-pushed the 0304_cmake_format branch from 3b66a94 to b651f58 Compare March 11, 2026 00:18
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.

[Style] Improve cmake readability and add cmake-format tools

3 participants