diff --git a/MyxCMake/modules/MyxCMakeFormatSources.cmake b/MyxCMake/modules/MyxCMakeFormatSources.cmake index 42e278f..5498acf 100644 --- a/MyxCMake/modules/MyxCMakeFormatSources.cmake +++ b/MyxCMake/modules/MyxCMakeFormatSources.cmake @@ -1,6 +1,42 @@ +find_program(UNCRUSTIFY_EXE NAMES uncrustify) + +if(UNCRUSTIFY_EXE) + if(NOT EXISTS ${CMAKE_BINARY_DIR}/uncrustify-classheader.txt) + file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-classheader.txt CONTENT +"/** + * @class $(fclass) + * @brief TODO + * @details TODO + */") + endif() + + if(NOT EXISTS ${CMAKE_BINARY_DIR}/uncrustify-filefooter.txt) + file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-filefooter.txt CONTENT + "// EOF $(filename)") + endif() + + if(NOT EXISTS ${CMAKE_BINARY_DIR}/uncrustify-fileheader.txt) + file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-fileheader.txt CONTENT +"/** + * @file $(filename) + * @brief TODO + * @details TODO + */") + endif() + + if(NOT EXISTS ${CMAKE_BINARY_DIR}/uncrustify-funcheader.txt) + file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-funcheader.txt CONTENT +"/** + * @fn $(fclass)::$(function) + * $(javaparam) + * @details TODO + */") + endif() +endif() + + function(myx_cmake_format_sources target) - find_program(UNCRUSTIFY_EXE NAMES uncrustify) if(UNCRUSTIFY_EXE) get_target_property(__sources ${target} SOURCES) list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$") @@ -32,26 +68,7 @@ function(myx_cmake_format_sources target) add_custom_target(${target}-format-sources-uncrustify DEPENDS ${CMAKE_BINARY_DIR}/uncrustify.cfg COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --mtime ${__sources}) - file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-classheader.txt CONTENT -"/** - * @class $(fclass) - * @brief TODO - * @details TODO - */") - file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-filefooter.txt CONTENT - "// EOF $(filename)") - file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-fileheader.txt CONTENT -"/** - * @file $(filename) - * @brief TODO - * @details TODO - */") - file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-funcheader.txt CONTENT -"/** - * @fn $(fclass)::$(function) - * $(javaparam) - * @details TODO - */") + add_custom_target(${target}-doc-doxygen-append-comments DEPENDS ${CMAKE_BINARY_DIR}/uncrustify.cfg COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS}