[cmake-developers] Code style auto-formatting
Brad King
brad.king at kitware.com
Mon May 9 13:14:17 EDT 2016
On 05/02/2016 10:08 AM, Brad King wrote:
> Next I'll look at the style updates themselves.
I've made some more preparatory commits:
Isolate formatted streaming blocks with clang-format off/on
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=64b55203
Move comments off of class access specifier lines
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=85425a3e
Help clang-format wrap after braces on long initializer lists
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=afca3735
Remove `//------...` horizontal separator comments
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0ac18d40
These changes improve the formatting output in some local
experiments.
With the earlier changes to the #include order we no longer need
to use any custom `IncludeCategories`.
Here is the `.clang-format` file I'd like to use:
---
# This configuration requires clang-format 3.8 or higher.
BasedOnStyle: Mozilla
AlignOperands: false
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterDefinitionReturnType: None
ColumnLimit: 79
IndentCaseLabels: false
Standard: Cpp03
...
Plus the custom one for Cpp11 in Tests/CompileFeatures.
The next few weeks will be a good time to do a one-shot
style change commit because the feature freeze for the
CMake 3.6 release is June 1. It is important to do sweeping
changes like this shortly before a release branch is created
because that way any fixes that must be backported to the
branch do not conflict with the style change. Furthermore
most fixes needed to the previous release have already been
done. If we don't do it now we will have to wait about
4 months for the next stable period.
If the above looks good I'll start an ANNOUNCE thread for
this to draw more attention to it. While it will be possible
to script style updates while rebasing topics across this
change, it will be simpler if developers start new topics
after the style change.
-Brad
More information about the cmake-developers
mailing list