From b3cdb38c0b2ebab71a75b4fe8329b2084313b8d9 Mon Sep 17 00:00:00 2001 From: Evgenii Zheltonozhskii Date: Tue, 5 Jun 2018 19:10:28 +0300 Subject: [PATCH] Add clang-format target to CMake and Travis --- .clang-format | 43 +++++++++++++++++++++++++++++++ .travis/build.sh | 3 +++ .travis/os_build.sh | 4 +-- CMakeLists.txt | 3 +++ modules/clang-cxx-dev-tools.cmake | 43 +++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 .clang-format create mode 100644 modules/clang-cxx-dev-tools.cmake diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..a5fc00726 --- /dev/null +++ b/.clang-format @@ -0,0 +1,43 @@ +--- +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: false +AlignEscapedNewlines: false +AlignOperands: true +AlignTrailingComments: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +BinPackArguments: true +BinPackParameters: true +BreakBeforeBraces: Attach +BreakBeforeTernaryOperators: false +BreakConstructorInitializers: BeforeComma +BreakStringLiterals: true +ColumnLimit: 120 +ConstructorInitializerAllOnOneLineOrOnePerLine: false +Cpp11BracedListStyle: true +DerivePointerAlignment: true +IndentCaseLabels: false +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +PointerAlignment: Right +SortIncludes: true +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +Standard: Cpp11 +TabWidth: 4 +UseTab: ForIndentation +ForEachMacros: [ for_const, foreach, Q_FOREACH, BOOST_FOREACH ] +... diff --git a/.travis/build.sh b/.travis/build.sh index a91387fd5..5eff2fa6f 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -3,5 +3,8 @@ set -x cmake -G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE $EXTRA_CMAKE_FLAGS -DBUILD_TESTING=ON .. || exit 1 +# grep returns number of items found. each change is enclosed into +# tag in the xml. Thus if no changes needed, 0 will be returned +cmake --build . --target clang-format-ci -- -v | grep -c "