From eb52f0f77cae4fe1fbbbf5455f9144a5ab52a365 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Fri, 19 Jul 2019 10:55:17 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=BA=D0=B0=20uncrustify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMLibCommon.cmake | 1 + CMLibFormatSources.cmake | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 CMLibFormatSources.cmake diff --git a/CMLibCommon.cmake b/CMLibCommon.cmake index 5a69215..d7b2910 100644 --- a/CMLibCommon.cmake +++ b/CMLibCommon.cmake @@ -37,6 +37,7 @@ include(CMLibCodeAnalysisClazy) include(CMLibSanitizers) include(cotire) +include(CMLibFormatSources) include(CMLibBreathe) include(CMLibQtTranslation) include(CMLibToday) diff --git a/CMLibFormatSources.cmake b/CMLibFormatSources.cmake new file mode 100644 index 0000000..3e07567 --- /dev/null +++ b/CMLibFormatSources.cmake @@ -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()