From 152c01bd862c459860d7aa2f39f6b13574b0ccd9 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 25 Aug 2022 12:19:28 +0200 Subject: [PATCH] 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 --- src/plugins/projectexplorer/gcctoolchain.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index 49573462fb2..46f06f5dbc7 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -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; });