sysbuild: ensure warning is only printed when VAR is not used

When calling `sysbuild_get(<out-var> VAR <lookup-var> ...)` user
specifically specify the output variable and in such cases the overwrite
warning should not be printed, because such invocation is similar to a
regular `set(<var> <val>)` CMake call.

Only the invocation where the same variable name is used for lookup and
return variable, then the warning must be printed to avoid unintentional
overwriting of existing variables.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2023-04-13 12:20:01 +02:00 committed by Anas Nashif
parent 4195ba5870
commit 782a0515ed

View file

@ -75,7 +75,7 @@ function(sysbuild_get variable)
message(FATAL_ERROR "sysbuild_get(...) requires IMAGE.")
endif()
if(DEFINED ${variable})
if(DEFINED ${variable} AND NOT DEFINED GET_VAR_VAR)
message(WARNING "Return variable ${variable} already defined with a value. "
"sysbuild_get(${variable} ...) may overwrite existing value. "
"Please use sysbuild_get(<variable> ... VAR <image-variable>) "