CMake: Do not default to CodeBlocks extra generator

Now that CMake without server-mode or file-api are no longer
supported in Qt Creator, there is no more need to push for the
CodeBlocks extra generator which was required for the
"tealeaf" reader only.

Change-Id: Iec280d960b9f50ee6f9b954ecc532745a62213f5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Tobias Hunger
2020-03-05 10:34:35 +01:00
parent 4dcc480865
commit e5f4cfbeb8
2 changed files with 42 additions and 28 deletions

View File

@@ -466,7 +466,20 @@ private:
namespace { namespace {
struct GeneratorInfo { class GeneratorInfo
{
public:
GeneratorInfo() = default;
GeneratorInfo(const QString &generator_,
const QString &extraGenerator_ = QString(),
const QString &platform_ = QString(),
const QString &toolset_ = QString())
: generator(generator_)
, extraGenerator(extraGenerator_)
, platform(platform_)
, toolset(toolset_)
{}
QVariant toVariant() const { QVariant toVariant() const {
QVariantMap result; QVariantMap result;
result.insert(GENERATOR_KEY, generator); result.insert(GENERATOR_KEY, generator);
@@ -568,10 +581,12 @@ void CMakeGeneratorKitAspect::setToolset(Kit *k, const QString &toolset)
} }
void CMakeGeneratorKitAspect::set(Kit *k, void CMakeGeneratorKitAspect::set(Kit *k,
const QString &generator, const QString &extraGenerator, const QString &generator,
const QString &platform, const QString &toolset) const QString &extraGenerator,
const QString &platform,
const QString &toolset)
{ {
GeneratorInfo info = {generator, extraGenerator, platform, toolset}; GeneratorInfo info(generator, extraGenerator, platform, toolset);
setGeneratorInfo(k, info); setGeneratorInfo(k, info);
} }
@@ -605,12 +620,9 @@ QVariant CMakeGeneratorKitAspect::defaultValue(const Kit *k) const
if (!tool) if (!tool)
return QVariant(); return QVariant();
const QString extraGenerator = "CodeBlocks"; const QList<CMakeTool::Generator> known = tool->supportedGenerators();
auto it = std::find_if(known.constBegin(), known.constEnd(), [](const CMakeTool::Generator &g) {
QList<CMakeTool::Generator> known = tool->supportedGenerators(); return g.matches("Ninja");
auto it = std::find_if(known.constBegin(), known.constEnd(),
[extraGenerator](const CMakeTool::Generator &g) {
return g.matches("Ninja", extraGenerator);
}); });
if (it != known.constEnd()) { if (it != known.constEnd()) {
const bool hasNinja = [k]() { const bool hasNinja = [k]() {
@@ -626,29 +638,30 @@ QVariant CMakeGeneratorKitAspect::defaultValue(const Kit *k) const
}(); }();
if (hasNinja) if (hasNinja)
return GeneratorInfo({QString("Ninja"), extraGenerator, QString(), QString()}).toVariant(); return GeneratorInfo("Ninja").toVariant();
} }
if (Utils::HostOsInfo::isWindowsHost()) { if (Utils::HostOsInfo::isWindowsHost()) {
// *sigh* Windows with its zoo of incompatible stuff again... // *sigh* Windows with its zoo of incompatible stuff again...
ToolChain *tc = ToolChainKitAspect::cxxToolChain(k); ToolChain *tc = ToolChainKitAspect::cxxToolChain(k);
if (tc && tc->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID) { if (tc && tc->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID) {
it = std::find_if(known.constBegin(), known.constEnd(), it = std::find_if(known.constBegin(),
[extraGenerator](const CMakeTool::Generator &g) { known.constEnd(),
return g.matches("MinGW Makefiles", extraGenerator); [](const CMakeTool::Generator &g) {
return g.matches("MinGW Makefiles");
}); });
} else { } else {
it = std::find_if(known.constBegin(), known.constEnd(), it = std::find_if(known.constBegin(),
[extraGenerator](const CMakeTool::Generator &g) { known.constEnd(),
return g.matches("NMake Makefiles", extraGenerator) [](const CMakeTool::Generator &g) {
|| g.matches("NMake Makefiles JOM", extraGenerator); return g.matches("NMake Makefiles")
|| g.matches("NMake Makefiles JOM");
}); });
} }
} else { } else {
// Unix-oid OSes: // Unix-oid OSes:
it = std::find_if(known.constBegin(), known.constEnd(), it = std::find_if(known.constBegin(), known.constEnd(), [](const CMakeTool::Generator &g) {
[extraGenerator](const CMakeTool::Generator &g) { return g.matches("Unix Makefiles");
return g.matches("Unix Makefiles", extraGenerator);
}); });
} }
if (it == known.constEnd()) if (it == known.constEnd())
@@ -656,7 +669,7 @@ QVariant CMakeGeneratorKitAspect::defaultValue(const Kit *k) const
if (it == known.constEnd()) if (it == known.constEnd())
return QVariant(); return QVariant();
return GeneratorInfo({it->name, extraGenerator, QString(), QString()}).toVariant(); return GeneratorInfo(it->name).toVariant();
} }
Tasks CMakeGeneratorKitAspect::validate(const Kit *k) const Tasks CMakeGeneratorKitAspect::validate(const Kit *k) const
@@ -723,9 +736,10 @@ void CMakeGeneratorKitAspect::fix(Kit *k)
dv.fromVariant(defaultValue(k)); dv.fromVariant(defaultValue(k));
setGeneratorInfo(k, dv); setGeneratorInfo(k, dv);
} else { } else {
const GeneratorInfo dv = {info.generator, info.extraGenerator, const GeneratorInfo dv(info.generator,
info.extraGenerator,
it->supportsPlatform ? info.platform : QString(), it->supportsPlatform ? info.platform : QString(),
it->supportsToolset ? info.toolset : QString()}; it->supportsToolset ? info.toolset : QString());
setGeneratorInfo(k, dv); setGeneratorInfo(k, dv);
} }
} }

View File

@@ -73,7 +73,7 @@ public:
bool supportsPlatform = true; bool supportsPlatform = true;
bool supportsToolset = true; bool supportsToolset = true;
bool matches(const QString &n, const QString &ex) const; bool matches(const QString &n, const QString &ex = QString()) const;
}; };
using PathMapper = std::function<Utils::FilePath (const Utils::FilePath &)>; using PathMapper = std::function<Utils::FilePath (const Utils::FilePath &)>;