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 AccessModifierOffset: 0
AlignEscapedNewlinesLeft: true AlignEscapedNewlinesLeft: true
AlignTrailingComments: false AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: false AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false AlwaysBreakTemplateDeclarations: false
BinPackArguments: false
BinPackParameters: false BinPackParameters: false
BreakBeforeBinaryOperators: false BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: false BreakBeforeTernaryOperators: false
@ -30,7 +31,7 @@ CommentPragmas: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 0 ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 0 ContinuationIndentWidth: 0
Cpp11BracedListStyle: true Cpp11BracedListStyle: false
DerivePointerAlignment: false DerivePointerAlignment: false
IndentCaseLabels: true IndentCaseLabels: true
IndentWidth: 4 IndentWidth: 4

View file

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