sysbuild: shared cache variable instead of local scope variable

Fixes: #52353

If a CMake variable is available in both local scope and as CMake cache
variable, then the use of `${<var>}` fetches the local scoped variable.
If only the cache variable is set, then things works as expected.

Ensure that the cached variable is always the variable being shared to
images by using `$CACHE{<var>}` instead.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2022-12-08 11:06:32 +01:00 committed by Carles Cufí
parent 411549c22c
commit 3b32444f10

View file

@ -183,7 +183,7 @@ function(ExternalZephyrProject_Add)
# Required CMake variable to be passed, like CMAKE_BUILD_TYPE must be
# passed using `-D` on command invocation.
get_property(var_type CACHE ${var_name} PROPERTY TYPE)
set(cache_entry "${var_name}:${var_type}=${${var_name}}")
set(cache_entry "${var_name}:${var_type}=$CACHE{${var_name}}")
string(REPLACE ";" "\;" cache_entry "${cache_entry}")
list(APPEND sysbuild_cache_strings "${cache_entry}\n")
endif()