2.0.21
This commit is contained in:
@ -6,12 +6,12 @@ endif()
|
||||
|
||||
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
|
||||
|
||||
function(myx_uncrustify NAME)
|
||||
function(myx_uncrustify TARGET_NAME)
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
||||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT})
|
||||
endif()
|
||||
|
||||
myx_skip_external_target(${NAME})
|
||||
myx_skip_external_target(${TARGET_NAME})
|
||||
|
||||
set(options)
|
||||
set(oneValueArgs CONFIG)
|
||||
@ -46,11 +46,11 @@ function(myx_uncrustify NAME)
|
||||
endif()
|
||||
|
||||
# Динамически сгенерированные файлы исключаются
|
||||
get_target_property(target_type ${NAME} TYPE)
|
||||
get_target_property(target_type ${TARGET_NAME} TYPE)
|
||||
if(${target_type} STREQUAL "INTERFACE_LIBRARY")
|
||||
get_target_property(s ${NAME} INTERFACE_SOURCES)
|
||||
get_target_property(s ${TARGET_NAME} INTERFACE_SOURCES)
|
||||
else()
|
||||
get_target_property(s ${NAME} SOURCES)
|
||||
get_target_property(s ${TARGET_NAME} SOURCES)
|
||||
endif()
|
||||
foreach(iter ${s})
|
||||
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
|
||||
@ -58,24 +58,26 @@ function(myx_uncrustify NAME)
|
||||
list(APPEND src ${iter})
|
||||
endif()
|
||||
endforeach()
|
||||
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
|
||||
|
||||
set(__fixed_config ${PROJECT_BINARY_DIR}/uncrustify-${TARGET_NAME}.cfg)
|
||||
|
||||
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-${TARGET_NAME}.cfg
|
||||
COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc
|
||||
-c ${ARG_CONFIG}
|
||||
-o ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg)
|
||||
list(APPEND UNCRUSTIFY_OPTS -c ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg)
|
||||
-c ${ARG_CONFIG} -o ${__fixed_config})
|
||||
list(APPEND __options -c ${__fixed_config})
|
||||
# cmake-format: off
|
||||
add_custom_target(${NAME}-uncrustify-check
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --check ${src})
|
||||
add_custom_target(${TARGET_NAME}-uncrustify-check
|
||||
DEPENDS ${__fixed_config}
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${__options} --check ${src})
|
||||
|
||||
list(APPEND UNCRUSTIFY_OPTS --replace --no-backup)
|
||||
add_custom_target(${NAME}-uncrustify
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --mtime ${src})
|
||||
list(APPEND __options --replace --no-backup)
|
||||
add_custom_target(${TARGET_NAME}-uncrustify
|
||||
DEPENDS ${__fixed_config}
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${__options} --mtime ${src})
|
||||
|
||||
add_custom_target(${NAME}-uncrustify-append-comments
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS}
|
||||
add_custom_target(${TARGET_NAME}-uncrustify-append-comments
|
||||
DEPENDS ${__fixed_config}
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${__options}
|
||||
--set cmt_insert_class_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/classheader.txt
|
||||
--set cmt_insert_file_footer=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/filefooter.txt
|
||||
--set cmt_insert_file_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/fileheader.txt
|
||||
@ -83,7 +85,7 @@ function(myx_uncrustify NAME)
|
||||
--set cmt_insert_before_ctor_dtor=true --mtime ${src})
|
||||
# cmake-format: on
|
||||
|
||||
add_dependencies(myx-uncrustify ${NAME}-uncrustify)
|
||||
add_dependencies(myx-uncrustify-check ${NAME}-uncrustify-check)
|
||||
add_dependencies(myx-uncrustify-append-comments ${NAME}-uncrustify-append-comments)
|
||||
add_dependencies(myx-uncrustify ${TARGET_NAME}-uncrustify)
|
||||
add_dependencies(myx-uncrustify-check ${TARGET_NAME}-uncrustify-check)
|
||||
add_dependencies(myx-uncrustify-append-comments ${TARGET_NAME}-uncrustify-append-comments)
|
||||
endfunction()
|
||||
|
Reference in New Issue
Block a user