feat(build): add MSVC cl.exe wrapper for UTF-8 compatibility in Ninja builds

This commit is contained in:
西风逍遥游 committed 2026-08-29 11:59:33 +08:00
1 parent afc7ee3614
commit 4a88950a14
4 files changed
+26 -2

No files matched your search

+15
View File
@@ -49,6 +49,21 @@ endif()
project(EVEngine)
if(WIN32 AND MSVC AND CMAKE_GENERATOR MATCHES "Ninja")
# sccache (and any other launcher) CreateProcess()es cl.exe with a pipe;
# localized cl then writes ACP /showIncludes (GBK) while Ninja's
# msvc_deps_prefix is UTF-8, so every header leaks into the build log.
# Route compiles through cmake/msvc-cl.cmd so cl inherits CP65001.
set(_eve_msvc_cl_wrap "${CMAKE_SOURCE_DIR}/cmake/msvc-cl.cmd")
foreach(_eve_lang IN ITEMS C CXX)
get_filename_component(_eve_comp_name "${CMAKE_${_eve_lang}_COMPILER}" NAME)
if(_eve_comp_name MATCHES "^cl(\\.exe)?$")
set(CMAKE_${_eve_lang}_COMPILER "${_eve_msvc_cl_wrap}"
CACHE FILEPATH "MSVC cl UTF-8 /showIncludes wrapper" FORCE)
endif()
endforeach()
endif()
if(_eve_sccache_enabled AND MSVC)
if(POLICY CMP0141)
# Embed debug information in each object. Cached objects are then
+2 -2
View File
@@ -260,8 +260,8 @@ ARCHITECTURE_BASE ?= HEAD
# Reusable configure command lines: used both by the first-configure rules and
# by the on-change reconfigure inside the build recipes below.
WIN32_CMAKE_ARGS = -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl $(CMAKE_EXTRA_ARGS) -B build/win32 -S .
WIN32_DEBUG_CMAKE_ARGS = -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl $(CMAKE_EXTRA_ARGS) -B build/win32-debug -S .
WIN32_CMAKE_ARGS = -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=cmake/msvc-cl.cmd -DCMAKE_CXX_COMPILER=cmake/msvc-cl.cmd $(CMAKE_EXTRA_ARGS) -B build/win32 -S .
WIN32_DEBUG_CMAKE_ARGS = -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=cmake/msvc-cl.cmd -DCMAKE_CXX_COMPILER=cmake/msvc-cl.cmd $(CMAKE_EXTRA_ARGS) -B build/win32-debug -S .
LINUX_CMAKE_ARGS = -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Release -DBUILD_PLATFORM=linux $(CMAKE_EXTRA_ARGS) -B build/linux -S .
LINUX_DEBUG_CMAKE_ARGS = -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Debug -DBUILD_PLATFORM=linux $(CMAKE_EXTRA_ARGS) -B build/linux-debug -S .
MACOSX_CMAKE_ARGS = -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Release -DBUILD_PLATFORM=macosx $(CMAKE_EXTRA_ARGS) -B build/macosx -S .
+7
View File
@@ -0,0 +1,7 @@
@echo off
rem Used as CMAKE_C/CXX_COMPILER under Ninja+sccache so cl.exe is a child of
rem this cmd (CP65001), not of sccache's ACP pipe.
chcp 65001 >nul
set "VSLANG=1033"
cl.exe %*
exit /b %ERRORLEVEL%
+2
View File
@@ -1,6 +1,8 @@
@echo off
chcp 65001 >nul
setlocal
rem Prefer English cl.exe messages when the 1033 language pack is installed.
set "VSLANG=1033"
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%VSWHERE%" (
echo error: vswhere.exe not found at "%VSWHERE%" >&2