diff --git a/CMLibFormatSources.cmake b/CMLibFormatSources.cmake index 8c1ea81..2c25b81 100644 --- a/CMLibFormatSources.cmake +++ b/CMLibFormatSources.cmake @@ -12,10 +12,18 @@ function(add_format_sources target) UNCRUSTIFY_OPTS -lCPP --replace - --no-backup - --mtime) + --no-backup) + if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/comments.cfg) + if(NOT TARGET doc-add-comments) + add_custom_target(doc-add-comments) + endif() + set(COMMENTS_OPTS ${UNCRUSTIFY_OPTS} -c ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/comments.cfg) + add_custom_target(doc-add-comments-uncrustify-${target} COMMAND ${UNCRUSTIFY_EXE} ${COMMENTS_OPTS} + ${_sources}) + add_dependencies(doc-add-comments doc-add-comments-uncrustify-${target}) + endif() if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg) - list(APPEND UNCRUSTIFY_OPTS -c ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg) + list(APPEND UNCRUSTIFY_OPTS --mtime -c ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg) endif() add_custom_target(format-sources-uncrustify-${target} COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} ${_sources})