[cmake-developers] [ANNOUNCE] CMake C++ coding style transition
Brad King
brad.king at kitware.com
Thu May 12 09:58:47 EDT 2016
Hi Folks,
As discussed previously on the developer list:
Code style auto-formatting
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/14969
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/14969/focus=15001
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/14969/focus=16307
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/14969/focus=16358
we've decided to change the C++ coding style within CMake to use a
more modern style that can be automatically formatted. We chose a
style defined by clang-format:
---
# This configuration requires clang-format 3.8 or higher.
BasedOnStyle: Mozilla
AlignOperands: false
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterDefinitionReturnType: None
ColumnLimit: 79
Standard: Cpp03
...
A simple example of the layout is:
bool foo(int a, int b)
{
if (a < b) {
return true;
} else {
return false;
}
}
This style is much more common than our old Whitesmiths-like style and
will be easier to maintain in many editors. Also the clang-format tool
can be used to maintain the format.
The transition will be implemented as a one-shot automated style conversion
recorded as a commit by "Kitware Robot". The use of this author will call
out the transition in `git blame` output that reaches it. I plan to perform
the final conversion sometime before the 3.6 release freeze so that fixes
for the release do not have to be backported to the old style.
For those of you with open topics it should be possible to rebase them
across the style transition automatically. I will include an empty commit
preceding the transition to aid with this. Its commit message will explain
what to do. I can help with the process for anyone that has trouble.
For reference, I've temporarily published an example topic performing the
transition here:
https://github.com/bradking/CMake/tree/clang-format-test
-Brad
More information about the cmake-developers
mailing list