From de53c0d2db19cc8d7ea55f27b6798f0c0c31574c Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Thu, 11 Apr 2024 12:22:13 +0200 Subject: [PATCH] sysbuild: cmake: fix sysbuild_cache_set() function The sysbuild_cache_set() supports setting variables in a dedicated sysbuild image cache. When appending to a list, the list is checked for existance of the variable to avoid appending it again on reruns. This was done be checking with `string(FIND ...)`, but that will also return an index on a partial match. A much safer approach is to use the `if( IN_LIST )` approach to check for existance. Signed-off-by: Torsten Rasmussen --- share/sysbuild/cmake/modules/sysbuild_extensions.cmake | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/share/sysbuild/cmake/modules/sysbuild_extensions.cmake b/share/sysbuild/cmake/modules/sysbuild_extensions.cmake index 1a9dbedf41..3f3d409922 100644 --- a/share/sysbuild/cmake/modules/sysbuild_extensions.cmake +++ b/share/sysbuild/cmake/modules/sysbuild_extensions.cmake @@ -615,9 +615,7 @@ function(sysbuild_cache_set) # Search for these exact items in the existing value and prevent adding # them if they are already present which avoids issues with double addition # when cmake is reran. - string(FIND "$CACHE{${VARS_VAR}}" "${VARS_UNPARSED_ARGUMENTS}" index) - - if(NOT ${index} EQUAL -1) + if("${VARS_UNPARSED_ARGUMENTS}" IN_LIST var_new) return() endif()