在使用Qt Creator时的CMake配置问题

4
我正在尝试使用CMake在Qt Creator中设置构建环境,但无论我尝试什么都无法使其进展。它会出现"配置问题"的错误。在General Messages部分展开详细信息后,看起来似乎无法编译测试c程序。
我没有看到我的Qt Creator配置有任何问题;过去我必须手动设置才能使用qmake来制作qt应用程序。这是成功的。以下是该配置。

enter image description here

这是一条完整的错误信息,通常显示在常规消息中;

Running Windows Runtime device detection.
No winrtrunner.exe found.
Running "C:\Program Files\CMake\bin\cmake.exe -E server "--pipe=\\.\pipe\{8454d5f3-9c7b-42c8-8f39-a6bfbbbdd562}" --experimental" in 
C:\Users\Andrew\AppData\Local\Temp\QtCreator-l9Mfi9\qtc-cmake-XXUaBP1D.
The C compiler identification is MSVC 19.0.24215.1
The CXX compiler identification is MSVC 19.0.24215.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/x86_amd64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/x86_amd64/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/CMakeTestCCompiler.cmake:51 (message):
  The C compiler "C:/Program Files (x86)/Microsoft Visual Studio
  14.0/VC/BIN/x86_amd64/cl.exe" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: C:/Users/Andrew/AppData/Local/Temp/QtCreator-l9Mfi9/qtc-cmake-XXUaBP1D/CMakeFiles/CMakeTmp



  Run Build Command:"nmake" "/NOLOGO" "cmTC_2c22c\fast"

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe" -f
  CMakeFiles\cmTC_2c22c.dir\build.make /nologo -L
  CMakeFiles\cmTC_2c22c.dir\build

  Building C object CMakeFiles/cmTC_2c22c.dir/testCCompiler.c.obj

            C:\PROGRA~2\MICROS~1.0\VC\BIN\X86_AM~1\cl.exe
  @C:\Users\Andrew\AppData\Local\Temp\nm7672.tmp

  testCCompiler.c

  Linking C executable cmTC_2c22c.exe

"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe
  --intdir=CMakeFiles\cmTC_2c22c.dir --manifests --
  C:\PROGRA~2\MICROS~1.0\VC\bin\X86_AM~1\link.exe /nologo
  @CMakeFiles\cmTC_2c22c.dir\objects1.rsp
  @C:\Users\Andrew\AppData\Local\Temp\nm76B2.tmp

  MT failed to run.

  NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' :
  return code '0xffffffff'

  Stop.

  NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio
  14.0\VC\BIN\nmake.exe"' : return code '0x2'

  Stop.





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)


Configuring incomplete, errors occurred!
See also "C:/Users/Andrew/AppData/Local/Temp/QtCreator-l9Mfi9/qtc-cmake-XXUaBP1D/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Andrew/AppData/Local/Temp/QtCreator-l9Mfi9/qtc-cmake-XXUaBP1D/CMakeFiles/CMakeError.log".

实际的CMake文件内容似乎并不重要,所以我非常倾向于某些配置不正确。我尝试过调整工具链,但没有成功。有什么想法吗?
1个回答

2

最终我解决了这个问题。

下面是我的处理过程。一开始我认为可能是编译器工具链配置有误,因此我换成了MinGW GNU工具链gcc/gdb来排除这种可能。

问题仍然存在,只剩下两个真正的可能性。要么CMake出了问题,要么CMake生成器没有正确配置。考虑到前者不太可能,因此只能是后者。

我尝试了几个提供的选项,显然我没有安装它们中的任何一个。但最后一个给出了一个合理的错误,即Qt Creator找不到它。(我从nmake切换到ninja)。

我安装了它,并将其添加到操作系统PATH环境变量中,以便Qt Creator可以找到它。(Windows 10:控制面板>系统>高级系统设置(侧栏)>环境变量+设置路径>确定)

(Linux: 将export PATH="${PATH}": 添加到类似于bashrc的某个文件中)。在Linux上可能不是问题,除非你从源代码安装程序。

总之,这很令人沮丧。建立新的开发环境很烦人。


1
我在Windows上遇到了很多问题,难以弄清楚。供将来参考,基本的工作配置是:C/C++:Microsoft Visual C++ Compiler 15.0 (amd64),Qt: 5.10 MSVC2017 64bit,CMake Generator CodeBlocks - NMake Makefiles,平台、工具链:<空>;CMake配置:<重置/加载默认值>。 - MateuszL

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接