Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

1. CMAKE_SYSTEM_PROCESSOR wrongly configured in emulated CMake

CMake provides a built-in flag CMAKE_SYSTEM_PROCESSOR to specify the target platform for the build.

...

And if your CMake project uses CMAKE_SYSTEM_PROCESSOR for platform-specific configuration it might fail.

Solution

You can use native CMake. There are no official CMake binaries for Windows Arm64 yet but can be generated from the source https://linaro.atlassian.net/wiki/spaces/WOAR/pages/28684353912/CMake#Build-from-source

2. Native arm64 toolchain with CMake

Visual Studio 2022 Preview 17 provides native Arm64 MSVC toolchain but unfortunately, CMake wouldn’t be able to use them with the visual studio generator.

CMake could be configured to generate the right Visual studio project files but MSBuild seems to be ignoring the directive in the project file

<PreferredToolArchitecture>ARM64</PreferredToolArchitecture>

Solution

If PreferredToolArchitecture is provided as an explicit argument to MSBuild from the command line that seems to work.

CMake we can pass extra parameters to MSBuild after -- flag.

Example

cmake --build . -- /p:PreferredToolArchitecture=ARM64