From 59b92aca7479e91a79d39d4f3f1cc0403b6ee7ba Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Tue, 19 Aug 2025 11:22:31 +0200 Subject: [PATCH] feat(cmakev2/utilities): add spaces2list function The spaces2list function is used by some existing components, so it should be added to cmakev2 as well. Signed-off-by: Frantisek Hrbata --- tools/cmakev2/utilities.cmake | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/cmakev2/utilities.cmake b/tools/cmakev2/utilities.cmake index c5520ac6e77..6a49200145d 100644 --- a/tools/cmakev2/utilities.cmake +++ b/tools/cmakev2/utilities.cmake @@ -501,3 +501,21 @@ function(remove_duplicated_flags FLAGS UNIQFLAGS) # Return that string to the caller set(${UNIQFLAGS} "${FLAGS_LIST}" PARENT_SCOPE) endfunction() + +#[[ + spaces2list() + + :variable[in,out]: String with space-delimited values. + + Take a variable containing space-delimited values and convert it into a + CMake list with semicolon-delimited values. + + Note: do not use this for directories or full paths, as they may contain + spaces. + + TODO: look at cmake separate_arguments, which is quote-aware +#]] +function(spaces2list variable_name) + string(REPLACE " " ";" tmp "${${variable_name}}") + set("${variable_name}" "${tmp}" PARENT_SCOPE) +endfunction()