don't autoformat generated source files

This commit is contained in:
Thomas Lindner 2022-10-18 02:00:05 +02:00
parent 20f71fcf0d
commit c4dcd7203d

View file

@ -11,8 +11,14 @@ unset(_CLANG_FORMAT)
function(add_autoformat_target target) function(add_autoformat_target target)
get_target_property(source_dir ${target} SOURCE_DIR) get_target_property(source_dir ${target} SOURCE_DIR)
get_target_property(sources ${target} SOURCES) get_target_property(sources ${target} SOURCES)
foreach(source ${sources})
get_property(generated SOURCE ${source} PROPERTY GENERATED)
if(NOT ${generated})
list(APPEND non_generated_sources ${source})
endif()
endforeach()
add_custom_target(autoformat_${target} add_custom_target(autoformat_${target}
COMMAND clang-format -i -- ${sources} COMMAND clang-format -i -- ${non_generated_sources}
WORKING_DIRECTORY ${source_dir} WORKING_DIRECTORY ${source_dir}
COMMENT "Autoformating sources of target ${target}" COMMENT "Autoformating sources of target ${target}"
VERBATIM) VERBATIM)