-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathSwiftList.cmake
55 lines (49 loc) · 1.42 KB
/
SwiftList.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
include(SwiftUtils)
function(list_subtract lhs rhs result_var_name)
set(result)
foreach(item IN LISTS lhs)
if(NOT "${item}" IN_LIST rhs)
list(APPEND result "${item}")
endif()
endforeach()
set("${result_var_name}" "${result}" PARENT_SCOPE)
endfunction()
function(list_intersect lhs rhs result_var_name)
set(result)
foreach(item IN LISTS lhs)
if("${item}" IN_LIST rhs)
list(APPEND result "${item}")
endif()
endforeach()
set("${result_var_name}" "${result}" PARENT_SCOPE)
endfunction()
function(list_union lhs rhs result_var_name)
set(result)
foreach(item IN LISTS lhs rhs)
if(NOT "${item}" IN_LIST result)
list(APPEND result "${item}")
endif()
endforeach()
set("${result_var_name}" "${result}" PARENT_SCOPE)
endfunction()
function(_list_add_string_suffix input_list suffix result_var_name)
set(result)
foreach(element ${input_list})
list(APPEND result "${element}${suffix}")
endforeach()
set("${result_var_name}" "${result}" PARENT_SCOPE)
endfunction()
function(list_replace input_list old new)
set(replaced_list)
foreach(item ${${input_list}})
if(${item} STREQUAL ${old})
list(APPEND replaced_list ${new})
else()
list(APPEND replaced_list ${item})
endif()
endforeach()
set("${input_list}" "${replaced_list}" PARENT_SCOPE)
endfunction()
function(precondition_list_empty l message)
precondition(l NEGATE MESSAGE "${message}")
endfunction()