cmake: setup formatting targets

for clang-tidy and astyle + minor formatting adjustments to clang-format config
This commit is contained in:
derselbst 2018-06-21 12:14:05 +02:00
parent 19b525af9b
commit 90c2d76709
2 changed files with 28 additions and 11 deletions

View file

@ -1,12 +1,13 @@
AccessModifierOffset: 0
AlignEscapedNewlinesLeft: true
AlignTrailingComments: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: false
@ -30,7 +31,7 @@ CommentPragmas: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 0
Cpp11BracedListStyle: true
Cpp11BracedListStyle: false
DerivePointerAlignment: false
IndentCaseLabels: true
IndentWidth: 4

View file

@ -334,9 +334,9 @@ find_program( CLANG_TIDY
message ( STATUS "Found clang-tidy" )
# whenever clang-tidy is available, use it to automatically add braces after ever "make"
if ( WITH_PROFILING )
# set ( CMAKE_C_CLANG_TIDY "clang-tidy" )
set ( CMAKE_C_CLANG_TIDY "clang-tidy" )
else ( WITH_PROFILING )
# set ( CMAKE_C_CLANG_TIDY "clang-tidy;-checks=-*,readability-braces-around-statements;-format-style=file" )
set ( CMAKE_C_CLANG_TIDY "clang-tidy;-checks=-*,readability-braces-*;-format-style=file" )
endif ( WITH_PROFILING )
endif ( CLANG_TIDY )
endif ( CMAKE_VERSION VERSION_GREATER "3.6.0" )
@ -356,17 +356,33 @@ file(GLOB_RECURSE
)
# Adding clang-format target if executable is found
find_program ( CLANG_FORMAT "clang-format" )
if ( CLANG_FORMAT )
# find_program ( CLANG_FORMAT "clang-format" )
# if ( CLANG_FORMAT )
# add_custom_target(
# clang-format
# COMMAND ${CLANG_FORMAT}
# -i
# -style=file
# ${ALL_SOURCE_FILES}
# )
# endif(CLANG_FORMAT)
find_program ( ASTYLE "astyle" )
if ( ASTYLE )
add_custom_target(
format
COMMAND ${CLANG_FORMAT}
-i
-style=file
COMMAND ${ASTYLE}
-A1
-xb
-j
-k3
-p
-f
-n
-U
${ALL_SOURCE_FILES}
)
endif(CLANG_FORMAT)
endif(ASTYLE)
if(NOT enable-pkgconfig)