Skip to content

Commit 92a5d7d

Browse files
committed
fix: set CMAKE_POLICY_VERSION_MINIMUM=3.5
1 parent b920a0e commit 92a5d7d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

ci/kokoro/windows/builds/cmake.ps1

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@ if ($missing.count -ge 1) {
4242

4343
$project_root = (Get-Item -Path ".\" -Verbose).FullName -replace "\\", "/"
4444
$vcpkg_root = Install-Vcpkg "${project_root}" ""
45+
46+
# The crc32c portfile (1.1.2#2) in this vcpkg checkout has a CMakeLists.txt
47+
# that is too old for the CMake version on the CI. The error log suggests
48+
# this fix. We will patch the portfile on the fly before running install.
49+
Write-Host -ForegroundColor Cyan "Patching crc32c portfile for CMake policy..."
50+
$crc32c_portfile = "${vcpkg_root}/ports/crc32c/portfile.cmake"
51+
if (Test-Path $crc32c_portfile) {
52+
$content = Get-Content -Raw -Path $crc32c_portfile
53+
# Add our policy fix to the vcpkg_cmake_configure call
54+
$content = $content -replace "vcpkg_cmake_configure(", "vcpkg_cmake_configure( OPTIONS -DCMAKE_POLICY_VERSION_MINIMUM=3.5 "
55+
Set-Content -Path $crc32c_portfile -Value $content
56+
Write-Host -ForegroundColor Cyan "Patch applied to $crc32c_portfile."
57+
} else {
58+
Write-Host -ForegroundColor Red "Could not find crc32c portfile at $crc32c_portfile. Skipping patch (build will likely fail)."
59+
}
60+
4561
$binary_dir="cmake-out/${BuildName}"
4662
# Install all dependencies from the vcpkg.json manifest file.
4763
# This mirrors the behavior of our GHA builds.
@@ -90,7 +106,8 @@ $cmake_args=@(
90106
"-DCMAKE_CXX_COMPILER=cl.exe",
91107
"-DGOOGLE_CLOUD_CPP_ENABLE_WERROR=ON",
92108
"-DGOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND=ON",
93-
"-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>"
109+
"-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>",
110+
"-DCMAKE_POLICY_VERSION_MINIMUM=3.5"
94111
)
95112

96113
# Configure CMake and create the build directory.

0 commit comments

Comments
 (0)