From 967b82a29fc475105f57a4548aeb057bd8c41cd1 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Tue, 2 Sep 2025 10:33:46 +0200 Subject: [PATCH] feat(cmakev2/project): add __init_project_flash_targets helper Some components rely on the existence of flash targets to declare dependencies. Add flash and encrypted-flash targets during project initialization to ensure they are available before including project_include.cmake files. Signed-off-by: Frantisek Hrbata --- tools/cmakev2/project.cmake | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/cmakev2/project.cmake b/tools/cmakev2/project.cmake index 3f2cb27073c..1a3f015db53 100644 --- a/tools/cmakev2/project.cmake +++ b/tools/cmakev2/project.cmake @@ -505,6 +505,27 @@ function(__init_project_configuration) idf_build_set_property(LINKER_TYPE "${linker_type}") endfunction() +#[[ + __init_project_flash_targets() + + Add placeholder flash targets to the build. This is used by components to + declare dependencies on the flash target. +#]] +function(__init_project_flash_targets) + if(NOT TARGET flash) + add_custom_target(flash) + endif() + + # When flash encryption is enabled, a corresponding 'encrypted-flash' target will be created. + idf_build_get_property(sdkconfig SDKCONFIG) + __get_sdkconfig_option(OPTION CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT + SDKCONFIG "${sdkconfig}" + OUTPUT sdkconfig_target) + if(encrypted_flash_enabled AND NOT TARGET encrypted-flash) + add_custom_target(encrypted-flash) + endif() +endfunction() + #[[api .. cmakev2:macro:: idf_project_init @@ -540,6 +561,9 @@ macro(idf_project_init) # Initialize all compilation options and defines. __init_project_configuration() + # Create global flash targets. + __init_project_flash_targets() + # Include all project_include.cmake files for the components that have # been discovered. idf_build_get_property(component_names COMPONENTS_DISCOVERED)