Disable dll copies by vcpkg to avoid race condition (#3412) This variable is explained at: https://learn.microsoft.com/en-us/vcpkg/users/buildsystems/cmake-integration#vcpkg_applocal_deps Parallel ninja builds call "vcpkg z-applocal" in parallel which can creaate collisions. X_VCPKG_APPLOCAL_DEPS_SERIALIZED (from #3408) did not resolve this because CMake's Ninja generator inlines target post-build commands directly into the linker rule and does not place them in the terminal/console pool. VCPKG_APPLOCAL_DEPS=OFF disables the post build copies. We still need to find the dlls so the the build folder is added to the path. It should fix the issues we've been seeing on the Windows CI with vcpkg.
diff --git a/.github/actions/setup-windows/action.yml b/.github/actions/setup-windows/action.yml index db453eb..a866a79 100644 --- a/.github/actions/setup-windows/action.yml +++ b/.github/actions/setup-windows/action.yml
@@ -35,7 +35,9 @@ ext-cache-hit: value: ${{ steps.cache.outputs.ext-cache-hit }} vcpkg-cmake-config: - value: ${{ steps.vcpkg.outputs.vcpkg-cmake-config != '' && format('{0} -DX_VCPKG_APPLOCAL_DEPS_SERIALIZED=ON', steps.vcpkg.outputs.vcpkg-cmake-config) || '' }} + # Disable vcpkg applocal deployment to prevent race conditions during parallel Ninja builds. + # Dependent DLLs are added to PATH instead. + value: ${{ steps.vcpkg.outputs.vcpkg-cmake-config != '' && format('{0} -DVCPKG_APPLOCAL_DEPS=OFF', steps.vcpkg.outputs.vcpkg-cmake-config) || '' }} runs: using: "composite" steps: @@ -112,6 +114,13 @@ mv ${{ github.workspace }}\tmp\rav1e-windows-msvc-sdk\lib\pkgconfig\* ${{ github.workspace }}\vcpkg\installed\x64-windows-release\lib\pkgconfig shell: pwsh + - name: Add dependent DLLs to PATH + if: env.AVIF_WIN_LIBRARIES != '' || inputs.codec-rav1e == 'SYSTEM' + run: | + echo "${{ github.workspace }}\vcpkg\installed\x64-windows-release\bin" >> $env:GITHUB_PATH + echo "${{ github.workspace }}\build" >> $env:GITHUB_PATH + shell: pwsh + - uses: ./.github/actions/cache id: cache with:
diff --git a/CMakeLists.txt b/CMakeLists.txt index e967765..ae2e6ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -45,11 +45,6 @@ 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