修改 将此发布到他们的问题跟踪器并与一些CMake开发人员一起介绍它,这实际上不是一个CMake问题。我的MSBuild安装导致它返回“操作已成功完成”。错误。但总体上还没有解决这个问题,但这缩小了潜在的原因。
我正在尝试使用MS Visual C ++ Build Tools 2015在Windows上构建一个CMake项目(注意:不完整的Visual Studio)。但是,CMake显然无法找到cl.exe
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 ++ shell(将工具添加到路径)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... ]
这就是我正在运行cmake ..
的相同环境,所以cl.exe肯定在PATH上供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 Build Tools。有什么想法吗?
编辑3: 我认为从3.8.0-rc4升级到3.8.0可能会解决它,但无济于事。我还认为我正在使用64位CMake尝试构建一个32位程序,所以我也改变了它。没有运气了。
编辑4: 此外,为了记录,这确实在安装了完整VS 2015的PC上与CMake一起构建。
答案 0 :(得分:1)
我不确定是否为您的The operation completed successfully
问题提供了解决方案,但我能够使用cmake 3.8.1和C ++ 2015 BuildTools编译[大]现实生活项目。< / p>
诀窍就是使用&#34; VS2015 x64 Native Tools命令提示符&#34; (或x86)。您可以使用此提示调用cmake,也可以从正常提示中call
显示此提示,它将正确设置您的路径。
REM Set up the include/lib paths of Visual Studio
call "C:\Program Files (x86)\Microsoft Visual C++ Build Tools\vcbuildtools.bat" amd64
cd to_build_dir
REM Call cmake with the right parameters
"C:\Program Files\CMake\bin\cmake.exe" .......
REM Build the XYZ project
MSBuild.exe SOLUTION_FILE.sln /t:XYZ .......
正如我写的那样,我不确定它是否能解决您的错误,因为我无法重现它。但是,我知道只有在使用正确的提示时我的项目才会编译。如果我没有使用它,我会得到一些error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.