AntikM
AntikM

Reputation: 651

QT VC CMake Compiler path

I am trying to setup Qt Creator to use the VC2017 compiler. It detects everything automatically but I keep getting a warning for my Kit setup (shown in the tooltip in the screenshot below) that says CMake configuration has a path to a C/C++ compiler set that does not match the compiler path configured in the tool chain of the kit.

I changed CMake Configuration to the following values:

CMAKE_CXX_COMPILER:STRING=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x64\cl.exe
CMAKE_C_COMPILER:STRING=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x64\cl.exe
CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}

But nothing changes. Here's a screenshot: enter image description here

Screenshot of the Compilers tab:enter image description here

Any help would be highly appreciated. Thanks!

Upvotes: 4

Views: 3272

Answers (1)

Craig Scott
Craig Scott

Reputation: 10137

Rather than hard-coding the compiler paths in the CMake Configuration, use the variables Qt Creator provides for you and then just make sure your kit selects the compilers you want to use from the Compilers drop-down box. Your CMake Configuration should look something like this:

CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}
CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}

The warning is for the kit itself, so it is independent of any build you're trying to use it for. If the warning still persists after setting the CMake Configuration to the above, it may just be Qt Creator not recognising the way the compiler executable is specified.

If you've been experimenting a bit along the way and have had build errors, try clearing your build directory and re-running CMake again. The first time you run CMake in an empty build directory, it should log information about the compiler it is trying to use. If it matches what you expect and the CMake run completes successfully, then the warning can be safely ignored (it won't prevent that kit from being used). You can also confirm the compiler being used by looking for the CMAKE_CXX_COMPILER and CMAKE_C_COMPILER entries in the CMakeCache.txt file at the top of your build tree.

Upvotes: 3

Related Questions