From 69702d86662369cafb4ec14fd7651e8a065b691a Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Thu, 10 Jul 2025 15:18:03 +0200 Subject: [PATCH] fix(bootloader): Correct dependency logic for custom commands The bootloader build script incorrectly used the `DEPENDS` keyword with the `add_custom_command(TARGET ...)` signature. This is unsupported, causes warnings with modern CMake versions enforcing the CMP0175 policy. This commit also updates the POST_BUILD messages generated during the bootloader build to depend on more precise CMake targets rather than depending on the generic bootloader.elf target. --- components/bootloader/subproject/CMakeLists.txt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/components/bootloader/subproject/CMakeLists.txt b/components/bootloader/subproject/CMakeLists.txt index dcf7074f44..6e358590b6 100644 --- a/components/bootloader/subproject/CMakeLists.txt +++ b/components/bootloader/subproject/CMakeLists.txt @@ -179,7 +179,7 @@ if(CONFIG_SECURE_BOOT_V2_ENABLED) endif() if(CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH) - add_custom_command(TARGET bootloader.elf POST_BUILD + add_custom_command(TARGET gen_project_binary POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "==============================================================================" COMMAND ${CMAKE_COMMAND} -E echo @@ -192,7 +192,7 @@ if(CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH) "* IMPORTANT: After first boot, BOOTLOADER CANNOT BE RE-FLASHED on same device" VERBATIM) elseif(CONFIG_SECURE_BOOTLOADER_REFLASHABLE) - add_custom_command(TARGET bootloader.elf POST_BUILD + add_custom_command(TARGET gen_bootloader_digest_bin POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "==============================================================================" COMMAND ${CMAKE_COMMAND} -E echo @@ -219,14 +219,13 @@ elseif(CONFIG_SECURE_BOOTLOADER_REFLASHABLE) "* After first boot, only re-flashes of this kind (with same key) will be accepted." COMMAND ${CMAKE_COMMAND} -E echo "* Not recommended to reuse the same secure boot keyfile on multiple production devices." - DEPENDS gen_secure_bootloader_key gen_bootloader_digest_bin VERBATIM) elseif( CONFIG_SECURE_BOOT_V2_ENABLED AND (CONFIG_SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS GREATER 1) AND NOT CONFIG_SECURE_BOOT_FLASH_BOOTLOADER_DEFAULT ) - add_custom_command(TARGET bootloader.elf POST_BUILD + add_custom_command(TARGET gen_signed_bootloader POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "==============================================================================" COMMAND ${CMAKE_COMMAND} -E echo @@ -242,20 +241,16 @@ elseif( "\t${esptoolpy_write_flash} ${BOOTLOADER_OFFSET} ${CMAKE_BINARY_DIR}/bootloader.bin" COMMAND ${CMAKE_COMMAND} -E echo "==============================================================================" - DEPENDS gen_signed_bootloader VERBATIM) elseif(CONFIG_SECURE_BOOT_V2_ENABLED AND NOT CONFIG_SECURE_BOOT_FLASH_BOOTLOADER_DEFAULT) - add_custom_command(TARGET bootloader.elf POST_BUILD + add_custom_command(TARGET gen_signed_bootloader POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "==============================================================================" COMMAND ${CMAKE_COMMAND} -E echo "Bootloader built. Secure boot enabled, so bootloader not flashed automatically." - COMMAND ${CMAKE_COMMAND} -E echo - "Secure boot enabled, so bootloader not flashed automatically." COMMAND ${CMAKE_COMMAND} -E echo "\t${esptoolpy_write_flash} ${BOOTLOADER_OFFSET} ${CMAKE_BINARY_DIR}/bootloader.bin" COMMAND ${CMAKE_COMMAND} -E echo "==============================================================================" - DEPENDS gen_signed_bootloader VERBATIM) endif()