cpp-best-practices / gui_starter_template

A template CMake project to get you started with C++ and tooling
The Unlicense
2.5k stars 447 forks source link

Support clang-format #212

Closed marcpawl closed 2 years ago

marcpawl commented 2 years ago

cmake --build ./build --target clangformat

Code taken from https://github.com/zemasoft/clangformat-cmake

I am pretty much a cut and past CMake guy, so please look at this closely before accepting.

ddalcino commented 2 years ago

We already have this running in CI, triggered on every pull request: https://github.com/cpp-best-practices/cpp_starter_project/blob/main/.github/workflows/auto-clang-format.yml

As far as I can tell, the difference between this PR and what we already have is that this PR gives you an extra build target that runs clang-format. Do we need this?

If a user is concerned that clang-format isn't running often enough, the auto-clang-format.yml action can be configured to run on every push, rather than only on pull requests.

marcpawl commented 2 years ago

In my case I wanted the target so I can have things formatted prior to making the commit. For example doing a git diff. I have users who edit code with vi and formatting gets messed up. I wanted to have a nice easy way that formats everything for them.

BTW, we are not using GITHUB.