Поддержка uncrustify

This commit is contained in:
Andrei Astafev 2019-07-19 10:55:17 +03:00
parent eabbde0701
commit eb52f0f77c
2 changed files with 18 additions and 0 deletions

View File

@ -37,6 +37,7 @@ include(CMLibCodeAnalysisClazy)
include(CMLibSanitizers) include(CMLibSanitizers)
include(cotire) include(cotire)
include(CMLibFormatSources)
include(CMLibBreathe) include(CMLibBreathe)
include(CMLibQtTranslation) include(CMLibQtTranslation)
include(CMLibToday) include(CMLibToday)

17
CMLibFormatSources.cmake Normal file
View File

@ -0,0 +1,17 @@
function(add_uncrustify_format)
list(GET ARGN 0 _target)
set(_sources ${ARGN})
list(REMOVE_AT _sources 0)
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
if(UNCRUSTIFY_EXE)
if(NOT TARGET uncrustify-format)
add_custom_target(uncrustify-format)
endif()
add_custom_target(uncrustify-format-${_target}
COMMAND ${UNCRUSTIFY_EXE} -lCPP --replace --no-backup ${_sources})
add_dependencies(uncrustify-format uncrustify-format-${_target})
else()
message(WARNING "Uncrustify is not found")
endif()
endfunction()