2.0.7
This commit is contained in:
@ -6,7 +6,7 @@ endif()
|
||||
|
||||
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
|
||||
|
||||
function(myx_uncrustify target)
|
||||
function(myx_uncrustify NAME)
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
||||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT})
|
||||
endif()
|
||||
@ -33,8 +33,6 @@ function(myx_uncrustify target)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
if(NOT TARGET myx-uncrustify)
|
||||
add_custom_target(myx-uncrustify)
|
||||
endif()
|
||||
@ -46,30 +44,35 @@ function(myx_uncrustify target)
|
||||
endif()
|
||||
|
||||
# Динамически сгенерированные файлы исключаются
|
||||
get_target_property(s ${target} SOURCES)
|
||||
get_target_property(target_type ${NAME} TYPE)
|
||||
if(${target_type} STREQUAL "INTERFACE_LIBRARY")
|
||||
get_target_property(s ${NAME} INTERFACE_SOURCES)
|
||||
else()
|
||||
get_target_property(s ${NAME} SOURCES)
|
||||
endif()
|
||||
foreach(iter ${s})
|
||||
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
|
||||
if(pos EQUAL -1)
|
||||
list(APPEND src ${iter})
|
||||
endif()
|
||||
endforeach()
|
||||
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
||||
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
|
||||
COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc
|
||||
-c ${ARG_CONFIG}
|
||||
-o ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg)
|
||||
list(APPEND UNCRUSTIFY_OPTS -c ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg)
|
||||
-o ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg)
|
||||
list(APPEND UNCRUSTIFY_OPTS -c ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg)
|
||||
# cmake-format: off
|
||||
add_custom_target(${target}-uncrustify-check
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
||||
add_custom_target(${NAME}-uncrustify-check
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --check ${src})
|
||||
|
||||
list(APPEND UNCRUSTIFY_OPTS --replace --no-backup)
|
||||
add_custom_target(${target}-uncrustify
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
||||
add_custom_target(${NAME}-uncrustify
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --mtime ${src})
|
||||
|
||||
add_custom_target(${target}-uncrustify-append-comments
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
||||
add_custom_target(${NAME}-uncrustify-append-comments
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS}
|
||||
--set cmt_insert_class_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/classheader.txt
|
||||
--set cmt_insert_file_footer=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/filefooter.txt
|
||||
@ -78,7 +81,7 @@ function(myx_uncrustify target)
|
||||
--set cmt_insert_before_ctor_dtor=true --mtime ${src})
|
||||
# cmake-format: on
|
||||
|
||||
add_dependencies(myx-uncrustify ${target}-uncrustify)
|
||||
add_dependencies(myx-uncrustify-check ${target}-uncrustify-check)
|
||||
add_dependencies(myx-uncrustify-append-comments ${target}-uncrustify-append-comments)
|
||||
add_dependencies(myx-uncrustify ${NAME}-uncrustify)
|
||||
add_dependencies(myx-uncrustify-check ${NAME}-uncrustify-check)
|
||||
add_dependencies(myx-uncrustify-append-comments ${NAME}-uncrustify-append-comments)
|
||||
endfunction()
|
||||
|
Reference in New Issue
Block a user