【发布时间】:2020-10-12 11:48:57
【问题描述】:
将我的 windows 10 更新到 1903 后,使用 CreateProcess 执行以下 cmake 命令:
命令:cmd /C "cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_TOOLCHAIN_FILE="D:/vcpkg/scripts/buildsystems/vcpkg.cmake"" ..
代码:CreateProcess("C:\\Windows\\System32\\cmd.exe", command, NULL, NULL, FALSE, NULL, 0, workingDir, &si, &pi))
找不到编译器:
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.18362.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Configuring incomplete, errors occurred!
但是当直接从命令提示符执行完全相同的命令时会成功(找到正确的 MSVC 编译器)。
通过跟踪挖掘后,我发现CMakeDetermineCompilerId.cmake 在编译CompilerIdC.vcxproj 时失败:
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\CL.exe /c /I"D:\vcpkg\installed\x64-windows\include" /nologo /W0 /WX- /diagnostics:classic /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc141.pdb" /Gd /TC /FC /errorReport:queue CMakeCCompilerId.c
FileTracker : error FTK0001: could not attach tracking. The storage
control block address is invalid.
[D:\[path redacted]\CMakeFiles\3.12.2\CompilerIdC\CompilerIdC.vcxproj]
这是唯一的错误,在此之前的所有跟踪输出,包括版本和路径,都与从命令行成功编译时完全相同。
如何解决此错误,或者这是 CreateProcess 的问题? (此代码在使用完全相同的编译器的 Windows 10 1803 上没有问题)
【问题讨论】:
-
能否在不运行 CMake 的情况下创建一个简单的 win32 应用程序,看看是否可以成功定位 SDK 版本 18362?
-
我找到了答案。感谢您的评论。
标签: c++ visual-studio winapi cmake