ProjectExplorer: Allow "c++" for MinGW imported compiler

Usually GCC on Linux is providing a symlink for "c++" as "g++". MinGW on
Windows is providing a copy of the executable, which gets ignored by Qt
Creator.

CMake is preferring "c++" instead of "g++" and Qt Creator will ignore
such a detected compiler at import time.

Change-Id: I3e19e1f1c29cad50cdc92c17a15f246188411597
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Cristian Adam
2022-08-25 12:19:28 +02:00
parent da446d0d15
commit 152c01bd86

View File

@@ -1980,10 +1980,15 @@ Toolchains MingwToolChainFactory::autoDetect(const ToolchainDetector &detector)
Toolchains MingwToolChainFactory::detectForImport(const ToolChainDescription &tcd) const
{
const QString fileName = tcd.compilerPath.completeBaseName();
if ((tcd.language == Constants::C_LANGUAGE_ID && (fileName.startsWith("gcc")
|| fileName.endsWith("gcc")))
|| (tcd.language == Constants::CXX_LANGUAGE_ID && (fileName.startsWith("g++")
|| fileName.endsWith("g++")))) {
const bool cCompiler = tcd.language == Constants::C_LANGUAGE_ID
&& (fileName.startsWith("gcc") || fileName.endsWith("gcc"));
const bool cxxCompiler = tcd.language == Constants::CXX_LANGUAGE_ID
&& ((fileName.startsWith("g++") || fileName.endsWith("g++"))
|| (fileName.startsWith("c++") || fileName.endsWith("c++")));
if (cCompiler || cxxCompiler) {
return autoDetectToolChain(tcd, [](const ToolChain *tc) {
return tc->targetAbi().osFlavor() == Abi::WindowsMSysFlavor;
});