Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions soc/nordic/common/uicr/sysbuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,23 @@ ExternalZephyrProject_Add(
# Ensure UICR is configured and built after the default image so EDT/ELFs exist.
sysbuild_add_dependencies(CONFIGURE uicr ${DEFAULT_IMAGE})

add_dependencies(uicr ${DEFAULT_IMAGE})
if(DEFINED image)
add_dependencies(uicr ${image})
endif()
# Add build dependencies for all images whose ELF files may be used by gen_uicr.
# The gen_uicr/CMakeLists.txt scans all sibling build directories and adds their
# ELF files as file dependencies. However, we also need target dependencies to
# ensure those images are built before uicr attempts to use their ELF files.
#
# Use cmake_language(DEFER DIRECTORY) to ensure this runs after ALL images have
# been added to the sysbuild_images global property, even if some module adds
# images after the soc subdirectory is processed. We defer to the source root
# directory to ensure we're at the top-level scope where all subdirectories have
# completed processing.
function(uicr_add_image_dependencies)
get_property(all_images GLOBAL PROPERTY sysbuild_images)
foreach(img ${all_images})
if(NOT img STREQUAL "uicr")
add_dependencies(uicr ${img})
endif()
endforeach()
endfunction()

cmake_language(DEFER DIRECTORY ${CMAKE_SOURCE_DIR} CALL uicr_add_image_dependencies)