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 <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2025-11-04 07:48:13 +01:00
parent f5ce3f8c8b
commit 59b92aca74
+18
View File
@@ -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>)
: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()