Skip to content

Commit 7577a52

Browse files
BenLocalclaude
andcommitted
fix(build): move CMAKE_POLICY_VERSION_MINIMUM into a -C cache file
- Pass the policy override via a CMake initial-cache file (`-C $workDir/policy-min.cmake` containing `set(CMAKE_POLICY_VERSION_MINIMUM 3.5 CACHE STRING "" FORCE)`) instead of `-D...=3.5`: the prior single-quote/splat fix (91a1864) still wasn't enough — PowerShell's native-arg parser reads the `3.5` as a number and splits the token into `...=3` + `.5` (CMake logs `Ignoring extra path from command line: ".5"` and then rejects the leftover value "3"). Keeping the decimal inside a .cmake file means CMake parses it itself and PowerShell never tokenizes it. - The `-C` cache loads before the first listfile pass, so it covers the top-level cmake_minimum_required (CMakeLists.txt:24), ZLToolKit, and the vcpkg toolchain's cmake_policy calls — all of which were failing on the mangled value. Override still needed because ZLToolKit/ZLMediaKit declare cmake_minimum_required(VERSION 3.1.3...3.26) and CMake 4.x dropped <3.5 policy compat. Signed-off-by: benshi <807629978@qq.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 91a1864 commit 7577a52

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

build-windows.ps1

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,21 @@ Write-Host "Installing OpenSSL via vcpkg ($vcpkgTriplet)..."
5454
if ($LASTEXITCODE -ne 0) { throw "vcpkg install failed (exit $LASTEXITCODE)" }
5555

5656
Write-Host "Building ZLMediaKit for Windows..."
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.
57+
# Pass CMAKE_POLICY_VERSION_MINIMUM via a CMake initial-cache (-C) file instead of
58+
# -D. PowerShell's native-argument parser reads the `3.5` in a bare
59+
# `-DCMAKE_POLICY_VERSION_MINIMUM=3.5` token as a number and splits it into
60+
# `...=3` + `.5`, so CMake only ever sees "3" (and discards ".5" as a stray path)
61+
# and rejects it. Putting the value inside a .cmake file keeps the decimal off the
62+
# PowerShell command line entirely — CMake parses the file itself. The override is
63+
# required because ZLToolKit/ZLMediaKit declare
64+
# cmake_minimum_required(VERSION 3.1.3...3.26) and CMake 4.x dropped <3.5 policy compat.
65+
$policyCacheFile = Join-Path $workDir "policy-min.cmake"
66+
Set-Content -Path $policyCacheFile -Encoding ASCII -Value 'set(CMAKE_POLICY_VERSION_MINIMUM 3.5 CACHE STRING "" FORCE)'
67+
6068
$cmakeArgs = @(
6169
'-S', '.', '-B', 'build', '-A', $cmakeArch,
70+
'-C', $policyCacheFile,
6271
'-DCMAKE_BUILD_TYPE=Release',
63-
'-DCMAKE_POLICY_VERSION_MINIMUM=3.5',
6472
'-DOPENSSL_USE_STATIC_LIBS=ON',
6573
"-DCMAKE_TOOLCHAIN_FILE=$vcpkgRoot/scripts/buildsystems/vcpkg.cmake",
6674
"-DVCPKG_TARGET_TRIPLET=$vcpkgTriplet",

0 commit comments

Comments
 (0)