CMAKE_CXX_COMPILER incorrectly set to C Compiler in Qt Creator
-
I have seen this happen on two different machines, so I think it may be a Qt Creator bug, but I don't fully understand what's happening.
On my Linux box, it set the CMAKE_CXX_COMPILER to gcc rather than g++. On OS-X, I was trying to use Clang, and it was set to clang rather than clang++.So, using Qt Creator 4.8.1 on OS-X 10.14.2,
cmake --version
cmake version 3.13.3I can't reproduce the issue outside of Qt Creator so far, so I don't think it's a cmake issue, or an issue with how the compilers are installed. If I inspect Qt Creator's Preferences -> Kits -> Compilers display, and look under C++, Qt Creator seems to be pointing at proper names for C++ compilers . (g++, or clang++, sometimes with a version number in the name, but not the C compiler)
If I open up a CMake project in Qt Creator, and try to build, I get weird linker errors that are ultimately because the C++ standard library isn't being linked. (Manifests with slightly different error messages between gcc and clang on Linux vs. OS-X). After much angry yelling and insisting that the problem is impossible, because I can build on the command line with no problem using cmake, so I know the CMakeLists.txt is valid. The project in the CMakelists.txt specifies that the language is "CXX" so the source isn't being misidentified as C by CMake.
But, if you look under Qt Creator's Projects Build&Run settings, and you click the "advanced" tickbox to see all of the settings that are normally hidden, I will see for example:
CMAKE_CXX_COMPILER is set to "/usr/local/Cellar/llvm/7.0.1/bin/clang-7"
In the case I am looking at right now, it's using a version of clang using brew from /usr/local, but like I mentioned I have seen basically the same issue on an Ubuntu box with gcc installed with apt, so I don't think it's anything to do with the specific compiler installed from brew.
Have other folks run into this? Do they understand the causes? How can I prevent it? Drives me crazy when it happens, and I waste a bunch of time figuring out what on earth is going wrong, and then having to manually edit the setting for every build configuration.
halps!
-
Hi,
Pretty intriguing... Can you provide a minimal compilable example that triggers this ?
Also, did you already check the bug report system for something similar ?