Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If clang-format can be found at config time, then a build target will be established that allows you to `make clang-format`. Running this does not cause any actual compiles, but will reformat all the .h and .cpp files in the code base, according to the .clang-format configuration. Cache variables CLANG_FORMAT_INCLUDES and CLANG_FORMAT_EXCLUDES provides patterns for any files to include (default: `"*.h;*.cpp"`) or exclude, respectively. Files that you are sure should never be reformatted can be added explicitly to the CLANG_FORMAT_EXCLUDES default in clang-format.cmake. Note that there will be some source modules which, in whole or in part, you know you don't want to be reformatted (sometimes a nonstandard formatting is much clearer than anything clang-format can be coaxed into doing, such is often the case for tables). In that case you can turn it off with the comment // clang-format off ... code that is excluded from reformatting ... // clang-format on The CMake implementation of finding clang-format and adding this target was largely borrowed from that in OpenImageIO's build system (also the same BSD-3-Clause license). This patch only establishes the build-time target so that you can run it by hand, but does not (in this commit) reformat any of the source. There are a LOT of diffs! We may want to fine-tune the .clang-format for a while before we take the plunge of actually checking in the reformatted code and then enforcing the formatting thereafter. (Pro tip: run `make clang-format` only when you have no uncommitted edits. If you then don't like the formatting it imposes, you can back out of it all with `git checkout HEAD --force`.)
- Loading branch information