Skip to content

[CMake] set OSX_ARCHITECTURES in add_swift_target_library_single #59922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,20 @@ function(add_swift_target_library_single target name)
# emitting warnings about global initializers when it compiles the code.
list(APPEND swiftlib_link_flags_all "-Xlinker -no_warn_inits")
endif()

if(${SWIFTLIB_SINGLE_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
# In the past, we relied on unsetting globally
# CMAKE_OSX_ARCHITECTURES to ensure that CMake
# would not add the -arch flag. This is no longer
# the case when running on Apple Silicon, when
# CMake will enforce a default (see
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291)
set_property(TARGET ${target} PROPERTY OSX_ARCHITECTURES "${SWIFTLIB_SINGLE_ARCHITECTURE}")
if(TARGET "${target_static}")
set_property(TARGET ${target_static} PROPERTY OSX_ARCHITECTURES "${SWIFTLIB_SINGLE_ARCHITECTURE}")
endif()
endif()

target_link_libraries(${target} PRIVATE
${link_libraries})
target_link_directories(${target} PRIVATE
Expand Down Expand Up @@ -2188,19 +2202,6 @@ function(add_swift_target_library name)
list(APPEND THIN_INPUT_TARGETS ${VARIANT_NAME})
endif()
endif()

if(sdk IN_LIST SWIFT_APPLE_PLATFORMS)
# In the past, we relied on unsetting globally
# CMAKE_OSX_ARCHITECTURES to ensure that CMake would
# not add the -arch flag
# This is no longer the case when running on Apple Silicon,
# when CMake will enforce a default (see
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291)
set_property(TARGET ${VARIANT_NAME} PROPERTY OSX_ARCHITECTURES "${arch}")
if (SWIFTLIB_IS_STDLIB AND SWIFTLIB_STATIC)
set_property(TARGET ${VARIANT_NAME}-static PROPERTY OSX_ARCHITECTURES "${arch}")
endif()
endif()
endforeach()

# Configure module-only targets
Expand Down