Skip to content

Commit 20b00dd

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

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,20 @@ function(add_swift_target_library_single target name)
13711371
# emitting warnings about global initializers when it compiles the code.
13721372
list(APPEND swiftlib_link_flags_all "-Xlinker -no_warn_inits")
13731373
endif()
1374+
1375+
if(${SWIFTLIB_SINGLE_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
1376+
# In the past, we relied on unsetting globally
1377+
# CMAKE_OSX_ARCHITECTURES to ensure that CMake
1378+
# would not add the -arch flag. This is no longer
1379+
# the case when running on Apple Silicon, when
1380+
# CMake will enforce a default (see
1381+
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291)
1382+
set_property(TARGET ${target} PROPERTY OSX_ARCHITECTURES "${SWIFTLIB_SINGLE_ARCHITECTURE}")
1383+
if(TARGET "${target_static}")
1384+
set_property(TARGET ${target_static} PROPERTY OSX_ARCHITECTURES "${SWIFTLIB_SINGLE_ARCHITECTURE}")
1385+
endif()
1386+
endif()
1387+
13741388
target_link_libraries(${target} PRIVATE
13751389
${link_libraries})
13761390
target_link_directories(${target} PRIVATE
@@ -2188,19 +2202,6 @@ function(add_swift_target_library name)
21882202
list(APPEND THIN_INPUT_TARGETS ${VARIANT_NAME})
21892203
endif()
21902204
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()
22042205
endforeach()
22052206

22062207
# Configure module-only targets

0 commit comments

Comments
 (0)