compnerd / swift-win32

A Windows application framework for Swift
https://compnerd.github.io/swift-win32/
BSD 3-Clause "New" or "Revised" License
1.11k stars 69 forks source link

Support for Apple Silicon ARM CPUs #733

Closed efalloon closed 1 year ago

efalloon commented 1 year ago

Solution

While building the project with cmake, an unexpected error occurred in relation to my laptop CPU architecture. Currently, I'm running a Parallels VM of Windows 11 on a M1 Max MacBook Pro. As such, I discovered that the Apple Silicon ARM64 architecture was not supported - possible use cases and scenarios include running windows on a Virtual Machine (VM), dual-boot or on Apple Bootcamp. Therefore, I have added the ARM64 [x86_64] CPU type under .\cmake\Modules\SwiftSupport.cmake. After trying and testing it out, it now works with support for M1/M2 Macs.

Original Error

The original error occurred while running the suggested session line: cmake -B build -D BUILD_SHARED_LIBS=YES -D CMAKE_BUILD_TYPE=Release -D CMAKE_Swift_FLAGS="-sdk %SDKROOT%" -G Ninja -S .

This was the output at the end:

CMake Error at cmake/Modules/SwiftSupport.cmake:41 (message):
  Unrecognized architecture on host system: ARM64
Call Stack (most recent call first):
  cmake/Modules/SwiftSupport.cmake:80 (get_swift_host_arch)
  Packages/swift-collections/Sources/Collections/CMakeLists.txt:18 (_install_target)
efalloon commented 1 year ago

Hi @compnerd. I have fixed up the commit message and pushed a new commit - also removed the comment I made on the SwiftSupport.cmake file. Thanks for clearing things up. 😊