Skip to content

Commit 1d28c0a

Browse files
committed
[cmake] Refactor two list processing utility functions from AddSwift.cmake => SwiftList.cmake.
1 parent a42d24f commit 1d28c0a

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
include(SwiftList)
2+
13
# SWIFTLIB_DIR is the directory in the build tree where Swift resource files
24
# should be placed. Note that $CMAKE_CFG_INTDIR expands to "." for
35
# single-configuration builds.
@@ -6,23 +8,6 @@ set(SWIFTLIB_DIR
68
set(SWIFTSTATICLIB_DIR
79
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/swift_static")
810

9-
function(_list_add_string_suffix input_list suffix result_var_name)
10-
set(result)
11-
foreach(element ${input_list})
12-
list(APPEND result "${element}${suffix}")
13-
endforeach()
14-
set("${result_var_name}" "${result}" PARENT_SCOPE)
15-
endfunction()
16-
17-
function(_list_escape_for_shell input_list result_var_name)
18-
set(result "")
19-
foreach(element ${input_list})
20-
string(REPLACE " " "\\ " element "${element}")
21-
set(result "${result}${element} ")
22-
endforeach()
23-
set("${result_var_name}" "${result}" PARENT_SCOPE)
24-
endfunction()
25-
2611
function(add_dependencies_multiple_targets)
2712
cmake_parse_arguments(
2813
ADMT # prefix

cmake/modules/SwiftList.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,21 @@ function(list_union lhs rhs result_var_name)
3030
endforeach()
3131
set("${result_var_name}" "${result}" PARENT_SCOPE)
3232
endfunction()
33+
34+
function(_list_add_string_suffix input_list suffix result_var_name)
35+
set(result)
36+
foreach(element ${input_list})
37+
list(APPEND result "${element}${suffix}")
38+
endforeach()
39+
set("${result_var_name}" "${result}" PARENT_SCOPE)
40+
endfunction()
41+
42+
function(_list_escape_for_shell input_list result_var_name)
43+
set(result "")
44+
foreach(element ${input_list})
45+
string(REPLACE " " "\\ " element "${element}")
46+
set(result "${result}${element} ")
47+
endforeach()
48+
set("${result_var_name}" "${result}" PARENT_SCOPE)
49+
endfunction()
50+

0 commit comments

Comments
 (0)