ci: fix the Windows arm64 build

GitHub's Windows runners are x64, so arm64 is a cross build. vcvarsall
sets up the ARM64 compiler, but CMake still reported the build machine's
own CPU (AMD64) as the target. astcenc then built its SSE4.1 version and
opus turned on its x86 SIMD files, neither of which compiles for ARM.

build_windows.bat now passes CMAKE_SYSTEM_NAME/CMAKE_SYSTEM_PROCESSOR
whenever the target differs from the build machine (arm64 from x64,
x86 from x64, x64 from an ARM PC).

Checked with MSVC 14.51: arm64 failed before this and builds after it
(the exe is ARM64); x86 and x64 still build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ToastconcernandClaude Opus 5.5 committed 2026-10-22 11:57:00 -05:00
1 parent 9b28f864d3
commit edccc0c115
1 file changed
+7 -1
+7 -1
View File
@@ -21,6 +21,12 @@ if /i "%ARCH%"=="arm64" set "VCARCH=%HOSTARCH%_arm64"
if "%VCARCH%"=="" ( echo ERROR: unknown architecture "%ARCH%": x64, x86 or arm64 & exit /b 1 )
if "%VCARCH%"=="amd64_amd64" set "VCARCH=amd64"
if "%VCARCH%"=="arm64_arm64" set "VCARCH=arm64"
REM Built for another architecture than this PC's: tell CMake, or it reports this PC's own (AMD64) and astcenc/opus
REM pick x86 SIMD code for an ARM64 build.
set "CROSS="
if /i "%ARCH%"=="x86" set "CROSS=-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=X86"
if /i "%ARCH%"=="arm64" if /i not "%HOSTARCH%"=="arm64" set "CROSS=-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64"
if /i "%ARCH%"=="x64" if /i "%HOSTARCH%"=="arm64" set "CROSS=-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=AMD64"
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
for /f "usebackq tokens=*" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VSPATH=%%i"
@@ -29,6 +35,6 @@ call "%VSPATH%\VC\Auxiliary\Build\vcvarsall.bat" %VCARCH% >nul || ( echo ERROR:
where cmake >nul 2>nul || set "PATH=%VSPATH%\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;%PATH%"
where ninja >nul 2>nul || set "PATH=%VSPATH%\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;%PATH%"
cmake -S "%SRC%." -B "%BDIR%" -G Ninja -DCMAKE_BUILD_TYPE=Release || exit /b 1
cmake -S "%SRC%." -B "%BDIR%" -G Ninja -DCMAKE_BUILD_TYPE=Release %CROSS% || exit /b 1
cmake --build "%BDIR%" --target frame-studio || exit /b 1
echo Built "%BDIR%\Frame Studio.exe" (%ARCH%)