Search code examples
c++cmakegithub-actionswindows-arm64

CMake and ARM64EC with GitHub actions


Following the instructions in https://learn.microsoft.com/en-us/windows/arm/arm64ec-build I can build a simple "hello world" CMake project using VS2022.

Issue is if I try to build on GitHub Actions I get:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
  No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:3 (project):
  No CMAKE_CXX_COMPILER could be found.

My yml is very simple

name: build

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

env:
  BUILD_TYPE: Release

jobs:
    buildWindowsARM64EC:
      runs-on: windows-latest
      steps:
        - uses: actions/checkout@v3

        - name: Do stuff
          run: | 
            call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64_arm64
            cmake -B ${{github.workspace}}/build --preset arm64ec
            cmake --build ${{github.workspace}}/build --config Release
          shell: cmd

CMakePresets.json is also simple

{
  "version": 5,
  "configurePresets": [
    {
      "name": "base",
      "hidden": true,
      "generator": "Visual Studio 17 2022"
    },
    {
      "name": "arm64ec",
      "inherits": "base",
      "displayName": "arm64ec",
      "architecture": {
        "value": "arm64ec",
        "strategy": "set"
      }
    }
  ]
}

CMakeLists.txt:

cmake_minimum_required (VERSION 3.15)

project ("hello")

set(CMAKE_CXX_STANDARD 17)

set(Sources
    main.cpp)

add_executable (${PROJECT_NAME} ${Sources})

I am guessing I am missing a PATH configuration or something similar but despite multiple iterations I can't seem to get any closer to it working.


Solution

  • The solution was in the end annoyingly simple.

    Basically I needed to target a different SDK.

    I added -DCMAKE_SYSTEM_VERSION=10 and all works fine

    The yml is now simply:

    name: build
    
    on:
      push:
        branches: [ "main" ]
      pull_request:
        branches: [ "main" ]
    
    env:
      BUILD_TYPE: Release
    
    jobs:
        buildWindowsARM64EC:
          runs-on: windows-latest
          steps:
            - uses: actions/checkout@v3
    
            - name: Do stuff
              run: | 
                cmake -B ${{github.workspace}}/build --preset arm64ec -DCMAKE_SYSTEM_VERSION=10
                cmake --build ${{github.workspace}}/build --config Release
    

    With this it works as expected:

     shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
      env:
        BUILD_TYPE: Release
      
    -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.
    -- The C compiler identification is MSVC 19.37.32825.0
    -- The CXX compiler identification is MSVC 19.37.32825.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/bin/Hostx64/arm64/cl.exe - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/bin/Hostx64/arm64/cl.exe - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Configuring done (43.2s)
    -- Generating done (0.0s)
    -- Build files have been written to: D:/a/simpleConsoleToTestGHActions/simpleConsoleToTestGHActions/build
    MSBuild version 17.7.2+d6990bcfa for .NET Framework