How does CMake find the cxx compiler?

血红的双手。 提交于 2020-01-14 12:27:26

问题


I am calling cmake -G "NMake Makefiles" from a Microsoft Visual C++ 2010 x64 command prompt. The C compiler identification is correct, but the CXX compiler identification not.

I am really confused, because it has worked before, but I could not determine what changed (Windows update?) and raised this issue. So I am searching for the root for this problem.

How does CMake find the cxx compiler (on Windows: cl.exe) and maybe how do I change this behavior? (Setting CMAKE_CXX_COMPILER seems not to have any effect.)

Here the strange output of CMake:

The C compiler identification is MSVC 16.0.40219.1
The CXX compiler identification is unknown
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC  /bin/amd64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/amd64/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/x86_amd64/cl.exe
CMake Error: your CXX compiler: "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/x86_amd64/cl.exe" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
CMake Error: Internal CMake error, TryCompile configure of cmake failed
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/x86_amd64/cl.exe -- broken
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/x86_amd64/cl.exe" is not able to compile a simple test program.

Visual Studio 9 is not installed on this machine (Where on earth is the path C:/Program Files (x86)/Microsoft Visual Studio 9.0 coming from? It does not exit on this machine, and I did not type it anywhere in CMake.)

CMake (output above) was called from a Visual Studio command prompt. This call reproduces this issue:

call "%VS100COMNTOOLS%"\..\..\VC\bin\amd64\vcvars64.bat 
cmake -G "NMake Makefiles" C:\base_repos\free

Visual Studio 2010 Ultimate (SP1 installed)

来源:https://stackoverflow.com/questions/23477379/how-does-cmake-find-the-cxx-compiler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!