libtiff: appveyor: Add VS2022 builds

From 91d24c2585f5fe0266cee432c59d1bef8ff52404 Mon Sep 17 00:00:00 2001
From: Roger Leigh <[EMAIL REDACTED]>
Date: Sat, 6 Apr 2024 20:39:25 +0000
Subject: [PATCH] appveyor: Add VS2022 builds

---
 .appveyor.yml | 74 ++++++++++++++++++++++++++++-----------------------
 1 file changed, 40 insertions(+), 34 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 3d3d4638..d4909a13 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -1,3 +1,14 @@
+# Operating system (build VM template)
+image:
+  - "Visual Studio 2022"
+  - "Visual Studio 2019"
+
+platform: x64
+
+configuration:
+    - Release
+    - Debug
+
 environment:
   AV_PROJECTS: 'c:\projects'
   AV_TIFF_DOWNLOAD: 'c:\projects\download'
@@ -6,55 +17,48 @@ environment:
   AV_TIFF_INSTALL: 'c:\projects\install'
 
   matrix:
+    - compiler: vc-cmake
     - compiler: cygwin-cmake
-      configuration: Release
-      generator: Unix Makefiles
-      shared: ON
-    - compiler: cygwin-cmake
-      configuration: Debug
-      generator: Unix Makefiles
-      shared: OFF
     - compiler: mingw-cmake
+
+matrix:
+  exclude:
+    - image: "Visual Studio 2019"
+      compiler: cygwin-cmake
       configuration: Release
-      generator: MinGW Makefiles
-      shared: ON
-    - compiler: mingw-cmake
+    - image: "Visual Studio 2019"
+      compiler: cygwin-cmake
       configuration: Debug
-      generator: MinGW Makefiles
-      shared: OFF
-    - compiler: vc14-cmake
+    - image: "Visual Studio 2019"
+      compiler: mingw-cmake
       configuration: Release
-      arch: x64
-      generator: Visual Studio 16 2019
-      shared: ON
-    - compiler: vc14-cmake
+    - image: "Visual Studio 2019"
+      compiler: mingw-cmake
       configuration: Debug
-      arch: Win32
-      generator: Visual Studio 16 2019
-      shared: OFF
-
 
 cache:
   #- 'c:\projects\download -> appveyor.yml'
 
-# Operating system (build VM template)
-os: 'Visual Studio 2019'
-
-# clone directory
+# Clone directory
 clone_folder: 'c:\projects\libtiff'
 clone_depth: 5
 
-platform: x64
-
 init:
   - git config --global core.autocrlf input
 
 before_build:
+  - 'if %compiler%==vc-cmake if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2022" set "generator=Visual Studio 17 2022"'
+  - 'if %compiler%==vc-cmake if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" set "generator=Visual Studio 16 2019"'
+  - 'if %compiler%==cygwin-cmake set "generator=Unix Makefiles"'
+  - 'if %compiler%==mingw-cmake set "generator=Ninja"'
+  - 'if %Configuration%==Release set "shared=ON"'
+  - 'if %Configuration%==Debug set "shared=OFF"'
+  - 'if %compiler%==vc-cmake if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2022" set "arch=x64"'
+  - 'if %compiler%==vc-cmake if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" set "arch=Win32"'
   - 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\cygwin64\bin\cygpath -u %AV_TIFF_SOURCE%`) DO SET AV_TIFF_CYG_SOURCE=%%F'
   - 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\cygwin64\bin\cygpath -u %AV_TIFF_INSTALL%`) DO SET AV_TIFF_CYG_INSTALL=%%F'
   - 'if %compiler%==cygwin-cmake C:\cygwin64\setup-x86_64 -q -R C:\cygwin64 -s http://cygwin.mirror.constant.com -l %AV_TIFF_DOWNLOAD%\cygwin -P cmake,libjpeg-devel,zlib-devel'
   - 'if %compiler%==cygwin-cmake set "PATH=C:\cygwin64\bin;%PATH%"'
-  - set
   - 'if %compiler%==cygwin-cmake cygpath --version || echo cygpath not found'
   - 'if %compiler%==cygwin-cmake cmake --version || echo CMake not found'
   - set "AV_CMAKE_ARGS=-DBUILD_SHARED_LIBS:BOOL=%shared%"
@@ -64,21 +68,24 @@ before_build:
   - set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_INSTALL%"
   - 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_CYG_SOURCE%'
   - 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_CYG_INSTALL%'
-  - 'if %compiler%==mingw-cmake set "PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH%"'
+  - 'if %compiler%==mingw-cmake C:\msys64\usr\bin\bash -lc "pacman -Syuu --noconfirm"'
+  - 'if %compiler%==mingw-cmake C:\msys64\usr\bin\bash -lc "pacman -Syuu --noconfirm"'
+  - 'if %compiler%==mingw-cmake C:\msys64\usr\bin\bash -lc "pacman -S --needed --noconfirm mingw-w64-ucrt-x86_64-{toolchain,cmake,ninja,zlib,libjpeg-turbo}"'
+  - 'if %compiler%==mingw-cmake set "PATH=C:\msys64\ucrt64\bin;C:\msys64\usr\bin;%PATH%"'
   - mkdir %AV_TIFF_BUILD%
   - cd %AV_TIFF_BUILD%
+  - set
   - echo Running cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_TIFF_CMAKE_SOURCE%
   # Disable doc building because of 'Could not import extension sphinxcontrib.applehelp (exception: No module named 'sphinxcontrib.applehelp')'
   - 'if %compiler%==cygwin-cmake bash -c "cmake -G \"%generator%\" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE% -Dtiff-docs=off"'
   - 'if %compiler%==mingw-cmake cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
-  - 'if %compiler%==vc14-cmake cmake -G "%generator%" -A %arch% -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
+  - 'if %compiler%==vc-cmake cmake -G "%generator%" -A %arch% -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
 
 build_script:
   - cd %AV_TIFF_BUILD%
   - 'if %compiler%==cygwin-cmake bash -c "cmake --build . --config %configuration% --target install"'
   - 'if %compiler%==mingw-cmake cmake --build . --config %configuration% --target install'
-  - 'if %compiler%==vc14-cmake cmake --build . --config %configuration% --target install'
-  - 'if %compiler%==vc9-cmake cmake --build . --config %configuration% --target install'
+  - 'if %compiler%==vc-cmake cmake --build . --config %configuration% --target install'
 
 # scripts to run after build
 after_build:
@@ -91,8 +98,7 @@ before_test:
   - cd %AV_TIFF_BUILD%
   - 'if %compiler%==cygwin-cmake bash -c "ctest -V -C %configuration%"'
   - 'if %compiler%==mingw-cmake ctest -V -C %configuration%'
-  - 'if %compiler%==vc14-cmake ctest -V -C %configuration%'
-  - 'if %compiler%==vc9-cmake ctest -V -C %configuration%'
+  - 'if %compiler%==vc-cmake ctest -V -C %configuration%'
 
 # AppVeyor don't yet have a configurable retention policy, so this will
 # eventually use up all the storage allowance.