Dorian
Dorian

Reputation: 417

CMAKE_CXX_COMPILER not set in qtcreator

Is there a way (like command line argument or some function in CMakeLists.txt) to print all command line arguments supplied to cmake invocation? Equivalent of bash "echo $@"

I need this to debug, why cmake invoked from qtcreator does not find my compiler (msvc12). After inspecting qtcreator sources, I see that it appends some environment by cmake arguments depending on selected kit. I got messages like

CMAKE_CXX_COMPILER not set

, when I select both "Nmake Desktop Qt MSVC2013 ..." or "Ninja Qt MSVC2013".

When I call cmake from command line, it finds compiler with no additional parameters:

-- Check for working CXX compiler using: Visual Studio 12 2013 -- Check for working CXX compiler using: Visual Studio 12 2013 -- works

Upvotes: 1

Views: 3569

Answers (2)

jaques-sam
jaques-sam

Reputation: 2795

I had the same problem after upgrading Visual Studio 2017.

For some reason, when ADDING (?) CMAKE_CXX_COMPILER in the cmake configuration in Build & Run to the location of the Visual Studio compiler, it should work:

  • Key: CMAKE_CXX_COMPILER
  • Value: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe ==> replace version with the correct one

Don't forget to click "Apply Configuration Changes" below. Very strange though, because after building, the cmake run becomes CMake Project was parsed successfully.and believe-it-or-not, the CMAKE_CXX_COMPILER is gone!

Upvotes: 1

Dorian
Dorian

Reputation: 417

My main problem was solved by installing ninja. I thought that the problem was not finding compiler by cmake invoked by qtcreator:

CMAKE_CXX_COMPILER not set

After installing ninja and restarting qtcreator, the problem was gone.

Upvotes: 1

Related Questions