Skip to content

Commit 37097c1

Browse files
authored
Merge pull request #36782 from porglezomp-misc/feeling-rather-cross-compiling
Skip adding alias targets when they don't exist
2 parents 17e84c2 + 2d3d515 commit 37097c1

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

stdlib/CMakeLists.txt

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,23 @@ function(swift_create_stdlib_targets name variant define_all_alias)
196196
if(NOT define_all_alias)
197197
set(ALL_keyword ALL)
198198
endif()
199-
add_custom_target(${name}${variant}
200-
${ALL_keyword}
201-
DEPENDS
202-
${name}${SWIFT_PRIMARY_VARIANT_SUFFIX}${variant})
203-
set_target_properties(${name}${variant}
204-
PROPERTIES
205-
FOLDER "Swift libraries/Aggregate")
199+
200+
# When cross-compiling host tools for multiple architectures, targeting a
201+
# different SDK, the primary variant is not one of the variants being built,
202+
# so it can't be added as a target here. build-script will invoke the
203+
# more-specific target, so just skip creating this target and warn in case
204+
# someone is using the CMake more directly.
205+
if(SWIFT_PRIMARY_VARIANT_SDK IN_LIST SWIFT_SDKS)
206+
add_custom_target(${name}${variant}
207+
${ALL_keyword}
208+
DEPENDS
209+
${name}${SWIFT_PRIMARY_VARIANT_SUFFIX}${variant})
210+
set_target_properties(${name}${variant}
211+
PROPERTIES
212+
FOLDER "Swift libraries/Aggregate")
213+
else()
214+
message(WARNING "Primary variant ${SWIFT_PRIMARY_VARIANT_SDK} is not being built, not creating ${name}${variant} alias target for it.")
215+
endif()
206216
endfunction()
207217

208218
swift_create_stdlib_targets("swift-stdlib" "" TRUE)

0 commit comments

Comments
 (0)