Skip to content

Format CMake files and keep them formatted with a tool #7346

@echoix

Description

@echoix

Decide on what options we need for a CMake formatting/linting.

Since not as commonly used, probably integrating them with pre-commit would be easier. It could always be manually defined in our configuration file, if a pre-defined pre-commit config doesn’t exist.

There seems to be two alternatives to explore:
The setup used by QField uses cmake-format, and there is also gersemi.

However, cmake-format doesnt seem really active, last commit on main was 5 years ago, last release in august 2020. That might not be ideal, as the tool might not have a clue about CMake 4.0


FTR: for QField we use https://github.com/cheshirekow/cmake-format-precommit
it's not perfect but can be tuned by making additional commands available if someone is motivated https://github.com/opengisch/QField/blob/master/.cmake-format.yaml

https://github.com/opengisch/QField/blob/c7fbab2b1bb5e048389d9ca68aa83e7b7edaa759/.pre-commit-config.yaml#L56-L62

Originally posted by @m-kuhn in #7345 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions