This commit is contained in:
2022-10-19 14:39:26 +03:00
parent 490b7a82d0
commit c32b2a85cc
15 changed files with 437 additions and 329 deletions

View File

@ -46,16 +46,19 @@ function(myx_uncrustify TARGET_NAME)
endif()
# Динамически сгенерированные файлы исключаются
get_target_property(target_type ${TARGET_NAME} TYPE)
if(${target_type} STREQUAL "INTERFACE_LIBRARY")
get_target_property(s ${TARGET_NAME} INTERFACE_SOURCES)
else()
get_target_property(s ${TARGET_NAME} SOURCES)
get_target_property(__s1 ${TARGET_NAME} INTERFACE_SOURCES)
if(__s1)
list(APPEND __all_sources ${__s1})
endif()
foreach(iter ${s})
get_target_property(__s2 ${TARGET_NAME} SOURCES)
if(__s2)
list(APPEND __all_sources ${__s2})
endif()
foreach(iter ${__all_sources})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
if(pos EQUAL -1)
list(APPEND src ${iter})
list(APPEND __sources ${iter})
endif()
endforeach()
@ -68,12 +71,12 @@ function(myx_uncrustify TARGET_NAME)
# cmake-format: off
add_custom_target(${TARGET_NAME}-uncrustify-check
DEPENDS ${__fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${__options} --check ${src})
COMMAND ${UNCRUSTIFY_EXE} ${__options} --check ${__sources})
list(APPEND __options --replace --no-backup)
add_custom_target(${TARGET_NAME}-uncrustify
DEPENDS ${__fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${__options} --mtime ${src})
COMMAND ${UNCRUSTIFY_EXE} ${__options} --mtime ${__sources})
add_custom_target(${TARGET_NAME}-uncrustify-append-comments
DEPENDS ${__fixed_config}
@ -82,7 +85,7 @@ function(myx_uncrustify TARGET_NAME)
--set cmt_insert_file_footer=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/filefooter.txt
--set cmt_insert_file_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/fileheader.txt
--set cmt_insert_func_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/funcheader.txt
--set cmt_insert_before_ctor_dtor=true --mtime ${src})
--set cmt_insert_before_ctor_dtor=true --mtime ${__sources})
# cmake-format: on
add_dependencies(myx-uncrustify ${TARGET_NAME}-uncrustify)