Skip to content

Commit

Permalink
Adding support for compilation target 'format'
Browse files Browse the repository at this point in the history
* clang-format 6.0 or above
* TODO: skip files in doc/
  • Loading branch information
kunaltyagi committed Jun 23, 2019
1 parent 0d78358 commit 5854fd7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
AccessModifierOffset: '0'
AlwaysBreakAfterReturnType : All
AlwaysBreakTemplateDeclarations: 'true'
BreakBeforeBraces: Linux
Language: Cpp
NamespaceIndentation: All
SpaceBeforeParens: Always
Standard: Cpp11
TabWidth: 2
UseTab: Never
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ endif()
include("${PCL_SOURCE_DIR}/cmake/pcl_verbosity.cmake")
include("${PCL_SOURCE_DIR}/cmake/pcl_targets.cmake")
include("${PCL_SOURCE_DIR}/cmake/pcl_options.cmake")
include("${PCL_SOURCE_DIR}/cmake/clang-format.cmake")

# Enable verbose timing display?
if(CMAKE_TIMING_VERBOSE AND UNIX)
Expand Down
22 changes: 22 additions & 0 deletions cmake/clang-format.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
file(GLOB_RECURSE
ALL_CXX_SOURCE_FILES
*.[ch] *.[chi]pp *.[chi]xx *.cppm *.cc *.hh *.ii *.[CHI]
)

find_program(CLANG_FORMAT
NAMES clang-format-9.0 clang-format-8.0 clang-format-7.0 clang-format-6.0
clang-format-9 clang-format-8 clang-format-7 clang-format-6
)

if(CLANG_FORMAT)
add_custom_target(
format
COMMAND ${CLANG_FORMAT}
-i
-style=file
${ALL_CXX_SOURCE_FILES}
)
message(STATUS "Using ${CLANG_FORMAT} for target 'format'")
else()
message(WARNING "No suitable clang-format (>=6.0) found")
endif()

0 comments on commit 5854fd7

Please sign in to comment.