Skip to content

VS: Detect ARM64 host architecture at runtime

Brad King requested to merge brad.king/cmake:vs-msbuild-arm64 into master

We use the host machine's architecture to select the MSBuild.exe binary variant, and the host toolset architecture. When CMake is compiled as x64 or x86 it may still run on ARM64 hosts. Detect the actual architecture of the host at runtime instead of relying on the architecture of CMake's own binary.

The arm64/MSBuild.exe executable is an ARM64 .NET 4 application, which requires the ARM64 version of .NET Framework 4.8.1 to be installed on the machine. That version is not yet released for Windows 10; however, the MSBuild/Current/Bin/arm64 directory is still created when installing Visual Studio 2022 (a user may upgrade to Windows 11 later). Use it only if the .NET Framework is installed.

The amd64/MSBuild.exe executable cannot run on Windows 10 ARM64, but can run on Windows 11 ARM64.

Fixes: #23755 (closed)
Backport: release

Edited by Brad King

Merge request reports