Problem: clang-format not run on CI

Solution: add clang-format to cmake, and add another travis-ci build type
This commit is contained in:
sigiesec
2018-02-01 14:18:02 +01:00
parent 41f459e1dc
commit 4161793d19
5 changed files with 62 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
# additional target to perform clang-format run, requires clang-format
# get all project files
file(GLOB_RECURSE ALL_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/*.cpp ${CMAKE_SOURCE_DIR}/*.h ${CMAKE_SOURCE_DIR}/*.hpp )
if("${CLANG_FORMAT}" STREQUAL "")
set(CLANG_FORMAT "clang-format")
endif()
add_custom_target(
clang-format
COMMAND ${CLANG_FORMAT} -style=file -i ${ALL_SOURCE_FILES}
)
function(JOIN VALUES GLUE OUTPUT)
string (REPLACE ";" "${GLUE}" _TMP_STR "${VALUES}")
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
endfunction()
configure_file(builds/cmake/clang-format-check.sh.in clang-format-check.sh @ONLY)
add_custom_target(
clang-format-check
COMMAND chmod +x clang-format-check.sh
COMMAND ./clang-format-check.sh
#COMMAND ${CLANG_FORMAT} -style=file -output-replacements-xml ${ALL_SOURCE_FILES} >clang-format-replacements.xml
#COMMAND grep \"<replacement \" clang-format-replacements.xml >/dev/null && exit 1
COMMENT "Checking correct formatting according to .clang-format file"
)
add_custom_target(
clang-format-diff
COMMAND ${CLANG_FORMAT} -style=file -i ${ALL_SOURCE_FILES}
COMMAND git diff ${ALL_SOURCE_FILES}
COMMENT "Formatting with clang-format and showing differences with latest commit"
)