CMake VS 2026 with GitHub Actions

The CMake variable CMAKE_GENERATOR can be used with GitHub Actions to specify the Visual Studio 18 2026 generator. At the time of writing this article, GitHub Actions held back CMake 3.31, so check in case CMake ≥ 4.2 is available in the Windows GA runner image already.

jobs:

  msvc:
    runs-on: windows-latest
    timeout-minutes: 15

    steps:
    - name: Install CMake 4.2
      run: winget install -e --id Kitware.CMake --disable-interactivity --accept-source-agreements --accept-package-agreements
    # FIXME: until GitHub Actions have at least CMake 4.2, necessary for VS 2026

    - name: Print CMake version
      run: cmake --version

    - name: Configure
      run: cmake -B build -G "Visual Studio 18 2026"

    # and so on