Skip to content

Commit c725faa

Browse files
committed
[CMake] set OSX_ARCHITECTURES in add_swift_target_library_single
This way we configure correctly `libBlocksRuntime`, which is not using `add_swift_target_library` (where the code for setting `OSX_ARCHITECTURES` currently lives, see #38415 and #38956) Addresses rdar://96469791
1 parent 1123a19 commit c725faa

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,18 @@ function(add_swift_target_library_single target name)
13461346
target_link_options(${target} PRIVATE
13471347
"LINKER:-current_version,${SWIFT_COMPILER_VERSION}")
13481348
endif()
1349+
1350+
# In the past, we relied on unsetting globally
1351+
# CMAKE_OSX_ARCHITECTURES to ensure that CMake would
1352+
# not add the -arch flag
1353+
# This is no longer the case when running on Apple Silicon,
1354+
# when CMake will enforce a default (see
1355+
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291)
1356+
set_property(TARGET ${target} PROPERTY OSX_ARCHITECTURES "${SWIFTLIB_SINGLE_ARCHITECTURE}")
1357+
if (target_static)
1358+
set_property(TARGET ${target_static} PROPERTY OSX_ARCHITECTURES "${SWIFTLIB_SINGLE_ARCHITECTURE}")
1359+
endif()
1360+
13491361
# Include LLVM Bitcode slices for iOS, Watch OS, and Apple TV OS device libraries.
13501362
if(SWIFT_EMBED_BITCODE_SECTION AND NOT SWIFTLIB_SINGLE_DONT_EMBED_BITCODE)
13511363
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "IOS" OR
@@ -2188,19 +2200,6 @@ function(add_swift_target_library name)
21882200
list(APPEND THIN_INPUT_TARGETS ${VARIANT_NAME})
21892201
endif()
21902202
endif()
2191-
2192-
if(sdk IN_LIST SWIFT_APPLE_PLATFORMS)
2193-
# In the past, we relied on unsetting globally
2194-
# CMAKE_OSX_ARCHITECTURES to ensure that CMake would
2195-
# not add the -arch flag
2196-
# This is no longer the case when running on Apple Silicon,
2197-
# when CMake will enforce a default (see
2198-
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291)
2199-
set_property(TARGET ${VARIANT_NAME} PROPERTY OSX_ARCHITECTURES "${arch}")
2200-
if (SWIFTLIB_IS_STDLIB AND SWIFTLIB_STATIC)
2201-
set_property(TARGET ${VARIANT_NAME}-static PROPERTY OSX_ARCHITECTURES "${arch}")
2202-
endif()
2203-
endif()
22042203
endforeach()
22052204

22062205
# Configure module-only targets

0 commit comments

Comments
 (0)