Skip to content

Commit 69702d8

Browse files
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.
1 parent 64e49c2 commit 69702d8

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

components/bootloader/subproject/CMakeLists.txt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ if(CONFIG_SECURE_BOOT_V2_ENABLED)
179179
endif()
180180

181181
if(CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH)
182-
add_custom_command(TARGET bootloader.elf POST_BUILD
182+
add_custom_command(TARGET gen_project_binary POST_BUILD
183183
COMMAND ${CMAKE_COMMAND} -E echo
184184
"=============================================================================="
185185
COMMAND ${CMAKE_COMMAND} -E echo
@@ -192,7 +192,7 @@ if(CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH)
192192
"* IMPORTANT: After first boot, BOOTLOADER CANNOT BE RE-FLASHED on same device"
193193
VERBATIM)
194194
elseif(CONFIG_SECURE_BOOTLOADER_REFLASHABLE)
195-
add_custom_command(TARGET bootloader.elf POST_BUILD
195+
add_custom_command(TARGET gen_bootloader_digest_bin POST_BUILD
196196
COMMAND ${CMAKE_COMMAND} -E echo
197197
"=============================================================================="
198198
COMMAND ${CMAKE_COMMAND} -E echo
@@ -219,14 +219,13 @@ elseif(CONFIG_SECURE_BOOTLOADER_REFLASHABLE)
219219
"* After first boot, only re-flashes of this kind (with same key) will be accepted."
220220
COMMAND ${CMAKE_COMMAND} -E echo
221221
"* Not recommended to reuse the same secure boot keyfile on multiple production devices."
222-
DEPENDS gen_secure_bootloader_key gen_bootloader_digest_bin
223222
VERBATIM)
224223
elseif(
225224
CONFIG_SECURE_BOOT_V2_ENABLED AND
226225
(CONFIG_SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS GREATER 1) AND
227226
NOT CONFIG_SECURE_BOOT_FLASH_BOOTLOADER_DEFAULT
228227
)
229-
add_custom_command(TARGET bootloader.elf POST_BUILD
228+
add_custom_command(TARGET gen_signed_bootloader POST_BUILD
230229
COMMAND ${CMAKE_COMMAND} -E echo
231230
"=============================================================================="
232231
COMMAND ${CMAKE_COMMAND} -E echo
@@ -242,20 +241,16 @@ elseif(
242241
"\t${esptoolpy_write_flash} ${BOOTLOADER_OFFSET} ${CMAKE_BINARY_DIR}/bootloader.bin"
243242
COMMAND ${CMAKE_COMMAND} -E echo
244243
"=============================================================================="
245-
DEPENDS gen_signed_bootloader
246244
VERBATIM)
247245
elseif(CONFIG_SECURE_BOOT_V2_ENABLED AND NOT CONFIG_SECURE_BOOT_FLASH_BOOTLOADER_DEFAULT)
248-
add_custom_command(TARGET bootloader.elf POST_BUILD
246+
add_custom_command(TARGET gen_signed_bootloader POST_BUILD
249247
COMMAND ${CMAKE_COMMAND} -E echo
250248
"=============================================================================="
251249
COMMAND ${CMAKE_COMMAND} -E echo
252250
"Bootloader built. Secure boot enabled, so bootloader not flashed automatically."
253-
COMMAND ${CMAKE_COMMAND} -E echo
254-
"Secure boot enabled, so bootloader not flashed automatically."
255251
COMMAND ${CMAKE_COMMAND} -E echo
256252
"\t${esptoolpy_write_flash} ${BOOTLOADER_OFFSET} ${CMAKE_BINARY_DIR}/bootloader.bin"
257253
COMMAND ${CMAKE_COMMAND} -E echo
258254
"=============================================================================="
259-
DEPENDS gen_signed_bootloader
260255
VERBATIM)
261256
endif()

0 commit comments

Comments
 (0)