2015-02-04 17:54:46 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 Canonical Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-02-04 17:54:46 +01: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.
|
2015-02-04 17:54:46 +01: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.
|
2015-02-04 17:54:46 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "cmaketoolmanager.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2018-06-29 13:39:26 +02:00
|
|
|
|
|
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
#include <utils/environment.h>
|
2015-02-04 17:54:46 +01:00
|
|
|
#include <utils/persistentsettings.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
using namespace Utils;
|
2015-03-04 13:32:31 +01:00
|
|
|
using namespace ProjectExplorer;
|
2015-02-04 17:54:46 +01:00
|
|
|
|
|
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
|
2018-06-29 13:20:59 +02:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// CMakeToolManagerPrivate:
|
|
|
|
|
// --------------------------------------------------------------------
|
2015-02-04 17:54:46 +01:00
|
|
|
|
|
|
|
|
class CMakeToolManagerPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Id m_defaultCMake;
|
|
|
|
|
QList<CMakeTool *> m_cmakeTools;
|
2016-01-26 15:22:03 +01:00
|
|
|
PersistentSettingsWriter *m_writer = nullptr;
|
2015-02-04 17:54:46 +01:00
|
|
|
};
|
2016-01-26 15:22:03 +01:00
|
|
|
static CMakeToolManagerPrivate *d = nullptr;
|
2015-02-04 17:54:46 +01:00
|
|
|
|
2018-06-29 13:20:59 +02:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// Helper:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
const char CMAKETOOL_COUNT_KEY[] = "CMakeTools.Count";
|
|
|
|
|
const char CMAKETOOL_DEFAULT_KEY[] = "CMakeTools.Default";
|
|
|
|
|
const char CMAKETOOL_DATA_KEY[] = "CMakeTools.";
|
|
|
|
|
const char CMAKETOOL_FILE_VERSION_KEY[] = "Version";
|
|
|
|
|
const char CMAKETOOL_FILENAME[] = "/cmaketools.xml";
|
|
|
|
|
|
2015-02-04 17:54:46 +01:00
|
|
|
static FileName userSettingsFileName()
|
|
|
|
|
{
|
2018-01-10 17:29:27 +01:00
|
|
|
return FileName::fromString(ICore::userResourcePath() + CMAKETOOL_FILENAME);
|
2015-02-04 17:54:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QList<CMakeTool *> readCMakeTools(const FileName &fileName, Core::Id *defaultId, bool fromSDK)
|
|
|
|
|
{
|
|
|
|
|
PersistentSettingsReader reader;
|
|
|
|
|
if (!reader.load(fileName))
|
2018-06-29 13:20:42 +02:00
|
|
|
return {};
|
2015-02-04 17:54:46 +01:00
|
|
|
|
|
|
|
|
QVariantMap data = reader.restoreValues();
|
|
|
|
|
|
|
|
|
|
// Check version
|
|
|
|
|
int version = data.value(QLatin1String(CMAKETOOL_FILE_VERSION_KEY), 0).toInt();
|
|
|
|
|
if (version < 1)
|
2018-06-29 13:20:42 +02:00
|
|
|
return {};
|
2015-02-04 17:54:46 +01:00
|
|
|
|
|
|
|
|
QList<CMakeTool *> loaded;
|
|
|
|
|
|
|
|
|
|
int count = data.value(QLatin1String(CMAKETOOL_COUNT_KEY), 0).toInt();
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
|
const QString key = QString::fromLatin1(CMAKETOOL_DATA_KEY) + QString::number(i);
|
|
|
|
|
if (!data.contains(key))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
const QVariantMap dbMap = data.value(key).toMap();
|
2016-01-07 15:22:53 +01:00
|
|
|
auto item = new CMakeTool(dbMap,fromSDK);
|
2015-02-04 17:54:46 +01:00
|
|
|
if (item->isAutoDetected()) {
|
|
|
|
|
if (!item->cmakeExecutable().toFileInfo().isExecutable()) {
|
|
|
|
|
qWarning() << QString::fromLatin1("CMakeTool \"%1\" (%2) read from \"%3\" dropped since the command is not executable.")
|
|
|
|
|
.arg(item->cmakeExecutable().toUserOutput(), item->id().toString(), fileName.toUserOutput());
|
|
|
|
|
delete item;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loaded.append(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*defaultId = Id::fromSetting(data.value(QLatin1String(CMAKETOOL_DEFAULT_KEY), defaultId->toSetting()));
|
|
|
|
|
|
|
|
|
|
return loaded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QList<CMakeTool *> autoDetectCMakeTools()
|
|
|
|
|
{
|
2015-07-15 14:21:45 +02:00
|
|
|
Utils::Environment env = Environment::systemEnvironment();
|
|
|
|
|
|
2017-09-20 12:53:30 +02:00
|
|
|
Utils::FileNameList path = env.path();
|
|
|
|
|
path = Utils::filteredUnique(path);
|
2015-07-15 14:21:45 +02:00
|
|
|
|
2017-06-09 20:47:47 -07:00
|
|
|
if (HostOsInfo::isWindowsHost()) {
|
2017-09-14 09:46:07 +03:00
|
|
|
const QString progFiles = QLatin1String(qgetenv("ProgramFiles"));
|
2017-09-20 12:53:30 +02:00
|
|
|
path.append(Utils::FileName::fromString(progFiles + "/CMake"));
|
|
|
|
|
path.append(Utils::FileName::fromString(progFiles + "/CMake/bin"));
|
2017-09-14 09:46:07 +03:00
|
|
|
const QString progFilesX86 = QLatin1String(qgetenv("ProgramFiles(x86)"));
|
|
|
|
|
if (!progFilesX86.isEmpty()) {
|
2017-09-20 12:53:30 +02:00
|
|
|
path.append(Utils::FileName::fromString(progFilesX86 + "/CMake"));
|
|
|
|
|
path.append(Utils::FileName::fromString(progFilesX86 + "/CMake/bin"));
|
2017-09-14 09:46:07 +03:00
|
|
|
}
|
2017-06-09 20:47:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (HostOsInfo::isMacHost()) {
|
2017-09-20 12:53:30 +02:00
|
|
|
path.append(Utils::FileName::fromString("/Applications/CMake.app/Contents/bin"));
|
|
|
|
|
path.append(Utils::FileName::fromString("/usr/local/bin"));
|
|
|
|
|
path.append(Utils::FileName::fromString("/opt/local/bin"));
|
2017-06-09 20:47:47 -07:00
|
|
|
}
|
|
|
|
|
|
2017-09-20 12:53:30 +02:00
|
|
|
const QStringList execs = env.appendExeExtensions(QLatin1String("cmake"));
|
2015-07-15 14:21:45 +02:00
|
|
|
|
2017-09-20 12:53:30 +02:00
|
|
|
FileNameList suspects;
|
|
|
|
|
foreach (const Utils::FileName &base, path) {
|
2015-07-15 14:21:45 +02:00
|
|
|
if (base.isEmpty())
|
|
|
|
|
continue;
|
|
|
|
|
|
2017-09-20 12:53:30 +02:00
|
|
|
QFileInfo fi;
|
|
|
|
|
for (const QString &exec : execs) {
|
2018-06-29 13:39:26 +02:00
|
|
|
fi.setFile(QDir(base.toString()), exec);
|
2015-07-15 14:21:45 +02:00
|
|
|
if (fi.exists() && fi.isFile() && fi.isExecutable())
|
|
|
|
|
suspects << FileName::fromString(fi.absoluteFilePath());
|
|
|
|
|
}
|
2015-02-04 17:54:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<CMakeTool *> found;
|
|
|
|
|
foreach (const FileName &command, suspects) {
|
2016-01-22 13:50:58 +01:00
|
|
|
auto item = new CMakeTool(CMakeTool::AutoDetection, CMakeTool::createId());
|
2015-02-04 17:54:46 +01:00
|
|
|
item->setCMakeExecutable(command);
|
|
|
|
|
item->setDisplayName(CMakeToolManager::tr("System CMake at %1").arg(command.toUserOutput()));
|
|
|
|
|
|
|
|
|
|
found.append(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-29 13:29:43 +02:00
|
|
|
static QList<CMakeTool *> mergeTools(QList<CMakeTool *> &sdkTools,
|
|
|
|
|
QList<CMakeTool *> &userTools,
|
|
|
|
|
QList<CMakeTool *> &autoDetectedTools)
|
|
|
|
|
{
|
|
|
|
|
QList<CMakeTool *> result;
|
|
|
|
|
for (int i = userTools.size() - 1; i >= 0; i--) {
|
|
|
|
|
CMakeTool *currTool = userTools.takeAt(i);
|
|
|
|
|
if (CMakeTool *sdk = Utils::findOrDefault(sdkTools, Utils::equal(&CMakeTool::id, currTool->id()))) {
|
|
|
|
|
delete currTool;
|
|
|
|
|
result.append(sdk);
|
|
|
|
|
} else {
|
|
|
|
|
//if the current tool is marked as autodetected and NOT in the autodetected list,
|
|
|
|
|
//it is a leftover SDK provided tool. The user will not be able to edit it,
|
|
|
|
|
//so we automatically drop it
|
|
|
|
|
if (currTool->isAutoDetected()) {
|
|
|
|
|
if (!Utils::anyOf(autoDetectedTools,
|
|
|
|
|
Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable()))) {
|
|
|
|
|
|
|
|
|
|
qWarning() << QString::fromLatin1("Previously SDK provided CMakeTool \"%1\" (%2) dropped.")
|
|
|
|
|
.arg(currTool->cmakeExecutable().toUserOutput(), currTool->id().toString());
|
|
|
|
|
|
|
|
|
|
delete currTool;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result.append(currTool);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//filter out the tools that are already known
|
|
|
|
|
while (autoDetectedTools.size()) {
|
|
|
|
|
CMakeTool *currTool = autoDetectedTools.takeFirst();
|
|
|
|
|
if (Utils::anyOf(result,
|
|
|
|
|
Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable())))
|
|
|
|
|
delete currTool;
|
|
|
|
|
else
|
|
|
|
|
result.append(currTool);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-29 13:20:59 +02:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// CMakeToolManager:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2016-01-26 15:22:03 +01:00
|
|
|
CMakeToolManager *CMakeToolManager::m_instance = nullptr;
|
2015-02-24 21:57:00 +01:00
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
CMakeToolManager::CMakeToolManager(QObject *parent) : QObject(parent)
|
2015-02-04 17:54:46 +01:00
|
|
|
{
|
2015-02-24 21:57:00 +01:00
|
|
|
QTC_ASSERT(!m_instance, return);
|
|
|
|
|
m_instance = this;
|
|
|
|
|
|
2015-02-04 17:54:46 +01:00
|
|
|
d = new CMakeToolManagerPrivate;
|
|
|
|
|
d->m_writer = new PersistentSettingsWriter(userSettingsFileName(), QStringLiteral("QtCreatorCMakeTools"));
|
|
|
|
|
connect(ICore::instance(), &ICore::saveSettingsRequested,
|
|
|
|
|
this, &CMakeToolManager::saveCMakeTools);
|
2015-02-24 21:57:00 +01:00
|
|
|
|
|
|
|
|
connect(this, &CMakeToolManager::cmakeAdded, this, &CMakeToolManager::cmakeToolsChanged);
|
|
|
|
|
connect(this, &CMakeToolManager::cmakeRemoved, this, &CMakeToolManager::cmakeToolsChanged);
|
|
|
|
|
connect(this, &CMakeToolManager::cmakeUpdated, this, &CMakeToolManager::cmakeToolsChanged);
|
2015-02-04 17:54:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMakeToolManager::~CMakeToolManager()
|
|
|
|
|
{
|
|
|
|
|
delete d->m_writer;
|
2015-07-14 12:26:49 +02:00
|
|
|
qDeleteAll(d->m_cmakeTools);
|
2015-02-04 17:54:46 +01:00
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-24 21:57:00 +01:00
|
|
|
CMakeToolManager *CMakeToolManager::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-04 17:54:46 +01:00
|
|
|
QList<CMakeTool *> CMakeToolManager::cmakeTools()
|
|
|
|
|
{
|
|
|
|
|
return d->m_cmakeTools;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Id CMakeToolManager::registerOrFindCMakeTool(const FileName &command)
|
|
|
|
|
{
|
|
|
|
|
CMakeTool *cmake = findByCommand(command);
|
|
|
|
|
if (cmake)
|
|
|
|
|
return cmake->id();
|
|
|
|
|
|
2016-01-22 13:50:58 +01:00
|
|
|
cmake = new CMakeTool(CMakeTool::ManualDetection, CMakeTool::createId());
|
2015-02-04 17:54:46 +01:00
|
|
|
cmake->setCMakeExecutable(command);
|
|
|
|
|
cmake->setDisplayName(tr("CMake at %1").arg(command.toUserOutput()));
|
|
|
|
|
|
2015-02-24 21:57:00 +01:00
|
|
|
addCMakeTool(cmake);
|
2015-02-04 17:54:46 +01:00
|
|
|
return cmake->id();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CMakeToolManager::registerCMakeTool(CMakeTool *tool)
|
|
|
|
|
{
|
|
|
|
|
if (!tool || d->m_cmakeTools.contains(tool))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
QTC_ASSERT(tool->id().isValid(),return false);
|
|
|
|
|
|
|
|
|
|
//make sure the same id was not used before
|
|
|
|
|
foreach (CMakeTool *current, d->m_cmakeTools) {
|
|
|
|
|
if (tool->id() == current->id())
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addCMakeTool(tool);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeToolManager::deregisterCMakeTool(const Id &id)
|
|
|
|
|
{
|
|
|
|
|
int idx = Utils::indexOf(d->m_cmakeTools, Utils::equal(&CMakeTool::id, id));
|
|
|
|
|
if (idx >= 0) {
|
|
|
|
|
CMakeTool *toRemove = d->m_cmakeTools.takeAt(idx);
|
|
|
|
|
if (toRemove->id() == d->m_defaultCMake) {
|
|
|
|
|
if (d->m_cmakeTools.isEmpty())
|
|
|
|
|
d->m_defaultCMake = Id();
|
|
|
|
|
else
|
|
|
|
|
d->m_defaultCMake = d->m_cmakeTools.first()->id();
|
2015-02-24 21:57:00 +01:00
|
|
|
|
|
|
|
|
emit m_instance->defaultCMakeChanged();
|
2015-02-04 17:54:46 +01:00
|
|
|
}
|
2015-02-24 21:57:00 +01:00
|
|
|
|
|
|
|
|
emit m_instance->cmakeRemoved(id);
|
2015-02-04 17:54:46 +01:00
|
|
|
delete toRemove;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMakeTool *CMakeToolManager::defaultCMakeTool()
|
|
|
|
|
{
|
|
|
|
|
CMakeTool *tool = findById(d->m_defaultCMake);
|
|
|
|
|
if (!tool) {
|
|
|
|
|
//if the id is not valid, we set the firstly registered one as default
|
|
|
|
|
if (!d->m_cmakeTools.isEmpty()) {
|
|
|
|
|
d->m_defaultCMake = d->m_cmakeTools.first()->id();
|
2015-02-24 21:57:00 +01:00
|
|
|
emit m_instance->defaultCMakeChanged();
|
|
|
|
|
|
2015-02-04 17:54:46 +01:00
|
|
|
return d->m_cmakeTools.first();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeToolManager::setDefaultCMakeTool(const Id &id)
|
|
|
|
|
{
|
|
|
|
|
if (d->m_defaultCMake == id)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-02-24 21:57:00 +01:00
|
|
|
if (findById(id)) {
|
2015-02-04 17:54:46 +01:00
|
|
|
d->m_defaultCMake = id;
|
2015-02-24 21:57:00 +01:00
|
|
|
emit m_instance->defaultCMakeChanged();
|
|
|
|
|
}
|
2015-02-04 17:54:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMakeTool *CMakeToolManager::findByCommand(const FileName &command)
|
|
|
|
|
{
|
|
|
|
|
return Utils::findOrDefault(d->m_cmakeTools, Utils::equal(&CMakeTool::cmakeExecutable, command));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMakeTool *CMakeToolManager::findById(const Id &id)
|
|
|
|
|
{
|
|
|
|
|
return Utils::findOrDefault(d->m_cmakeTools, Utils::equal(&CMakeTool::id, id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeToolManager::restoreCMakeTools()
|
|
|
|
|
{
|
|
|
|
|
Core::Id defaultId;
|
|
|
|
|
|
2018-06-29 13:29:43 +02:00
|
|
|
const FileName sdkSettingsFile = FileName::fromString(ICore::installerResourcePath()
|
|
|
|
|
+ CMAKETOOL_FILENAME);
|
2015-02-04 17:54:46 +01:00
|
|
|
|
2018-06-29 13:24:36 +02:00
|
|
|
QList<CMakeTool *> sdkTools = readCMakeTools(sdkSettingsFile, &defaultId, true);
|
2015-02-04 17:54:46 +01:00
|
|
|
|
|
|
|
|
//read the tools from the user settings file
|
2018-06-29 13:24:36 +02:00
|
|
|
QList<CMakeTool *> userTools = readCMakeTools(userSettingsFileName(), &defaultId, false);
|
2015-02-04 17:54:46 +01:00
|
|
|
|
|
|
|
|
//autodetect tools
|
2018-06-29 13:24:36 +02:00
|
|
|
QList<CMakeTool *> autoDetectedTools = autoDetectCMakeTools();
|
2015-02-04 17:54:46 +01:00
|
|
|
|
|
|
|
|
//filter out the tools that were stored in SDK
|
2018-06-29 13:29:43 +02:00
|
|
|
const QList<CMakeTool *> toRegister = mergeTools(sdkTools, userTools, autoDetectedTools);
|
2015-02-04 17:54:46 +01:00
|
|
|
|
|
|
|
|
// Store all tools
|
2018-06-29 13:24:36 +02:00
|
|
|
foreach (CMakeTool *current, toRegister) {
|
2015-02-04 17:54:46 +01:00
|
|
|
if (!registerCMakeTool(current)) {
|
|
|
|
|
//this should never happen, but lets make sure we do not leak memory
|
|
|
|
|
qWarning() << QString::fromLatin1("CMakeTool \"%1\" (%2) dropped.")
|
|
|
|
|
.arg(current->cmakeExecutable().toUserOutput(), current->id().toString());
|
|
|
|
|
|
|
|
|
|
delete current;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CMakeToolManager::findById(defaultId))
|
|
|
|
|
d->m_defaultCMake = defaultId;
|
|
|
|
|
|
2015-03-10 15:47:09 +01:00
|
|
|
emit m_instance->cmakeToolsLoaded();
|
2015-02-04 17:54:46 +01:00
|
|
|
}
|
|
|
|
|
|
2015-02-24 21:57:00 +01:00
|
|
|
void CMakeToolManager::notifyAboutUpdate(CMakeTool *tool)
|
|
|
|
|
{
|
|
|
|
|
if (!tool || !d->m_cmakeTools.contains(tool))
|
|
|
|
|
return;
|
|
|
|
|
emit m_instance->cmakeUpdated(tool->id());
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-04 17:54:46 +01:00
|
|
|
void CMakeToolManager::saveCMakeTools()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(d->m_writer, return);
|
|
|
|
|
QVariantMap data;
|
|
|
|
|
data.insert(QLatin1String(CMAKETOOL_FILE_VERSION_KEY), 1);
|
|
|
|
|
data.insert(QLatin1String(CMAKETOOL_DEFAULT_KEY), d->m_defaultCMake.toSetting());
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
foreach (CMakeTool *item, d->m_cmakeTools) {
|
|
|
|
|
QFileInfo fi = item->cmakeExecutable().toFileInfo();
|
|
|
|
|
|
|
|
|
|
if (fi.isExecutable()) {
|
|
|
|
|
QVariantMap tmp = item->toMap();
|
|
|
|
|
if (tmp.isEmpty())
|
|
|
|
|
continue;
|
|
|
|
|
data.insert(QString::fromLatin1(CMAKETOOL_DATA_KEY) + QString::number(count), tmp);
|
|
|
|
|
++count;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
data.insert(QLatin1String(CMAKETOOL_COUNT_KEY), count);
|
|
|
|
|
d->m_writer->save(data, ICore::mainWindow());
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-29 15:52:03 +02:00
|
|
|
void CMakeToolManager::addCMakeTool(CMakeTool *item)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(item->id().isValid(), return);
|
|
|
|
|
|
|
|
|
|
d->m_cmakeTools.append(item);
|
|
|
|
|
|
|
|
|
|
emit CMakeToolManager::m_instance->cmakeAdded(item->id());
|
|
|
|
|
|
|
|
|
|
//set the first registered cmake tool as default if there is not already one
|
|
|
|
|
if (!d->m_defaultCMake.isValid())
|
|
|
|
|
CMakeToolManager::setDefaultCMakeTool(item->id());
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-04 17:54:46 +01:00
|
|
|
} // namespace CMakeProjectManager
|