Skip to content

Commit 91a1864

Browse files
BenLocalclaude
andcommitted
fix(build): pass CMAKE_POLICY_VERSION_MINIMUM literally on Windows
- Pass cmake args as single-quoted literals via splatting (`cmake @cmakeArgs`): the bare `-DCMAKE_POLICY_VERSION_MINIMUM=3.5` token was mangled to "3" by PowerShell's native-argument parsing (the ".5" dropped), so CMake rejected it and configure aborted at ZLToolKit's `cmake_minimum_required(VERSION 3.1.3...3.26)` — the override is required because CMake 4.x on windows-latest refuses policy versions < 3.5. Single quotes force the value through verbatim; the same =3.5 already works in the bash macOS/Linux builds. - Add `$LASTEXITCODE` checks after vcpkg install, cmake configure, and cmake build: PowerShell's `$ErrorActionPreference=Stop` ignores native exe exit codes, so the script ran past the failed configure, packaged a junk zip, and printed a false "Build success" (the step only failed later via MSBuild's leftover exit code). Now it stops at the real failure point. Signed-off-by: benshi <807629978@qq.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3e45994 commit 91a1864

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

build-windows.ps1

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,32 @@ Write-Host "Installing OpenSSL via vcpkg ($vcpkgTriplet)..."
5151
"openssl:$vcpkgTriplet" `
5252
"ffmpeg:$vcpkgTriplet" `
5353
"libsrtp:$vcpkgTriplet"
54+
if ($LASTEXITCODE -ne 0) { throw "vcpkg install failed (exit $LASTEXITCODE)" }
5455

5556
Write-Host "Building ZLMediaKit for Windows..."
56-
cmake -S . -B build -A $cmakeArch `
57-
-DCMAKE_BUILD_TYPE=Release `
58-
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 `
59-
-DOPENSSL_USE_STATIC_LIBS=ON `
60-
-DCMAKE_TOOLCHAIN_FILE="$vcpkgRoot/scripts/buildsystems/vcpkg.cmake" `
61-
-DVCPKG_TARGET_TRIPLET="$vcpkgTriplet" `
62-
-DENABLE_TESTS=OFF `
63-
-DENABLE_OPENSSL=ON `
64-
-DENABLE_SRT=ON `
65-
-DENABLE_WEBRTC=ON `
66-
-DENABLE_FFMPEG=ON `
67-
-DENABLE_API=ON
57+
# Pass cmake args as single-quoted literals via splatting. A bare
58+
# `-DCMAKE_POLICY_VERSION_MINIMUM=3.5` token gets mangled to "3" by PowerShell's
59+
# native-argument parsing (the ".5" is dropped), which CMake then rejects.
60+
$cmakeArgs = @(
61+
'-S', '.', '-B', 'build', '-A', $cmakeArch,
62+
'-DCMAKE_BUILD_TYPE=Release',
63+
'-DCMAKE_POLICY_VERSION_MINIMUM=3.5',
64+
'-DOPENSSL_USE_STATIC_LIBS=ON',
65+
"-DCMAKE_TOOLCHAIN_FILE=$vcpkgRoot/scripts/buildsystems/vcpkg.cmake",
66+
"-DVCPKG_TARGET_TRIPLET=$vcpkgTriplet",
67+
'-DENABLE_TESTS=OFF',
68+
'-DENABLE_OPENSSL=ON',
69+
'-DENABLE_SRT=ON',
70+
'-DENABLE_WEBRTC=ON',
71+
'-DENABLE_FFMPEG=ON',
72+
'-DENABLE_API=ON'
73+
)
74+
cmake @cmakeArgs
75+
if ($LASTEXITCODE -ne 0) { throw "CMake configure failed (exit $LASTEXITCODE)" }
6876

6977
# Build only runtime target to avoid test/api linkage issues in CI.
7078
cmake --build build --config Release --target MediaServer --parallel
79+
if ($LASTEXITCODE -ne 0) { throw "CMake build failed (exit $LASTEXITCODE)" }
7180

7281
$releaseRoot = Get-ChildItem -Path (Join-Path $srcDir "release") -Directory -Recurse | Where-Object { $_.Name -eq "Release" } | Select-Object -First 1
7382
if (-not $releaseRoot) {

0 commit comments

Comments
 (0)