diff options
author | Christoph Cullmann <cullmann@kde.org> | 2019-10-20 20:00:56 +0200 |
---|---|---|
committer | Christoph Cullmann <cullmann@kde.org> | 2019-10-20 20:00:59 +0200 |
commit | 235fcabf50189c5a89b5f6664fc5e01657ddc65c (patch) | |
tree | dfbc13003b06eb05cd9bcddf86ce41a0359768ff /kde-modules/clang-format.cmake | |
parent | ebd61cd51ab5b66ab70bbc918cb4007da1a9af4c (diff) | |
download | extra-cmake-modules-235fcabf50189c5a89b5f6664fc5e01657ddc65c.tar.gz extra-cmake-modules-235fcabf50189c5a89b5f6664fc5e01657ddc65c.tar.bz2 |
Provide clang-format target with a KDE Frameworks style file
Summary:
Provides a clang-format target if wanted
Example usage:
include(KDEClangFormat)
# add clang-format target for all our real source files
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES autotests/src/*.cpp autotests/src/*.h src/*.cpp src/*.h templates/*.cpp templates/*.h)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
Test Plan: Tried that above usage thingy in KTextEditor
Reviewers: #frameworks, dfaure
Reviewed By: dfaure
Subscribers: zzag, sitter, mwolff, ochurlaud, nalvarez, kossebau, aacid, davidedmundson, dhaumann, apol, ognarb, kde-frameworks-devel, kde-buildsystem
Tags: #frameworks, #build_system
Differential Revision: https://phabricator.kde.org/D24568
Diffstat (limited to 'kde-modules/clang-format.cmake')
-rw-r--r-- | kde-modules/clang-format.cmake | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/kde-modules/clang-format.cmake b/kde-modules/clang-format.cmake new file mode 100644 index 00000000..21f10857 --- /dev/null +++ b/kde-modules/clang-format.cmake @@ -0,0 +1,88 @@ +--- +# SPDX-License-Identifier: MIT +# +# Copyright (C) 2019 Christoph Cullmann <cullmann@kde.org> +# Copyright (C) 2019 Gernot Gebhard <gebhard@absint.com> +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# Style for C++ +Language: Cpp + +# base is WebKit coding style: http://www.webkit.org/coding/coding-style.html +# below are only things set that diverge from this style! +BasedOnStyle: WebKit + +# enforce C++11 (e.g. for std::vector<std::vector<lala>> +Standard: Cpp11 + +# 4 spaces indent +TabWidth: 4 + +# 3 * 80 wide lines +ColumnLimit: 240 + +# sort includes inside line separated groups +SortIncludes: true + +# break before braces on function, namespace and class definitions. +BreakBeforeBraces: Linux + +# CrlInstruction *a; +PointerAlignment: Right + +# horizontally aligns arguments after an open bracket. +AlignAfterOpenBracket: Align + +# align trailing comments +AlignTrailingComments: true + +# don't move all parameters to new line +AllowAllParametersOfDeclarationOnNextLine: false + +# no single line functions +AllowShortFunctionsOnASingleLine: None + +# always break before you encounter multi line strings +AlwaysBreakBeforeMultilineStrings: true + +# don't move arguments to own lines if they are not all on the same +BinPackArguments: false + +# don't move parameters to own lines if they are not all on the same +BinPackParameters: false + +# don't break binary ops +BreakBeforeBinaryOperators: None + +# format C++11 braced lists like function calls +Cpp11BracedListStyle: true + +# remove empty lines +KeepEmptyLinesAtTheStartOfBlocks: false + +# no namespace indentation to keep indent level low +NamespaceIndentation: None + +# we use template< without space. +SpaceAfterTemplateKeyword: false + +# macros for which the opening brace stays attached. +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ] |