CMake: Improve default generator setup on Windows

If ninja is not an option on windows: Pick mingw makefile generator
for kits with a Mingw toolchain on windows and the nmake makefile
generator for other toolchains on windows.

On Unix fall back to the Unix makefiles generator if ninja is
unavailable as we did before.

Change-Id: I8005615e6f725d38c16c1b9026d3f7548e7b42db
Task-number: QTCREATORBUG-15756
Reviewed-by: Robert Loehning <robert.loehning@theqtcompany.com>
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2016-03-02 10:18:06 +01:00
parent 0f8e3f2000
commit 3cffacdd0f

View File

@@ -176,12 +176,25 @@ QVariant CMakeGeneratorKitInformation::defaultValue(const Kit *k) const
if (ninjaExec.isEmpty())
it = known.constEnd(); // Ignore ninja generator without ninja exectuable
}
if (it == known.constEnd())
it = std::find_if(known.constBegin(), known.constEnd(),
[](const QString &s) { return s == QLatin1String("CodeBlocks - Unix Makefiles"); });
if (it == known.constEnd())
it = std::find_if(known.constBegin(), known.constEnd(),
[](const QString &s) { return s == QLatin1String("CodeBlocks - NMake Makefiles"); });
if (Utils::HostOsInfo::isWindowsHost()) {
// *sigh* Windows with its zoo of incompatible stuff again...
ToolChain *tc = ToolChainKitInformation::toolChain(k);
if (tc && tc->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID) {
if (it == known.constEnd())
it = std::find_if(known.constBegin(), known.constEnd(),
[](const QString &s) { return s == QLatin1String("CodeBlocks - MinGW Makefiles"); });
} else {
if (it == known.constEnd())
it = std::find_if(known.constBegin(), known.constEnd(),
[](const QString &s) { return s == QLatin1String("CodeBlocks - NMake Makefiles"); });
}
} else {
// Unix-oid OSes:
if (it == known.constEnd())
it = std::find_if(known.constBegin(), known.constEnd(),
[](const QString &s) { return s == QLatin1String("CodeBlocks - Unix Makefiles"); });
}
if (it == known.constEnd())
it = known.constBegin(); // Fallback to the first generator...
if (it != known.constEnd())