[cmake-developers] [ANNOUNCE] CMake C++ coding style transition

Daniel Pfeifer daniel at pfeifer-mail.de
Thu May 12 22:28:17 EDT 2016


On Thu, May 12, 2016 at 7:58 AM, Brad King <brad.king at kitware.com> wrote:
> 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;
>    }
>  }

In a next step, we can use clang-tidy to clean up the above to:

bool foo(int a, int b)
{
  return a < b;
}

:-)


More information about the cmake-developers mailing list