From 4e85b3f5a50a33991fa7d315f30ec0f654028856 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Tue, 23 Sep 2025 13:14:35 +0200 Subject: [PATCH] feat(cmakev2/utilities): add __list_difference function Return the difference between two lists, meaning the elements that are present in the first list but not in the second. Signed-off-by: Frantisek Hrbata --- tools/cmakev2/utilities.cmake | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/cmakev2/utilities.cmake b/tools/cmakev2/utilities.cmake index 1fba6cabf47..40182486c02 100644 --- a/tools/cmakev2/utilities.cmake +++ b/tools/cmakev2/utilities.cmake @@ -1181,3 +1181,32 @@ function(__list_intersection list1 list2 output_var) endforeach() set(${output_var} "${result}" PARENT_SCOPE) endfunction() + +#[[ + __list_difference( ) + + *list1[in]* + + First list. + + *list2[in]* + + Second list. + + *output_var[out]* + + Variable name where the resulting list will be stored. + + Return the difference between the elements of ``list1`` and ``list2``. In + other words, the elements that are present in ``list1`` but not in + ``list2``. The resulting list is stored in the ``output_var`` list. +#]] +function(__list_difference list1 list2 output_var) + set(result "") + foreach(item IN LISTS ${list1}) + if(NOT item IN_LIST ${list2}) + list(APPEND result "${item}") + endif() + endforeach() + set(${output_var} "${result}" PARENT_SCOPE) +endfunction()