feat(cmakev2/utilities): add add_prefix function

The add_prefix 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-08-19 11:32:05 +02:00
parent 59b92aca74
commit 20aa4c94e7

View File

@@ -519,3 +519,19 @@ function(spaces2list variable_name)
string(REPLACE " " ";" tmp "${${variable_name}}")
set("${variable_name}" "${tmp}" PARENT_SCOPE)
endfunction()
#[[
add_prefix(<variable> <prefix> <item>...)
:variable[out]: Output variable with list of prefixed items.
:prefix[in]: Prefix string.
:item[in]: Items to be prefixed.
Add a prefix to each item in the given list.
#]]
function(add_prefix var prefix)
foreach(elm ${ARGN})
list(APPEND newlist "${prefix}${elm}")
endforeach()
set(${var} "${newlist}" PARENT_SCOPE)
endfunction()