編輯: 已將此發佈到他們的問題跟蹤器,並與一些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