2012-09-06 22:38:25 +08:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-09-06 22:38:25 +08:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-09-06 22:38:25 +08:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2012-09-06 22:38:25 +08:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2014-03-12 08:36:36 +01:00
|
|
|
#include "cmaketool.h"
|
2015-02-24 21:57:00 +01:00
|
|
|
#include "cmaketoolmanager.h"
|
2012-09-06 22:38:25 +08:00
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
#include <utils/environment.h>
|
2015-02-04 17:54:46 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2012-09-06 22:38:25 +08:00
|
|
|
#include <QFileInfo>
|
2016-01-22 13:50:58 +01:00
|
|
|
#include <QProcess>
|
|
|
|
|
#include <QSet>
|
2012-09-06 22:38:25 +08:00
|
|
|
#include <QTextDocument>
|
2015-02-04 17:54:46 +01:00
|
|
|
#include <QUuid>
|
2016-01-22 13:50:58 +01:00
|
|
|
#include <QVariantMap>
|
2015-02-04 17:54:46 +01:00
|
|
|
|
2016-02-12 12:30:55 +01:00
|
|
|
namespace CMakeProjectManager {
|
2012-09-06 22:38:25 +08:00
|
|
|
|
2015-02-04 17:54:46 +01:00
|
|
|
const char CMAKE_INFORMATION_ID[] = "Id";
|
|
|
|
|
const char CMAKE_INFORMATION_COMMAND[] = "Binary";
|
|
|
|
|
const char CMAKE_INFORMATION_DISPLAYNAME[] = "DisplayName";
|
2016-06-27 13:09:14 +02:00
|
|
|
const char CMAKE_INFORMATION_AUTORUN[] = "AutoRun";
|
2015-02-04 17:54:46 +01:00
|
|
|
const char CMAKE_INFORMATION_AUTODETECTED[] = "AutoDetected";
|
2012-09-06 22:38:25 +08:00
|
|
|
|
2016-09-28 12:24:06 +02:00
|
|
|
|
|
|
|
|
bool CMakeTool::Generator::matches(const QString &n, const QString &ex) const
|
|
|
|
|
{
|
|
|
|
|
return n == name && (ex.isEmpty() || extraGenerators.contains(ex));
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-06 22:38:25 +08:00
|
|
|
///////////////////////////
|
2014-03-12 08:36:36 +01:00
|
|
|
// CMakeTool
|
2012-09-06 22:38:25 +08:00
|
|
|
///////////////////////////
|
2016-01-07 15:22:53 +01:00
|
|
|
CMakeTool::CMakeTool(Detection d, const Core::Id &id) :
|
2016-01-22 13:50:58 +01:00
|
|
|
m_id(id), m_isAutoDetected(d == AutoDetection)
|
2012-09-06 22:38:25 +08:00
|
|
|
{
|
2016-01-22 13:50:58 +01:00
|
|
|
QTC_ASSERT(m_id.isValid(), m_id = Core::Id::fromString(QUuid::createUuid().toString()));
|
2015-02-04 17:54:46 +01:00
|
|
|
}
|
2012-09-06 22:38:25 +08:00
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
CMakeTool::CMakeTool(const QVariantMap &map, bool fromSdk) : m_isAutoDetected(fromSdk)
|
2015-02-04 17:54:46 +01:00
|
|
|
{
|
2016-09-26 16:29:58 +02:00
|
|
|
m_id = Core::Id::fromSetting(map.value(CMAKE_INFORMATION_ID));
|
|
|
|
|
m_displayName = map.value(CMAKE_INFORMATION_DISPLAYNAME).toString();
|
|
|
|
|
m_isAutoRun = map.value(CMAKE_INFORMATION_AUTORUN, true).toBool();
|
2015-02-04 17:54:46 +01:00
|
|
|
|
|
|
|
|
//loading a CMakeTool from SDK is always autodetection
|
|
|
|
|
if (!fromSdk)
|
2016-09-26 16:29:58 +02:00
|
|
|
m_isAutoDetected = map.value(CMAKE_INFORMATION_AUTODETECTED, false).toBool();
|
2015-02-04 17:54:46 +01:00
|
|
|
|
2016-09-26 16:29:58 +02:00
|
|
|
setCMakeExecutable(Utils::FileName::fromString(map.value(CMAKE_INFORMATION_COMMAND).toString()));
|
2012-09-06 22:38:25 +08:00
|
|
|
}
|
|
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
Core::Id CMakeTool::createId()
|
2012-09-06 22:38:25 +08:00
|
|
|
{
|
2016-01-22 13:50:58 +01:00
|
|
|
return Core::Id::fromString(QUuid::createUuid().toString());
|
2012-09-06 22:38:25 +08:00
|
|
|
}
|
|
|
|
|
|
2015-02-04 17:54:46 +01:00
|
|
|
void CMakeTool::setCMakeExecutable(const Utils::FileName &executable)
|
2012-09-06 22:38:25 +08:00
|
|
|
{
|
2016-01-22 13:50:58 +01:00
|
|
|
if (m_executable == executable)
|
|
|
|
|
return;
|
2012-09-06 22:38:25 +08:00
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
m_didRun = false;
|
|
|
|
|
m_didAttemptToRun = false;
|
2015-02-24 21:57:00 +01:00
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
m_executable = executable;
|
2015-02-24 21:57:00 +01:00
|
|
|
CMakeToolManager::notifyAboutUpdate(this);
|
2012-09-06 22:38:25 +08:00
|
|
|
}
|
|
|
|
|
|
2016-06-27 13:09:14 +02:00
|
|
|
void CMakeTool::setAutorun(bool autoRun)
|
|
|
|
|
{
|
|
|
|
|
if (m_isAutoRun == autoRun)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_isAutoRun = autoRun;
|
|
|
|
|
CMakeToolManager::notifyAboutUpdate(this);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
bool CMakeTool::isValid() const
|
2012-09-06 22:38:25 +08:00
|
|
|
{
|
2016-01-22 13:50:58 +01:00
|
|
|
if (!m_id.isValid())
|
|
|
|
|
return false;
|
2012-09-06 22:38:25 +08:00
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
if (!m_didAttemptToRun)
|
|
|
|
|
supportedGenerators();
|
2012-09-06 22:38:25 +08:00
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
return m_didRun;
|
2012-09-06 22:38:25 +08:00
|
|
|
}
|
|
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
Utils::SynchronousProcessResponse CMakeTool::run(const QString &arg) const
|
2012-09-06 22:38:25 +08:00
|
|
|
{
|
2016-01-22 13:50:58 +01:00
|
|
|
if (m_didAttemptToRun && !m_didRun) {
|
|
|
|
|
Utils::SynchronousProcessResponse response;
|
|
|
|
|
response.result = Utils::SynchronousProcessResponse::StartFailed;
|
|
|
|
|
return response;
|
2015-02-04 17:54:46 +01:00
|
|
|
}
|
2012-09-06 22:38:25 +08:00
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
Utils::SynchronousProcess cmake;
|
|
|
|
|
cmake.setTimeoutS(1);
|
|
|
|
|
cmake.setFlags(Utils::SynchronousProcess::UnixTerminalDisabled);
|
|
|
|
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
2016-04-07 13:06:01 +02:00
|
|
|
Utils::Environment::setupEnglishOutput(&env);
|
2016-01-22 13:50:58 +01:00
|
|
|
cmake.setProcessEnvironment(env.toProcessEnvironment());
|
|
|
|
|
cmake.setTimeOutMessageBoxEnabled(false);
|
|
|
|
|
|
2016-05-26 12:12:01 +02:00
|
|
|
Utils::SynchronousProcessResponse response = cmake.runBlocking(m_executable.toString(), QStringList() << arg);
|
2016-01-22 13:50:58 +01:00
|
|
|
m_didAttemptToRun = true;
|
|
|
|
|
m_didRun = (response.result == Utils::SynchronousProcessResponse::Finished);
|
|
|
|
|
return response;
|
2015-02-04 17:54:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap CMakeTool::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap data;
|
2016-09-26 16:29:58 +02:00
|
|
|
data.insert(CMAKE_INFORMATION_DISPLAYNAME, m_displayName);
|
|
|
|
|
data.insert(CMAKE_INFORMATION_ID, m_id.toSetting());
|
|
|
|
|
data.insert(CMAKE_INFORMATION_COMMAND, m_executable.toString());
|
|
|
|
|
data.insert(CMAKE_INFORMATION_AUTORUN, m_isAutoRun);
|
|
|
|
|
data.insert(CMAKE_INFORMATION_AUTODETECTED, m_isAutoDetected);
|
2015-02-04 17:54:46 +01:00
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::FileName CMakeTool::cmakeExecutable() const
|
2012-09-06 22:38:25 +08:00
|
|
|
{
|
2016-09-14 12:56:32 +02:00
|
|
|
if (Utils::HostOsInfo::isMacHost() && m_executable.endsWith(".app")) {
|
|
|
|
|
Utils::FileName toTest = m_executable;
|
|
|
|
|
toTest = toTest.appendPath("Contents/bin/cmake");
|
|
|
|
|
if (toTest.exists())
|
|
|
|
|
return toTest;
|
|
|
|
|
}
|
2012-09-06 22:38:25 +08:00
|
|
|
return m_executable;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-27 13:09:14 +02:00
|
|
|
bool CMakeTool::isAutoRun() const
|
|
|
|
|
{
|
|
|
|
|
return m_isAutoRun;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-28 12:24:06 +02:00
|
|
|
QList<CMakeTool::Generator> CMakeTool::supportedGenerators() const
|
2012-09-06 22:38:25 +08:00
|
|
|
{
|
2016-01-22 13:50:58 +01:00
|
|
|
if (m_generators.isEmpty()) {
|
2016-09-28 12:24:06 +02:00
|
|
|
fetchGeneratorsFromHelp();
|
2012-09-06 22:38:25 +08:00
|
|
|
}
|
2016-01-22 13:50:58 +01:00
|
|
|
return m_generators;
|
2012-09-06 22:38:25 +08:00
|
|
|
}
|
|
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
TextEditor::Keywords CMakeTool::keywords()
|
2012-09-06 22:38:25 +08:00
|
|
|
{
|
2016-01-22 13:50:58 +01:00
|
|
|
if (m_functions.isEmpty()) {
|
|
|
|
|
Utils::SynchronousProcessResponse response;
|
2016-09-26 16:29:58 +02:00
|
|
|
response = run("--help-command-list");
|
2016-01-22 13:50:58 +01:00
|
|
|
if (response.result == Utils::SynchronousProcessResponse::Finished)
|
2016-09-26 16:29:58 +02:00
|
|
|
m_functions = response.stdOut().split('\n');
|
2016-01-22 13:50:58 +01:00
|
|
|
|
2016-09-26 16:29:58 +02:00
|
|
|
response = run("--help-commands");
|
2016-01-22 13:50:58 +01:00
|
|
|
if (response.result == Utils::SynchronousProcessResponse::Finished)
|
2016-07-05 12:00:59 +02:00
|
|
|
parseFunctionDetailsOutput(response.stdOut());
|
2016-01-22 13:50:58 +01:00
|
|
|
|
2016-09-26 16:29:58 +02:00
|
|
|
response = run("--help-property-list");
|
2016-01-22 13:50:58 +01:00
|
|
|
if (response.result == Utils::SynchronousProcessResponse::Finished)
|
2016-07-05 12:00:59 +02:00
|
|
|
m_variables = parseVariableOutput(response.stdOut());
|
2016-01-22 13:50:58 +01:00
|
|
|
|
2016-09-26 16:29:58 +02:00
|
|
|
response = run("--help-variable-list");
|
2016-01-22 13:50:58 +01:00
|
|
|
if (response.result == Utils::SynchronousProcessResponse::Finished) {
|
2016-07-05 12:00:59 +02:00
|
|
|
m_variables.append(parseVariableOutput(response.stdOut()));
|
2016-01-22 13:50:58 +01:00
|
|
|
m_variables = Utils::filteredUnique(m_variables);
|
|
|
|
|
Utils::sort(m_variables);
|
|
|
|
|
}
|
2012-09-06 22:38:25 +08:00
|
|
|
}
|
2016-01-22 13:50:58 +01:00
|
|
|
|
|
|
|
|
return TextEditor::Keywords(m_variables, m_functions, m_functionArgs);
|
2012-09-06 22:38:25 +08:00
|
|
|
}
|
|
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
bool CMakeTool::isAutoDetected() const
|
2012-09-06 22:38:25 +08:00
|
|
|
{
|
2016-01-22 13:50:58 +01:00
|
|
|
return m_isAutoDetected;
|
2012-09-06 22:38:25 +08:00
|
|
|
}
|
|
|
|
|
|
2015-02-04 17:54:46 +01:00
|
|
|
QString CMakeTool::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return m_displayName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeTool::setDisplayName(const QString &displayName)
|
|
|
|
|
{
|
|
|
|
|
m_displayName = displayName;
|
2015-02-24 21:57:00 +01:00
|
|
|
CMakeToolManager::notifyAboutUpdate(this);
|
2015-02-04 17:54:46 +01:00
|
|
|
}
|
|
|
|
|
|
2015-03-10 15:47:09 +01:00
|
|
|
void CMakeTool::setPathMapper(const CMakeTool::PathMapper &pathMapper)
|
|
|
|
|
{
|
|
|
|
|
m_pathMapper = pathMapper;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 12:30:55 +01:00
|
|
|
QString CMakeTool::mapAllPaths(const ProjectExplorer::Kit *kit, const QString &in) const
|
2015-03-10 15:47:09 +01:00
|
|
|
{
|
|
|
|
|
if (m_pathMapper)
|
|
|
|
|
return m_pathMapper(kit, in);
|
|
|
|
|
return in;
|
|
|
|
|
}
|
2015-02-04 17:54:46 +01:00
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
static QStringList parseDefinition(const QString &definition)
|
2012-09-06 22:38:25 +08:00
|
|
|
{
|
2016-01-22 13:50:58 +01:00
|
|
|
QStringList result;
|
|
|
|
|
QString word;
|
|
|
|
|
bool ignoreWord = false;
|
|
|
|
|
QVector<QChar> braceStack;
|
|
|
|
|
|
|
|
|
|
foreach (const QChar &c, definition) {
|
2016-09-26 16:29:58 +02:00
|
|
|
if (c == '[' || c == '<' || c == '(') {
|
2016-01-22 13:50:58 +01:00
|
|
|
braceStack.append(c);
|
|
|
|
|
ignoreWord = false;
|
2016-09-26 16:29:58 +02:00
|
|
|
} else if (c == ']' || c == '>' || c == ')') {
|
|
|
|
|
if (braceStack.isEmpty() || braceStack.takeLast() == '<')
|
2016-01-22 13:50:58 +01:00
|
|
|
ignoreWord = true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-26 16:29:58 +02:00
|
|
|
if (c == ' ' || c == '[' || c == '<' || c == '('
|
|
|
|
|
|| c == ']' || c == '>' || c == ')') {
|
2016-01-22 13:50:58 +01:00
|
|
|
if (!ignoreWord && !word.isEmpty()) {
|
2016-09-26 16:29:58 +02:00
|
|
|
if (result.isEmpty() || Utils::allOf(word, [](const QChar &c) { return c.isUpper() || c == '_'; }))
|
2016-01-22 13:50:58 +01:00
|
|
|
result.append(word);
|
2012-09-06 22:38:25 +08:00
|
|
|
}
|
2016-01-22 13:50:58 +01:00
|
|
|
word.clear();
|
|
|
|
|
ignoreWord = false;
|
|
|
|
|
} else {
|
|
|
|
|
word.append(c);
|
2012-09-06 22:38:25 +08:00
|
|
|
}
|
|
|
|
|
}
|
2016-01-22 13:50:58 +01:00
|
|
|
return result;
|
2013-02-16 22:37:31 +08:00
|
|
|
}
|
|
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
void CMakeTool::parseFunctionDetailsOutput(const QString &output)
|
2013-02-16 22:37:31 +08:00
|
|
|
{
|
2016-01-22 13:50:58 +01:00
|
|
|
QSet<QString> functionSet;
|
|
|
|
|
functionSet.fromList(m_functions);
|
|
|
|
|
|
|
|
|
|
bool expectDefinition = false;
|
|
|
|
|
QString currentDefinition;
|
|
|
|
|
|
2016-09-26 16:29:58 +02:00
|
|
|
const QStringList lines = output.split('\n');
|
2016-01-22 13:50:58 +01:00
|
|
|
for (int i = 0; i < lines.count(); ++i) {
|
|
|
|
|
const QString line = lines.at(i);
|
|
|
|
|
|
2016-09-26 16:29:58 +02:00
|
|
|
if (line == "::") {
|
2016-01-22 13:50:58 +01:00
|
|
|
expectDefinition = true;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (expectDefinition) {
|
2016-09-26 16:29:58 +02:00
|
|
|
if (!line.startsWith(' ') && !line.isEmpty()) {
|
2016-01-22 13:50:58 +01:00
|
|
|
expectDefinition = false;
|
|
|
|
|
QStringList words = parseDefinition(currentDefinition);
|
|
|
|
|
if (!words.isEmpty()) {
|
|
|
|
|
const QString command = words.takeFirst();
|
|
|
|
|
if (functionSet.contains(command)) {
|
|
|
|
|
QStringList tmp = words + m_functionArgs[command];
|
|
|
|
|
Utils::sort(tmp);
|
|
|
|
|
m_functionArgs[command] = Utils::filteredUnique(tmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!words.isEmpty() && functionSet.contains(words.at(0)))
|
|
|
|
|
m_functionArgs[words.at(0)];
|
|
|
|
|
currentDefinition.clear();
|
|
|
|
|
} else {
|
2016-09-26 16:29:58 +02:00
|
|
|
currentDefinition.append(line.trimmed() + ' ');
|
2013-02-16 22:37:31 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
QStringList CMakeTool::parseVariableOutput(const QString &output)
|
2013-02-16 22:37:31 +08:00
|
|
|
{
|
2016-09-26 16:29:58 +02:00
|
|
|
const QStringList variableList = output.split('\n');
|
2016-01-22 13:50:58 +01:00
|
|
|
QStringList result;
|
|
|
|
|
foreach (const QString &v, variableList) {
|
2016-09-14 12:28:14 +02:00
|
|
|
if (v.startsWith("CMAKE_COMPILER_IS_GNU<LANG>")) { // This key takes a compiler name :-/
|
|
|
|
|
result << "CMAKE_COMPILER_IS_GNUCC" << "CMAKE_COMPILER_IS_GNUCXX";
|
|
|
|
|
} else if (v.contains("<CONFIG>")) {
|
2016-09-14 12:26:13 +02:00
|
|
|
const QString tmp = QString(v).replace("<CONFIG>", "%1");
|
|
|
|
|
result << tmp.arg("DEBUG") << tmp.arg("RELEASE")
|
|
|
|
|
<< tmp.arg("MINSIZEREL") << tmp.arg("RELWITHDEBINFO");
|
|
|
|
|
} else if (v.contains("<LANG>")) {
|
|
|
|
|
const QString tmp = QString(v).replace("<LANG>", "%1");
|
|
|
|
|
result << tmp.arg("C") << tmp.arg("CXX");
|
2016-09-26 16:29:58 +02:00
|
|
|
} else if (!v.contains('<') && !v.contains('[')) {
|
2016-01-22 13:50:58 +01:00
|
|
|
result << v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
2012-09-06 22:38:25 +08:00
|
|
|
}
|
2016-02-12 12:30:55 +01:00
|
|
|
|
2016-09-28 12:24:06 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 12:30:55 +01:00
|
|
|
} // namespace CMakeProjectManager
|