Skip to content

Commit b496019

Browse files
committed
build: support aliases for TARGET_SDKS
Introduce two new aliasees `ALL_POSIX_PLATFORMS` and `ALL_APPLE_PLATFORMS`. The latter expands to iOS, tvOS, watchOS, macOS and if relevant, the simulators. The former expands to the same list as `ALL_APPLE_PLATFORMS` as well as Linux and FreeBSD.
1 parent 7280261 commit b496019

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,8 @@ function(add_swift_library name)
11111111
if("${SWIFTLIB_TARGET_SDKS}" STREQUAL "")
11121112
set(SWIFTLIB_TARGET_SDKS ${SWIFT_SDKS})
11131113
endif()
1114+
list_replace(SWIFTLIB_TARGET_SDKS ALL_POSIX_PLATFORMS "ALL_APPLE_PLATFORMS;ANDROID;CYGWIN;FREEBSD;LINUX")
1115+
list_replace(SWIFTLIB_TARGET_SDKS ALL_APPLE_PLATFORMS "IOS;IOS_SIMULATOR;TVOS;TVOS_SIMULATOR;WATCHOS;WATCHOS_SIMULATOR;OSX")
11141116

11151117
# All Swift code depends on the standard library, except for the standard
11161118
# library itself.

cmake/modules/SwiftList.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,15 @@ function(_list_escape_for_shell input_list result_var_name)
4848
set("${result_var_name}" "${result}" PARENT_SCOPE)
4949
endfunction()
5050

51+
function(list_replace input_list old new)
52+
set(replaced_list)
53+
foreach(item ${${input_list}})
54+
if(${item} STREQUAL ${old})
55+
list(APPEND replaced_list ${new})
56+
else()
57+
list(APPEND replaced_list ${item})
58+
endif()
59+
endforeach()
60+
set("${input_list}" "${replaced_list}" PARENT_SCOPE)
61+
endfunction()
62+

0 commit comments

Comments
 (0)