aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cmakeprojectmanager/cmaketool.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-09-28 12:24:06 +0200
committerTobias Hunger <tobias.hunger@qt.io>2016-09-30 07:27:14 +0000
commitb3b6cfb5ef563796eaa0718b97852a6abe9eef46 (patch)
tree85c876164f6f2cb99b833cd432b1aa17b107e8e5 /src/plugins/cmakeprojectmanager/cmaketool.cpp
parent4bce0d7c36fc4505dfa91dd90bbe000fa5118d6d (diff)
CMake: Improve generator selection in kits
Allow to select generator and extragenerator in a nicer way. Enable support for platforms and toolsets. Change-Id: I0c9aae635cdca0ec1db7f285e9cb2785172ed338 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmaketool.cpp')
-rw-r--r--src/plugins/cmakeprojectmanager/cmaketool.cpp93
1 files changed, 64 insertions, 29 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmaketool.cpp b/src/plugins/cmakeprojectmanager/cmaketool.cpp
index 306f96c02a2..642a368cfb4 100644
--- a/src/plugins/cmakeprojectmanager/cmaketool.cpp
+++ b/src/plugins/cmakeprojectmanager/cmaketool.cpp
@@ -45,6 +45,12 @@ const char CMAKE_INFORMATION_DISPLAYNAME[] = "DisplayName";
const char CMAKE_INFORMATION_AUTORUN[] = "AutoRun";
const char CMAKE_INFORMATION_AUTODETECTED[] = "AutoDetected";
+
+bool CMakeTool::Generator::matches(const QString &n, const QString &ex) const
+{
+ return n == name && (ex.isEmpty() || extraGenerators.contains(ex));
+}
+
///////////////////////////
// CMakeTool
///////////////////////////
@@ -153,37 +159,10 @@ bool CMakeTool::isAutoRun() const
return m_isAutoRun;
}
-QStringList CMakeTool::supportedGenerators() const
+QList<CMakeTool::Generator> CMakeTool::supportedGenerators() const
{
if (m_generators.isEmpty()) {
- Utils::SynchronousProcessResponse response = run("--help");
- if (response.result == Utils::SynchronousProcessResponse::Finished) {
- bool inGeneratorSection = false;
- const QStringList lines = response.stdOut().split('\n');
- foreach (const QString &line, lines) {
- if (line.isEmpty())
- continue;
- if (line == "Generators") {
- inGeneratorSection = true;
- continue;
- }
- if (!inGeneratorSection)
- continue;
-
- if (line.startsWith(" ") && line.at(3) != ' ') {
- int pos = line.indexOf('=');
- if (pos < 0)
- pos = line.length();
- if (pos >= 0) {
- --pos;
- while (pos > 2 && line.at(pos).isSpace())
- --pos;
- }
- if (pos > 2)
- m_generators.append(line.mid(2, pos - 1));
- }
- }
- }
+ fetchGeneratorsFromHelp();
}
return m_generators;
}
@@ -334,4 +313,60 @@ QStringList CMakeTool::parseVariableOutput(const QString &output)
return result;
}
+void CMakeTool::fetchGeneratorsFromHelp() const
+{
+ Utils::SynchronousProcessResponse response = run("--help");
+ if (response.result != Utils::SynchronousProcessResponse::Finished)
+ return;
+
+ bool inGeneratorSection = false;
+ QHash<QString, QStringList> generatorInfo;
+ const QStringList lines = response.stdOut().split('\n');
+ foreach (const QString &line, lines) {
+ if (line.isEmpty())
+ continue;
+ if (line == "Generators") {
+ inGeneratorSection = true;
+ continue;
+ }
+ if (!inGeneratorSection)
+ continue;
+
+ if (line.startsWith(" ") && line.at(3) != ' ') {
+ int pos = line.indexOf('=');
+ if (pos < 0)
+ pos = line.length();
+ if (pos >= 0) {
+ --pos;
+ while (pos > 2 && line.at(pos).isSpace())
+ --pos;
+ }
+ if (pos > 2) {
+ const QString fullName = line.mid(2, pos - 1);
+ const int dashPos = fullName.indexOf(" - ");
+ QString generator;
+ QString extra;
+ if (dashPos < 0) {
+ generator = fullName;
+ } else {
+ extra = fullName.mid(0, dashPos);
+ generator = fullName.mid(dashPos + 3);
+ }
+ QStringList value = generatorInfo.value(generator);
+ if (!extra.isEmpty())
+ value.append(extra);
+ generatorInfo.insert(generator, value);
+ }
+ }
+ }
+
+ // Populate genertor list:
+ for (auto it = generatorInfo.constBegin(); it != generatorInfo.constEnd(); ++it) {
+ Generator info;
+ info.name = it.key();
+ info.extraGenerators = it.value();
+ m_generators.append(info);
+ }
+}
+
} // namespace CMakeProjectManager