From c4dcd7203dcf869dc8aa04c6e21a5bc49cc54326 Mon Sep 17 00:00:00 2001 From: Thomas Lindner Date: Tue, 18 Oct 2022 02:00:05 +0200 Subject: [PATCH] don't autoformat generated source files --- cmake/AddAutoformatTarget.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/AddAutoformatTarget.cmake b/cmake/AddAutoformatTarget.cmake index baaffaa..07e739f 100644 --- a/cmake/AddAutoformatTarget.cmake +++ b/cmake/AddAutoformatTarget.cmake @@ -11,8 +11,14 @@ unset(_CLANG_FORMAT) function(add_autoformat_target target) get_target_property(source_dir ${target} SOURCE_DIR) 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} - COMMAND clang-format -i -- ${sources} + COMMAND clang-format -i -- ${non_generated_sources} WORKING_DIRECTORY ${source_dir} COMMENT "Autoformating sources of target ${target}" VERBATIM)