From c3ba08c1f86895e244fac6bd0658b460d5606c8e Mon Sep 17 00:00:00 2001 From: alexsmn Date: Mon, 20 Apr 2026 23:14:24 -0700 Subject: [PATCH] ci: fix MSVC build by setting up VS env via ilammy/msvc-dev-cmd windows-latest no longer ships VS 2019 Enterprise, so the hardcoded vcvars64.bat path silently failed to execute and cl.exe was missing from PATH, breaking CMake's compiler detection. Use ilammy/msvc-dev-cmd@v1, which finds whichever Visual Studio is installed on the runner and exports the env vars via GITHUB_ENV so they persist across steps. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/cmake.yml | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 237da67..1ab68e2 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -14,7 +14,7 @@ jobs: name: "Windows Latest MSVC", artifact: "Windows-MSVC.tar.xz", os: windows-latest, build_type: "Release", cc: "cl", cxx: "cl", - environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" + msvc: true } - { name: "Windows Latest MinGW", artifact: "Windows-MinGW.tar.xz", @@ -30,6 +30,10 @@ jobs: steps: - uses: actions/checkout@v1 + - name: Set up MSVC environment + if: matrix.config.msvc + uses: ilammy/msvc-dev-cmd@v1 + - name: Download Ninja and CMake id: cmake_and_ninja shell: cmake -P {0} @@ -78,19 +82,6 @@ jobs: set(ENV{CC} ${{ matrix.config.cc }}) set(ENV{CXX} ${{ matrix.config.cxx }}) - if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") - execute_process( - COMMAND "${{ matrix.config.environment_script }}" && set - OUTPUT_FILE environment_script_output.txt - ) - file(STRINGS environment_script_output.txt output_lines) - foreach(line IN LISTS output_lines) - if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") - set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") - endif() - endforeach() - endif() - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/ninja" ninja_program) execute_process( @@ -112,15 +103,6 @@ jobs: run: | set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") - if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") - file(STRINGS environment_script_output.txt output_lines) - foreach(line IN LISTS output_lines) - if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") - set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") - endif() - endforeach() - endif() - execute_process( COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake --build build RESULT_VARIABLE result