Skip to content

ci: integrate gersemi to format and lint CMake files - #7663

Closed
ArthPatel1502 wants to merge 12 commits into
OSGeo:mainfrom
ArthPatel1502:format-cmake-7346
Closed

ArthPatel1502 wants to merge 12 commits into
OSGeo:mainfrom
ArthPatel1502:format-cmake-7346

Conversation

@ArthPatel1502

Copy link
Copy Markdown
Contributor

Description

Addresses #7346.

This PR integrates Gersemi into the project's pre-commit pipeline to automatically format and lint CMake layout files (CMakeLists.txt and .cmake files).

Per the maintainer discussion on the tracking issue, Gersemi was chosen over cmake-format because it is actively maintained, supports modern CMake features, and provides an official pre-commit hook interface out of the box.

Changes Made

  • Appended the BlankSpruce/gersemi-pre-commit hook repository to .pre-commit-config.yaml.
  • Configured it to run automatically on any staged files during pre-commit checks.

Verification Plan

  1. Ran pre-commit clean to clear localized hook environment definitions.
  2. Evaluated configuration robustness globally via pre-commit run gersemi --all-files.

@github-actions github-actions Bot added the CI Continuous integration label Jul 10, 2026
@echoix

echoix commented Jul 10, 2026

Copy link
Copy Markdown
Member

Ok, nice, can you apply the changes as you mentioned you did in your verification plan? As such, we’ll see how the changes and formatting looks like

@echoix

echoix commented Jul 10, 2026

Copy link
Copy Markdown
Member

And possibly add our definitions if needed

@github-actions github-actions Bot added GUI wxGUI related vector Related to vector data processing raster Related to raster data processing temporal Related to temporal data processing translation Message translation related database Related to database management libraries module docs general display imagery tests Related to Test Suite raster3d misc CMake labels Jul 13, 2026
@ArthPatel1502

Copy link
Copy Markdown
Contributor Author

And possibly add our definitions if needed

Ok, nice, can you apply the changes as you mentioned you did in your verification plan? As such, we’ll see how the changes and formatting looks like

@echoix Done! I've run the gersemi hook globally across the repository and forced-pushed the formatted CMake files to this branch so you can inspect the layout changes directly in the file diff.

Regarding definitions: Gersemi handles standard CMake setups cleanly out of the box with its built-in defaults. If the team decides on specific style rules down the road (like strict line-wrapping limits or lowercase/uppercase command preferences), we can easily append an args: section or supply a configuration file in a follow-up task. Let me know if the current automated formatting looks good to you!

@github-actions github-actions Bot 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.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

pre-commit

[pre-commit] reported by reviewdog 🐶

message(STATUS "Looking for LAPACKE_dgesv - not found")


[pre-commit] reported by reviewdog 🐶

find_package(SQLite3 REQUIRED)
if(NOT TARGET SQLite3::SQLite3) # CMake < 4.3
add_library(SQLite3::SQLite3 ALIAS SQLite::SQLite3)
endif()


[pre-commit] reported by reviewdog 🐶

if(NOT WITH_CBLAS)
message(FATAL_ERROR "LAPACKE support requires CBLAS")
endif()
if(NOT LAPACKE_PREFER_PKGCONFIG)
set(LAPACKE_PREFER_PKGCONFIG ON)
endif()
find_package(LAPACKE REQUIRED)

Comment thread cmake/find_scripts/FindCBLAS.cmake Resolved
Comment thread cmake/find_scripts/FindCBLAS.cmake Resolved
Comment thread cmake/find_scripts/FindCBLAS.cmake Resolved
Comment thread cmake/find_scripts/FindCBLAS.cmake Resolved
Comment thread cmake/find_scripts/FindCBLAS.cmake Resolved
Comment thread cmake/find_scripts/FindLAPACKE.cmake Resolved
Comment thread cmake/find_scripts/FindLAPACKE.cmake Resolved
Comment thread cmake/find_scripts/FindLAPACKE.cmake Resolved
Comment thread cmake/find_scripts/FindLAPACKE.cmake Resolved
Comment thread cmake/find_scripts/FindLAPACKE.cmake Resolved
@echoix

echoix commented Jul 13, 2026

Copy link
Copy Markdown
Member

Just so you know, even if the PR would be ready, maybe we would wait for the end of the week before merging, there are many CMake PRs currently worked on during the community meeting, so it would just force all of them to reupdate their branches.

I'll take a look at the PR soon

@echoix echoix linked an issue Jul 13, 2026 that may be closed by this pull request
@echoix echoix changed the title ci: integrate gersemi to format and lint CMake files (#7346) ci: integrate gersemi to format and lint CMake files Jul 13, 2026
@echoix

echoix commented Jul 13, 2026

Copy link
Copy Markdown
Member

Could you actually run pre-commit on all files, just like what we would do after merging this PR?

@echoix

echoix commented Jul 14, 2026

Copy link
Copy Markdown
Member

I'm working on this PR locally since yesterday

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Continuous integration CMake database Related to database management display docs general GUI wxGUI related imagery libraries misc module raster Related to raster data processing raster3d temporal Related to temporal data processing tests Related to Test Suite translation Message translation related vector Related to vector data processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Format CMake files and keep them formatted with a tool

2 participants