CMake 3.9 Generates build.ninja failed on Non-Engish Windows
Starting with CMake 3.9, cmake cannot generates build.ninja
on Non-Engish Windows. When we use chcp 65001
or change current console CodePage, cmake can generates build.ninja
.
cmake 3.8.2 is success.
CMake log:
CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/CMakeTestCXXCompiler.cmake:44 (message):
The C++ compiler "C:/Program Files (x86)/Microsoft Visual
Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX64/x86/cl.exe" is
not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/git/vcpkg/buildtrees/gflags/x86-windows-rel/CMakeFiles/CMakeTmp
Run Build
Command:"D:/git/vcpkg/downloads/tools/ninja/ninja-1.7.2/ninja.exe"
"cmTC_81c7a"
ninja: error: build.ninja:30: loading 'rules.ninja':
系统找不到指定的文件。
include rules.ninja
^ near here
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:94 (project)
This error info is The system cannot find the file specified
Your can use chcp change console codepage to non-Engish Windows (cp936) test cmake -GNinja
.
Function ProcessExec {
param(
[string]$FilePath,
[string]$Arguments,
[string]$WorkingDirectory
)
$ProcessInfo = New-Object System.Diagnostics.ProcessStartInfo
$ProcessInfo.FileName = $FilePath
Write-Host "$FilePath $Arguments $PWD"
if ($WorkingDirectory.Length -eq 0) {
$ProcessInfo.WorkingDirectory = $PWD
}
else {
$ProcessInfo.WorkingDirectory = $WorkingDirectory
}
$ProcessInfo.Arguments = $Arguments
$ProcessInfo.UseShellExecute = $false ## use createprocess not shellexecute
$Process = New-Object System.Diagnostics.Process
$Process.StartInfo = $ProcessInfo
if ($Process.Start() -eq $false) {
return -1
}
$Process.WaitForExit()
return $Process.ExitCode
}
Function ClangNinjaGenerator{
param(
[String]$ClangExe,
[String]$BuildDir
)
$env:CC=$ClangExe
$env:CXX=$ClangExe
Write-Host "Build llvm, Use: CC=$env:CC CXX=$env:CXX"
Set-Workdir $BuildDir
$Arguments=Get-ClangArgument
$oe=[Console]::OutputEncoding
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 ### Ninja need UTF8
$exitcode = ProcessExec -FilePath "cmake.exe" -Arguments $Arguments
if ($exitcode -ne 0) {
Write-Error "CMake exit: $exitcode"
return 1
}
[Console]::OutputEncoding=$oe
$PN = & Parallel
$exitcode = ProcessExec -FilePath "ninja.exe" -Arguments "all -j $PN"
return $exitcode
}
This problem can be reproduced