Skip to content

Commit

Permalink
cmake: setup formatting targets
Browse files Browse the repository at this point in the history
for clang-tidy and astyle + minor formatting adjustments to clang-format config
  • Loading branch information
derselbst committed Jun 24, 2018
1 parent 19b525a commit 90c2d76
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
5 changes: 3 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -30,7 +31,7 @@ CommentPragmas: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 0
Cpp11BracedListStyle: true
Cpp11BracedListStyle: false
DerivePointerAlignment: false
IndentCaseLabels: true
IndentWidth: 4
Expand Down
34 changes: 25 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand All @@ -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)

Expand Down

0 comments on commit 90c2d76

Please sign in to comment.