# clang-format integration

**URL:** https://discourse.cmake.org/t/clang-format-integration/3358
**Category:** Code
**Tags:** comp:clang
**Created:** [May 18, 2021, 7:44am UTC](https://discourse.cmake.org/t/clang-format-integration/3358 "2021-05-18T07:44:43Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![jwm](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jwm/32/654_2.png) [@jwm](https://discourse.cmake.org/u/jwm)
#### Post date: [May 25, 2021, 7:41pm UTC](https://discourse.cmake.org/t/clang-format-integration/3358/9 "2021-05-25T19:41:48Z")

</div>

@cmak , I wanted the same thing. @ben.boeckel walked through the philosophical/practical aspects of why this should not be done [here](https://discourse.cmake.org/t/cmake-pre-build-command/1083/11).

You can configure a pre-commit hook for `git` to run `clang-format` over just the lines changed by the commit, but I don’t like doing that because that means I’m committing code I haven’t even tried to build.

What I ended up doing was changing my automated build (Bamboo) to run `clang-format` over the entire source tree and fail if any file was modified. This makes the enforcement of formatting a CI step as Ben suggested; your build fails very quickly if you didn’t do the formatting like you should.

---

_[View the full topic](https://discourse.cmake.org/t/clang-format-integration/3358)._
