编辑: 已将此发布到他们的问题跟踪器,并与一些CMake开发人员一起通过它,这实际上不是CMake问题。我的MSBuild安装导致它返回“操作成功完成”。错误。总体上仍然没有解决这个问题,但是这缩小了潜在的原因。我想在Windows上使用MS Visual C++构建工具2015(注意:不是完整的Visual Studio)构建一个CMake项目。 CMake的,但是,显然无法找到cl.exe时CMake与Microsoft Visual C++构建工具
cmake ..
-- Building for: Visual Studio 14 2015
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:4 (project):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:4 (project):
No CMAKE_CXX_COMPILER could be found.
我怀疑这是因为CMake的是希望找到编译器与Visual Studio安装,但也许是独立的构建工具安装在不同的位置?是否可以配置CMake在其他地方寻找编译器?
编辑:为了把这个可能性关掉,cl.exe肯定是安装的。当我打开Visual C++壳(添加工具路径)输出的cl.exe:
cl.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
这是我从这么运行的cl.exe的cmake ..
同样的环境,绝对是对的路径探索由CMake。
编辑2:综观CMakeError.log文件我看到下面的
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 4/14/2017 11:58:13 AM.
Project "E:\<project_dir>\build\CMakeFiles\3.8.0-rc4\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdCXX.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdCXX.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /nologo /W0 /WX- /Od /Oy- /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TP /analyze- /errorReport:queue CMakeCXXCompilerId.cpp
TRACKER : error TRK0002: Failed to execute command: ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe" @C:\Users\<user>\AppData\Local\Temp\tmpa0925a9f05d5426d82afdcee8d722031.rsp". The operation completed successfully. [E:\<project_dir>\build\CMakeFiles\3.8.0-rc4\CompilerIdCXX\CompilerIdCXX.vcxproj]
Done Building Project "E:\<project_dir>\build\CMakeFiles\3.8.0-rc4\CompilerIdCXX\CompilerIdCXX.vcxproj" (default targets) -- FAILED.
Build FAILED.
"E:\<project_dir>\build\CMakeFiles\3.8.0-rc4\CompilerIdCXX\CompilerIdCXX.vcxproj" (default target) (1) ->
(ClCompile target) ->
TRACKER : error TRK0002: Failed to execute command: ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe" @C:\Users\<user>\AppData\Local\Temp\tmpa0925a9f05d5426d82afdcee8d722031.rsp". The operation completed successfully. [E:\<project_dir>\build\CMakeFiles\3.8.0-rc4\CompilerIdCXX\CompilerIdCXX.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.21
这看起来像是某种输出兼容性问题的几个变种,尤其是“错误:操作成功完成。”线。我使用CMake 3.8.0-rc4和Visual C++ 2015构建工具。有任何想法吗?
编辑3: 我认为从3.8.0-rc4升级到3.8.0可能会解决它,但无济于事。我还认为我正在使用64位CMake试图构建一个32位程序,所以我改变了这一点。没有运气。
编辑4: 另外,为了记录,这确实与装有完整VS 2015的PC上的CMake一起构建。
是的。而且我再次检查了我可以在该shell中手动调用cl.exe。 –
这就是我从中获得上述输出的地方,甚至是相同的终端实例。 –
这看起来像一个CMake错误。尝试用尽可能多的信息来报告错误[这里](https://gitlab.kitware.com/cmake/cmake/issues)。也很好地为你的问题添加尽可能多的信息! – tambre