Skip to content

Commit 604f74a

Browse files
committed
fix: add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to x64-windows-static.cmake
1 parent b920a0e commit 604f74a

File tree

2 files changed

+66
-16
lines changed

2 files changed

+66
-16
lines changed

ci/kokoro/windows/builds/cmake.ps1

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,66 @@ if ($missing.count -ge 1) {
4343
$project_root = (Get-Item -Path ".\" -Verbose).FullName -replace "\\", "/"
4444
$vcpkg_root = Install-Vcpkg "${project_root}" ""
4545
$binary_dir="cmake-out/${BuildName}"
46-
# Install all dependencies from the vcpkg.json manifest file.
47-
# This mirrors the behavior of our GHA builds.
46+
47+
Write-Host -ForegroundColor Cyan "----------------------------------------------------------------"
48+
Write-Host -ForegroundColor Cyan "Dumping environment and config before vcpkg install..."
49+
Write-Host -ForegroundColor Cyan "----------------------------------------------------------------"
50+
51+
Write-Host -ForegroundColor Yellow "========= Dumping relevant environment variables ========="
52+
Get-ChildItem env: | Where-Object { $_.Name -like "VCPKG_*" -or $_.Name -like "CMAKE_*" } | Format-List
53+
Write-Host -ForegroundColor Yellow "=========================================================="
54+
55+
$triplet_file = "${project_root}/ci/kokoro/windows/triplets/x64-windows-static.cmake"
56+
Write-Host -ForegroundColor Yellow "========= Dumping triplet file ($triplet_file) ========="
57+
if (Test-Path $triplet_file) {
58+
Get-Content $triplet_file
59+
} else {
60+
Write-Host -ForegroundColor Red "Triplet file not found at $triplet_file"
61+
}
62+
Write-Host -ForegroundColor Yellow "=========================================================="
63+
64+
Write-Host -ForegroundColor Cyan "----------------------------------------------------------------"
65+
Write-Host -ForegroundColor Cyan "Unsetting toxic VCPKG_ROOT and VCPKG_OVERLAY_TRIPLETS env vars..."
66+
Write-Host -ForegroundColor Cyan "----------------------------------------------------------------"
67+
# The VCPKG_ROOT env var is mismatched with the vcpkg we are running,
68+
# which causes vcpkg to ignore other env vars.
69+
# We'll unset them both and pass the overlay-triplets path manually.
70+
Remove-Item env:VCPKG_ROOT -ErrorAction SilentlyContinue
71+
Remove-Item env:VCPKG_OVERLAY_TRIPLETS -ErrorAction SilentlyContinue
72+
73+
# Define the correct path to our custom triplets, which your debug log confirmed
74+
$overlay_triplets_path = "${project_root}/ci/kokoro/windows/triplets"
75+
4876
Write-Host -ForegroundColor Yellow "Attempting vcpkg install..."
49-
& "${vcpkg_root}/vcpkg.exe" install --triplet "${env:VCPKG_TRIPLET}"
77+
Write-Host -ForegroundColor Yellow "Explicitly setting --overlay-triplets=$overlay_triplets_path"
78+
79+
# Install all dependencies, now passing the overlay path on the command line
80+
& "${vcpkg_root}/vcpkg.exe" install --triplet "${env:VCPKG_TRIPLET}" --overlay-triplets="${overlay_triplets_path}"
5081

5182
# Manually check the exit code. vcpkg might not be throwing a terminating error.
5283
if ($LastExitCode -ne 0) {
5384
Write-Host -ForegroundColor Red "----------------------------------------------------------------"
5485
Write-Host -ForegroundColor Red "vcpkg install FAILED with exit code $LastExitCode."
55-
Write-Host -ForegroundColor Red "Dumping vcpkg buildtree logs for crc32c..."
86+
Write-Host -ForegroundColor Red "Dumping vcpkg buildtree logs for known failing packages..."
5687
Write-Host -ForegroundColor Red "----------------------------------------------------------------"
5788

58-
# Define the log files based on the error message
59-
$log1 = "${vcpkg_root}/buildtrees/crc32c/config-x64-windows-static-out.log"
60-
$log2 = "${vcpkg_root}/buildtrees/crc32c/config-x64-windows-static-dbg-CMakeCache.txt.log"
61-
$log3 = "${vcpkg_root}/buildtrees/crc32c/config-x64-windows-static-rel-CMakeCache.txt.log"
62-
63-
foreach ($logFile in @($log1, $log2, $log3)) {
64-
if (Test-Path $logFile) {
65-
Write-Host -ForegroundColor Red "========= Contents of $logFile ========="
66-
Get-Content $logFile
67-
Write-Host -ForegroundColor Red "========= End of $logFile ========="
68-
} else {
69-
Write-Host -ForegroundColor Yellow "Log file not found, skipping: $logFile"
89+
# We'll check logs for *all* known problematic packages
90+
$problem_packages = @("crc32c", "yaml-cpp")
91+
92+
foreach ($pkg in $problem_packages) {
93+
Write-Host -ForegroundColor Magenta "--- Checking logs for $pkg ---"
94+
$log1 = "${vcpkg_root}/buildtrees/${pkg}/config-x64-windows-static-out.log"
95+
$log2 = "${vcpkg_root}/buildtrees/${pkg}/config-x64-windows-static-dbg-CMakeCache.txt.log"
96+
$log3 = "${vcpkg_root}/buildtrees/${pkg}/config-x64-windows-static-rel-CMakeCache.txt.log"
97+
98+
foreach ($logFile in @($log1, $log2, $log3)) {
99+
if (Test-Path $logFile) {
100+
Write-Host -ForegroundColor Red "========= Contents of $logFile ========="
101+
Get-Content $logFile
102+
Write-Host -ForegroundColor Red "========= End of $logFile ========="
103+
} else {
104+
Write-Host -ForegroundColor Yellow "Log file not found, skipping: $logFile"
105+
}
70106
}
71107
}
72108

@@ -86,6 +122,7 @@ $cmake_args=@(
86122
"-DCMAKE_TOOLCHAIN_FILE=`"${vcpkg_root}/scripts/buildsystems/vcpkg.cmake`""
87123
"-DCMAKE_BUILD_TYPE=${env:CONFIG}",
88124
"-DVCPKG_TARGET_TRIPLET=${env:VCPKG_TRIPLET}",
125+
"-DVCPKG_OVERLAY_TRIPLETS=${project_root}/ci/kokoro/windows/triplets",
89126
"-DCMAKE_C_COMPILER=cl.exe",
90127
"-DCMAKE_CXX_COMPILER=cl.exe",
91128
"-DGOOGLE_CLOUD_CPP_ENABLE_WERROR=ON",
@@ -95,6 +132,17 @@ $cmake_args=@(
95132

96133
# Configure CMake and create the build directory.
97134
Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) Configuring CMake with $cmake_args"
135+
136+
Write-Host -ForegroundColor Cyan "----------------------------------------------------------------"
137+
Write-Host -ForegroundColor Cyan "Dumping VCPKG_ROOT before removal..."
138+
Get-ChildItem env:VCPKG_ROOT -ErrorAction SilentlyContinue | Format-List
139+
# Unset the toxic env var *again* just before the main cmake call
140+
Write-Host -ForegroundColor Cyan "Removing VCPKG_ROOT..."
141+
Remove-Item env:VCPKG_ROOT -ErrorAction SilentlyContinue
142+
Write-Host -ForegroundColor Cyan "Dumping VCPKG_ROOT after removal..."
143+
Get-ChildItem env:VCPKG_ROOT -ErrorAction SilentlyContinue | Format-List
144+
Write-Host -ForegroundColor Cyan "--- END DEBUG LOGGING (VCPKG_ROOT) ---"
145+
98146
cmake $cmake_args
99147
if ($LastExitCode) {
100148
Write-Host -ForegroundColor Red "cmake config failed with exit code $LastExitCode"

ci/kokoro/windows/triplets/x64-windows-static.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ set(VCPKG_LIBRARY_LINKAGE static)
44
set(VCPKG_VISUAL_STUDIO_PATH
55
"C:\\Program Files (x86)\\Microsoft Visual Studio\\$ENV{MSVC_VERSION}\\BuildTools"
66
)
7+
set(VCPKG_CMAKE_CONFIGURE_OPTIONS
8+
"${VCPKG_CMAKE_CONFIGURE_OPTIONS};-DCMAKE_POLICY_VERSION_MINIMUM=3.5")

0 commit comments

Comments
 (0)