Переименования
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.17.0)
|
||||
set(MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
|
||||
endif()
|
||||
|
||||
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
|
||||
|
||||
function(myx_uncrustify TARGET_NAME)
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.17.0)
|
||||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT})
|
||||
endif()
|
||||
|
||||
@ -45,50 +45,50 @@ function(myx_uncrustify TARGET_NAME)
|
||||
endif()
|
||||
|
||||
# Динамически сгенерированные файлы исключаются
|
||||
get_target_property(__target_type ${TARGET_NAME} TYPE)
|
||||
if((${__target_type} STREQUAL "INTERFACE_LIBRARY") AND (${CMAKE_VERSION} VERSION_LESS "3.17.0"))
|
||||
get_target_property(__s1 ${TARGET_NAME} INTERFACE_SOURCES)
|
||||
if(__s1)
|
||||
list(APPEND __all_sources ${__s1})
|
||||
get_target_property(target_type ${TARGET_NAME} TYPE)
|
||||
if((${target_type} STREQUAL "INTERFACE_LIBRARY") AND (${CMAKE_VERSION} VERSION_LESS 3.17.0))
|
||||
get_target_property(target_sources ${TARGET_NAME} INTERFACE_SOURCES)
|
||||
if(target_sources)
|
||||
list(APPEND all_sources ${target_sources})
|
||||
endif()
|
||||
else()
|
||||
get_target_property(__s2 ${TARGET_NAME} SOURCES)
|
||||
if(__s2)
|
||||
list(APPEND __all_sources ${__s2})
|
||||
get_target_property(target_sources ${TARGET_NAME} SOURCES)
|
||||
if(target_sources)
|
||||
list(APPEND all_sources ${target_sources})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
foreach(iter ${__all_sources})
|
||||
foreach(iter ${all_sources})
|
||||
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
|
||||
if(pos EQUAL -1)
|
||||
list(APPEND __sources ${iter})
|
||||
list(APPEND sources ${iter})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(__fixed_config ${PROJECT_BINARY_DIR}/uncrustify-${TARGET_NAME}.cfg)
|
||||
add_custom_command(OUTPUT ${__fixed_config}
|
||||
set(fixed_config ${PROJECT_BINARY_DIR}/uncrustify-${TARGET_NAME}.cfg)
|
||||
add_custom_command(OUTPUT ${fixed_config}
|
||||
DEPENDS ${ARG_CONFIG}
|
||||
COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc
|
||||
-c ${ARG_CONFIG} -o ${__fixed_config})
|
||||
list(APPEND __options -c ${__fixed_config})
|
||||
-c ${ARG_CONFIG} -o ${fixed_config})
|
||||
list(APPEND options -c ${fixed_config})
|
||||
# cmake-format: off
|
||||
add_custom_target(${TARGET_NAME}-uncrustify-check
|
||||
DEPENDS ${__fixed_config}
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${__options} --check ${__sources})
|
||||
DEPENDS ${fixed_config}
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${options} --check ${sources})
|
||||
|
||||
list(APPEND __options --replace --no-backup)
|
||||
list(APPEND options --replace --no-backup)
|
||||
add_custom_target(${TARGET_NAME}-uncrustify
|
||||
DEPENDS ${__fixed_config}
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${__options} --mtime ${__sources})
|
||||
DEPENDS ${fixed_config}
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${options} --mtime ${sources})
|
||||
|
||||
add_custom_target(${TARGET_NAME}-uncrustify-append-comments
|
||||
DEPENDS ${__fixed_config}
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${__options}
|
||||
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
|
||||
--set cmt_insert_func_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/funcheader.txt
|
||||
--set cmt_insert_before_ctor_dtor=true --mtime ${__sources})
|
||||
--set cmt_insert_before_ctor_dtor=true --mtime ${sources})
|
||||
# cmake-format: on
|
||||
|
||||
add_dependencies(myx-uncrustify ${TARGET_NAME}-uncrustify)
|
||||
|
Reference in New Issue
Block a user