From c3881a06312ebcb5d91f9cd35ddd581b2d047405 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Fri, 26 Sep 2025 17:58:09 +0200 Subject: [PATCH] feat(cmakev2): Create executable dummy source only if it does not exist idf_build_executable() creates a dummy source file to create the executable target. Since this file is created unconditionally everytime CMake configuration happens, a source file change is registered which causes CMake to execute other targets even though no other source file changed. --- tools/cmakev2/build.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/cmakev2/build.cmake b/tools/cmakev2/build.cmake index 0ea08936230..d7b57bc215d 100644 --- a/tools/cmakev2/build.cmake +++ b/tools/cmakev2/build.cmake @@ -527,7 +527,9 @@ function(idf_build_executable executable) idf_build_library(${library} COMPONENTS "${ARG_COMPONENTS}") set(executable_src ${CMAKE_BINARY_DIR}/executable_${executable}.c) - file(TOUCH "${executable_src}") + if(NOT EXISTS "${executable_src}") + file(TOUCH "${executable_src}") + endif() add_executable(${executable} "${executable_src}") if(ARG_NAME)