ci: Serialize vcpkg applocal deployment on Windows (#3408)

In parallel Ninja builds on Windows with vcpkg, concurrent invocations
of `vcpkg z-applocal` post-build commands collide when copying shared
runtime DLLs (such as libpng16.dll or z.dll) into the same output
directory (tests/). This triggers transient Windows file-sharing
violations ("The process cannot access the file because it is being used
by another process").

Enable `X_VCPKG_APPLOCAL_DEPS_SERIALIZED=ON` to add USES_TERMINAL to
the post-build step, forcing Ninja to serialize the dependency-copying
operations while keeping compilation and linking fully parallel.
diff --git a/.github/actions/setup-windows/action.yml b/.github/actions/setup-windows/action.yml
index 5ace229..db453eb 100644
--- a/.github/actions/setup-windows/action.yml
+++ b/.github/actions/setup-windows/action.yml
@@ -35,7 +35,7 @@
   ext-cache-hit:
     value: ${{ steps.cache.outputs.ext-cache-hit }}
   vcpkg-cmake-config:
-    value: ${{ steps.vcpkg.outputs.vcpkg-cmake-config }}
+    value: ${{ steps.vcpkg.outputs.vcpkg-cmake-config != '' && format('{0} -DX_VCPKG_APPLOCAL_DEPS_SERIALIZED=ON', steps.vcpkg.outputs.vcpkg-cmake-config) || '' }}
 runs:
   using: "composite"
   steps:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ae2e6ec..e967765 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,6 +45,11 @@
 include(AvifExternalProjectUtils)
 include(GNUInstallDirs)
 
+# Prevent race condition when copying dependencies in parallel builds with vcpkg on Windows.
+if(WIN32 AND VCPKG_APPLOCAL_DEPS)
+    set(X_VCPKG_APPLOCAL_DEPS_SERIALIZED ON CACHE BOOL "Add USES_TERMINAL to VCPKG_APPLOCAL_DEPS to force serialization." FORCE)
+endif()
+
 option(AVIF_ENABLE_NODISCARD "Add [[nodiscard]] to some functions." OFF)
 
 # Set C11 as the default