SDL_image: Add CMake+MSVC to github CI

From a6018f1cffa7519445ad0c8457186f2f07414765 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Wed, 25 May 2022 18:10:23 +0200
Subject: [PATCH] Add CMake+MSVC to github CI

---
 .github/workflows/main.yml | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 71c244cb..557076e4 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -15,6 +15,7 @@ jobs:
       fail-fast: false
       matrix:
         platform:
+        - { name: Windows (MSVC+CMake),         os: windows-latest, shell: sh,   cmake: '-DSDL2IMAGE_VENDORED=ON -G "Ninja Multi-Config"', msvc: 1 }
         - { name: Windows (mingw32+autotools),  os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686 }
         - { name: Windows (mingw64+CMake),      os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64,
             cmake: '-DSDL2IMAGE_BACKEND_STB=OFF -DSDL2IMAGE_BACKEND_WIC=OFF -DSDL2IMAGE_VENDORED=OFF -DSDL2IMAGE_AVIF=ON -G "Ninja Multi-Config"' }
@@ -83,6 +84,23 @@ jobs:
     - uses: actions/checkout@v2
       with:
         submodules: recursive
+
+    - name: Setup MSVC dependencies
+      if: "matrix.platform.msvc"
+      shell: pwsh
+      run: |
+        .github/fetch_sdl_vc.ps1
+        echo "SDL2_DIR=$Env:GITHUB_WORKSPACE/SDL2-devel-VC" >> $Env:GITHUB_ENV
+    - name: Setup Ninja for MSVC
+      if: "matrix.platform.msvc"
+      uses: ashutoshvarma/setup-ninja@master
+      with:
+        version: 1.10.2
+    - uses: ilammy/msvc-dev-cmd@v1
+      if: "matrix.platform.msvc"
+      with:
+        arch: x64
+
     - name: Check that versioning is consistent
       # We only need to run this once: arbitrarily use the Linux/CMake build
       if: "runner.os == 'Linux' && matrix.platform.cmake"
@@ -101,7 +119,7 @@ jobs:
           -DSDL2IMAGE_WEBP=ON \
           ${NULL+}
 
-        if [ "${{ runner.os }}" = Linux ]; then
+        if [ "${{ matrix.platform.msystem }}" = "" ]; then
             # mingw-w64-*-SDL2 doesn't have SDL_test, and the macOS CMake
             # build can't find it (see #260), so we only enable build-time
             # tests for Linux at the moment.
@@ -116,7 +134,7 @@ jobs:
           ${{ matrix.platform.cmake }}
     - name: Build
       if: "matrix.platform.cmake"
-      run: cmake --build build/ --config Release --verbose
+      run: cmake --build build/ --config Release --parallel --verbose
     - name: Run build-time tests
       if: "runner.os == 'Linux' && matrix.platform.cmake"
       run: |