使用 Qt Creator 时的 CMake 配置问题

CMake Configuration Issue when using Qt Creator

我正在尝试使用 cmake 在 qt creator 中设置构建环境,但无论我尝试什么,我都无法进行。它因问题而失败; "Configuration Issue"。在“一般消息”部分展开详细信息时,它似乎无法编译测试 c 程序。

我看不出我的 qt creator 配置有什么问题;过去我必须手动设置才能将 qmake 用于 qt 应用程序。这按预期工作。这是那个配置。

这是一般消息中显示的完整错误;

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 文件的内容似乎并不重要,所以我严重依赖未正确配置的内容。

我试过弄乱工具链但无济于事。有任何想法吗?

最后我想通了

这是我经历的过程。最初我假设我有一些没有正确配置编译器工具链,所以为了排除这种情况我切换到 MinGW GNU 工具链 gcc/gdb。

问题依然存在,所以只剩下两个真正的可能性。 CMake 已损坏或 CMake 生成器未正确配置。出于理智原因忽略第一个离开生成器的。

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

我安装了,并且添加到OSPATH环境变量中;所以 Qt Creator 可以找到它。 (Windows10:控制面板>系统>高级系统设置(边栏)>环境变量+设置路径>确定)

(Linux: 添加 export PATH="${PATH}": 到你的 bashrc 之类的东西)。在 Linux 上可能不会成为问题,除非您从源代码安装该程序。

无论如何,这令人沮丧。设置一个新的开发环境很糟糕。