CMake Configuration Issue when using Qt Creator

2019-07-17 06:15发布

问题:

I am trying to set up a build environment in qt creator using cmake, but no matter what I try I cannot get it to progress. It fails with issue; "Configuration Issue". When expanding the details in the General Messages section it looks like its failing to compile a test c program.

I can't see anything wrong with my qt creator configuration; which I had to set up in the past manually to use qmake for a qt app. This worked as desired. Here is that configuration.

This is the error in full as displayed in general messages;

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".

The content of the actual CMake file doesn't seem to matter, so I'm heavily leaning on something not being correctly configured.

I've tried messing with the toolchain to no avail. Any ideas?

回答1:

I figured it out in the end.

This is the process I went through. Initially I assumed I had some how not configured the compiler toolchain correctly, so to rule that out I switched to the MinGW GNU toolchain gcc/gdb.

The issue persisted, so that left only two real possibility. CMake was broken or the CMake Generator wasn't correctly configured. Ignoring the first for sanity reasons that left the generator.

I tried switching through a few of the provided options, obviously I didn't have any of them installed. But finally one gave me a reasonable error, that Qt Creator couldn't find it. (I switched to ninja from nmake).

I installed it, and added it to the OS PATH environment variable; so Qt Creator could find it. (Windows 10: Control Panel > System > Advanced system settings (sidebar) > Environment Variables + Set Path > OK)

(Linux: add export PATH="${PATH}": to something like your bashrc). Probably wouldn't be an issue on Linux unless you installed the program from source.

Anyway, that was frustrating. Setting up a new development environment sucks.