Skip to content

Commit ae128bb

Browse files
committed
[CMake] set target architecture for Darwin idiomatically
Previously we were setting `-arch` explicitly and unsetting `CMAKE_OSX_ARCHITECTURES`; however this approach does not work when building on Apple Silicon, since in there CMake 3.19+ enforces a default value (https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291/diffs), and this would result in the inability to compile code for x86_64. This is a similar approach used for stdlib targets in swiftlang#38415 Addresses rdar://88100025
1 parent d35ad60 commit ae128bb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ function(_add_host_variant_c_compile_link_flags name)
162162
# side effects are introduced should a new search path be added.
163163
target_compile_options(${name} PRIVATE
164164
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:
165-
-arch ${SWIFT_HOST_VARIANT_ARCH}
166165
"-F${SWIFT_SDK_${SWIFT_HOST_VARIANT_ARCH}_PATH}/../../../Developer/Library/Frameworks"
167166
>)
167+
set_property(TARGET ${name} PROPERTY OSX_ARCHITECTURES "${SWIFT_HOST_VARIANT_ARCH}")
168168
endif()
169169

170170
_compute_lto_flag("${SWIFT_TOOLS_ENABLE_LTO}" _lto_flag_out)

0 commit comments

Comments
 (0)