forked from qt-creator/qt-creator
CMake: Add per-cmake option to not automatically run cmake
Task-number: QTCREATORBUG-15934 Change-Id: I54fdb505a451fb269c3747a370c8dfd7043c6c9d Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -108,7 +108,13 @@ BuildDirManager::BuildDirManager(CMakeBuildConfiguration *bc) :
|
|||||||
connect(&m_reparseTimer, &QTimer::timeout, this, &BuildDirManager::parse);
|
connect(&m_reparseTimer, &QTimer::timeout, this, &BuildDirManager::parse);
|
||||||
|
|
||||||
connect(m_watcher, &QFileSystemWatcher::fileChanged, this, [this]() {
|
connect(m_watcher, &QFileSystemWatcher::fileChanged, this, [this]() {
|
||||||
if (!isParsing())
|
if (isParsing())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const CMakeTool *tool = CMakeKitInformation::cmakeTool(m_buildConfiguration->target()->kit());
|
||||||
|
if (!tool->isAutoRun())
|
||||||
|
return;
|
||||||
|
|
||||||
m_reparseTimer.start();
|
m_reparseTimer.start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@@ -65,12 +66,13 @@ public:
|
|||||||
|
|
||||||
CMakeToolTreeItem *cmakeToolItem(const Core::Id &id) const;
|
CMakeToolTreeItem *cmakeToolItem(const Core::Id &id) const;
|
||||||
CMakeToolTreeItem *cmakeToolItem(const QModelIndex &index) const;
|
CMakeToolTreeItem *cmakeToolItem(const QModelIndex &index) const;
|
||||||
QModelIndex addCMakeTool(const QString &name, const FileName &executable, const bool isAutoDetected);
|
QModelIndex addCMakeTool(const QString &name, const FileName &executable, const bool autoRun, const bool isAutoDetected);
|
||||||
void addCMakeTool(const CMakeTool *item, bool changed);
|
void addCMakeTool(const CMakeTool *item, bool changed);
|
||||||
TreeItem *autoGroupItem() const;
|
TreeItem *autoGroupItem() const;
|
||||||
TreeItem *manualGroupItem() const;
|
TreeItem *manualGroupItem() const;
|
||||||
void reevaluateChangedFlag(CMakeToolTreeItem *item) const;
|
void reevaluateChangedFlag(CMakeToolTreeItem *item) const;
|
||||||
void updateCMakeTool(const Core::Id &id, const QString &displayName, const FileName &executable);
|
void updateCMakeTool(const Core::Id &id, const QString &displayName, const FileName &executable,
|
||||||
|
bool autoRun);
|
||||||
void removeCMakeTool(const Core::Id &id);
|
void removeCMakeTool(const Core::Id &id);
|
||||||
void apply();
|
void apply();
|
||||||
|
|
||||||
@@ -92,19 +94,22 @@ public:
|
|||||||
m_id(item->id()),
|
m_id(item->id()),
|
||||||
m_name(item->displayName()),
|
m_name(item->displayName()),
|
||||||
m_executable(item->cmakeExecutable()),
|
m_executable(item->cmakeExecutable()),
|
||||||
|
m_isAutoRun(item->isAutoRun()),
|
||||||
m_autodetected(item->isAutoDetected()),
|
m_autodetected(item->isAutoDetected()),
|
||||||
m_changed(changed)
|
m_changed(changed)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CMakeToolTreeItem(const QString &name, const Utils::FileName &executable, bool autodetected) :
|
CMakeToolTreeItem(const QString &name, const Utils::FileName &executable,
|
||||||
|
bool autoRun, bool autodetected) :
|
||||||
m_id(Core::Id::fromString(QUuid::createUuid().toString())),
|
m_id(Core::Id::fromString(QUuid::createUuid().toString())),
|
||||||
m_name(name),
|
m_name(name),
|
||||||
m_executable(executable),
|
m_executable(executable),
|
||||||
|
m_isAutoRun(autoRun),
|
||||||
m_autodetected(autodetected),
|
m_autodetected(autodetected),
|
||||||
m_changed(true)
|
m_changed(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CMakeToolTreeItem() : m_autodetected(false), m_changed(true) {}
|
CMakeToolTreeItem() = default;
|
||||||
|
|
||||||
CMakeToolItemModel *model() const { return static_cast<CMakeToolItemModel *>(TreeItem::model()); }
|
CMakeToolItemModel *model() const { return static_cast<CMakeToolItemModel *>(TreeItem::model()); }
|
||||||
|
|
||||||
@@ -135,8 +140,9 @@ public:
|
|||||||
Core::Id m_id;
|
Core::Id m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
FileName m_executable;
|
FileName m_executable;
|
||||||
bool m_autodetected;
|
bool m_isAutoRun = true;
|
||||||
bool m_changed;
|
bool m_autodetected = false;
|
||||||
|
bool m_changed = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
CMakeToolItemModel::CMakeToolItemModel()
|
CMakeToolItemModel::CMakeToolItemModel()
|
||||||
@@ -157,9 +163,10 @@ CMakeToolItemModel::CMakeToolItemModel()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex CMakeToolItemModel::addCMakeTool(const QString &name, const FileName &executable, const bool isAutoDetected)
|
QModelIndex CMakeToolItemModel::addCMakeTool(const QString &name, const FileName &executable,
|
||||||
|
const bool autoRun, const bool isAutoDetected)
|
||||||
{
|
{
|
||||||
CMakeToolTreeItem *item = new CMakeToolTreeItem(name, executable, isAutoDetected);
|
CMakeToolTreeItem *item = new CMakeToolTreeItem(name, executable, autoRun, isAutoDetected);
|
||||||
if (isAutoDetected)
|
if (isAutoDetected)
|
||||||
autoGroupItem()->appendChild(item);
|
autoGroupItem()->appendChild(item);
|
||||||
else
|
else
|
||||||
@@ -208,13 +215,14 @@ void CMakeToolItemModel::reevaluateChangedFlag(CMakeToolTreeItem *item) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CMakeToolItemModel::updateCMakeTool(const Core::Id &id, const QString &displayName,
|
void CMakeToolItemModel::updateCMakeTool(const Core::Id &id, const QString &displayName,
|
||||||
const FileName &executable)
|
const FileName &executable, bool autoRun)
|
||||||
{
|
{
|
||||||
CMakeToolTreeItem *treeItem = cmakeToolItem(id);
|
CMakeToolTreeItem *treeItem = cmakeToolItem(id);
|
||||||
QTC_ASSERT(treeItem, return);
|
QTC_ASSERT(treeItem, return);
|
||||||
|
|
||||||
treeItem->m_name = displayName;
|
treeItem->m_name = displayName;
|
||||||
treeItem->m_executable = executable;
|
treeItem->m_executable = executable;
|
||||||
|
treeItem->m_isAutoRun = autoRun;
|
||||||
|
|
||||||
reevaluateChangedFlag(treeItem);
|
reevaluateChangedFlag(treeItem);
|
||||||
}
|
}
|
||||||
@@ -249,6 +257,7 @@ void CMakeToolItemModel::apply()
|
|||||||
if (CMakeTool *cmake = CMakeToolManager::findById(item->m_id)) {
|
if (CMakeTool *cmake = CMakeToolManager::findById(item->m_id)) {
|
||||||
cmake->setDisplayName(item->m_name);
|
cmake->setDisplayName(item->m_name);
|
||||||
cmake->setCMakeExecutable(item->m_executable);
|
cmake->setCMakeExecutable(item->m_executable);
|
||||||
|
cmake->setAutorun(item->m_isAutoRun);
|
||||||
} else {
|
} else {
|
||||||
toRegister.append(item);
|
toRegister.append(item);
|
||||||
}
|
}
|
||||||
@@ -315,6 +324,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
CMakeToolItemModel *m_model;
|
CMakeToolItemModel *m_model;
|
||||||
QLineEdit *m_displayNameLineEdit;
|
QLineEdit *m_displayNameLineEdit;
|
||||||
|
QCheckBox *m_autoRunCheckBox;
|
||||||
PathChooser *m_binaryChooser;
|
PathChooser *m_binaryChooser;
|
||||||
Core::Id m_id;
|
Core::Id m_id;
|
||||||
bool m_loadingItem;
|
bool m_loadingItem;
|
||||||
@@ -330,21 +340,28 @@ CMakeToolItemConfigWidget::CMakeToolItemConfigWidget(CMakeToolItemModel *model)
|
|||||||
m_binaryChooser->setMinimumWidth(400);
|
m_binaryChooser->setMinimumWidth(400);
|
||||||
m_binaryChooser->setHistoryCompleter(QLatin1String("Cmake.Command.History"));
|
m_binaryChooser->setHistoryCompleter(QLatin1String("Cmake.Command.History"));
|
||||||
|
|
||||||
|
m_autoRunCheckBox = new QCheckBox;
|
||||||
|
m_autoRunCheckBox->setText("Autorun CMake");
|
||||||
|
|
||||||
QFormLayout *formLayout = new QFormLayout(this);
|
QFormLayout *formLayout = new QFormLayout(this);
|
||||||
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
||||||
formLayout->addRow(new QLabel(tr("Name:")), m_displayNameLineEdit);
|
formLayout->addRow(new QLabel(tr("Name:")), m_displayNameLineEdit);
|
||||||
formLayout->addRow(new QLabel(tr("Path:")), m_binaryChooser);
|
formLayout->addRow(new QLabel(tr("Path:")), m_binaryChooser);
|
||||||
|
formLayout->addRow(m_autoRunCheckBox);
|
||||||
|
|
||||||
connect(m_binaryChooser, &PathChooser::rawPathChanged,
|
connect(m_binaryChooser, &PathChooser::rawPathChanged,
|
||||||
this, &CMakeToolItemConfigWidget::store);
|
this, &CMakeToolItemConfigWidget::store);
|
||||||
connect(m_displayNameLineEdit, &QLineEdit::textChanged,
|
connect(m_displayNameLineEdit, &QLineEdit::textChanged,
|
||||||
this, &CMakeToolItemConfigWidget::store);
|
this, &CMakeToolItemConfigWidget::store);
|
||||||
|
connect(m_autoRunCheckBox, &QCheckBox::toggled,
|
||||||
|
this, &CMakeToolItemConfigWidget::store);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeToolItemConfigWidget::store() const
|
void CMakeToolItemConfigWidget::store() const
|
||||||
{
|
{
|
||||||
if (!m_loadingItem && m_id.isValid())
|
if (!m_loadingItem && m_id.isValid())
|
||||||
m_model->updateCMakeTool(m_id, m_displayNameLineEdit->text(), m_binaryChooser->fileName());
|
m_model->updateCMakeTool(m_id, m_displayNameLineEdit->text(), m_binaryChooser->fileName(),
|
||||||
|
m_autoRunCheckBox->checkState() == Qt::Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeToolItemConfigWidget::load(const CMakeToolTreeItem *item)
|
void CMakeToolItemConfigWidget::load(const CMakeToolTreeItem *item)
|
||||||
@@ -363,6 +380,8 @@ void CMakeToolItemConfigWidget::load(const CMakeToolTreeItem *item)
|
|||||||
m_binaryChooser->setReadOnly(item->m_autodetected);
|
m_binaryChooser->setReadOnly(item->m_autodetected);
|
||||||
m_binaryChooser->setFileName(item->m_executable);
|
m_binaryChooser->setFileName(item->m_executable);
|
||||||
|
|
||||||
|
m_autoRunCheckBox->setChecked(item->m_isAutoRun);
|
||||||
|
|
||||||
m_id = item->m_id;
|
m_id = item->m_id;
|
||||||
m_loadingItem = false;
|
m_loadingItem = false;
|
||||||
}
|
}
|
||||||
@@ -375,7 +394,7 @@ class CMakeToolConfigWidget : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CMakeToolConfigWidget() : m_currentItem(0)
|
CMakeToolConfigWidget()
|
||||||
{
|
{
|
||||||
m_addButton = new QPushButton(tr("Add"), this);
|
m_addButton = new QPushButton(tr("Add"), this);
|
||||||
|
|
||||||
@@ -452,7 +471,7 @@ public:
|
|||||||
QPushButton *m_makeDefButton;
|
QPushButton *m_makeDefButton;
|
||||||
DetailsWidget *m_container;
|
DetailsWidget *m_container;
|
||||||
CMakeToolItemConfigWidget *m_itemConfigWidget;
|
CMakeToolItemConfigWidget *m_itemConfigWidget;
|
||||||
CMakeToolTreeItem *m_currentItem;
|
CMakeToolTreeItem *m_currentItem = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
void CMakeToolConfigWidget::apply()
|
void CMakeToolConfigWidget::apply()
|
||||||
@@ -467,7 +486,7 @@ void CMakeToolConfigWidget::cloneCMakeTool()
|
|||||||
|
|
||||||
QModelIndex newItem = m_model.addCMakeTool(tr("Clone of %1").arg(m_currentItem->m_name),
|
QModelIndex newItem = m_model.addCMakeTool(tr("Clone of %1").arg(m_currentItem->m_name),
|
||||||
m_currentItem->m_executable,
|
m_currentItem->m_executable,
|
||||||
false);
|
m_currentItem->m_isAutoRun, false);
|
||||||
|
|
||||||
m_cmakeToolsView->setCurrentIndex(newItem);
|
m_cmakeToolsView->setCurrentIndex(newItem);
|
||||||
}
|
}
|
||||||
@@ -475,7 +494,7 @@ void CMakeToolConfigWidget::cloneCMakeTool()
|
|||||||
void CMakeToolConfigWidget::addCMakeTool()
|
void CMakeToolConfigWidget::addCMakeTool()
|
||||||
{
|
{
|
||||||
QModelIndex newItem = m_model.addCMakeTool(m_model.uniqueDisplayName(tr("New CMake")),
|
QModelIndex newItem = m_model.addCMakeTool(m_model.uniqueDisplayName(tr("New CMake")),
|
||||||
FileName(), false);
|
FileName(), true, false);
|
||||||
|
|
||||||
m_cmakeToolsView->setCurrentIndex(newItem);
|
m_cmakeToolsView->setCurrentIndex(newItem);
|
||||||
}
|
}
|
||||||
|
@@ -42,6 +42,7 @@ namespace CMakeProjectManager {
|
|||||||
const char CMAKE_INFORMATION_ID[] = "Id";
|
const char CMAKE_INFORMATION_ID[] = "Id";
|
||||||
const char CMAKE_INFORMATION_COMMAND[] = "Binary";
|
const char CMAKE_INFORMATION_COMMAND[] = "Binary";
|
||||||
const char CMAKE_INFORMATION_DISPLAYNAME[] = "DisplayName";
|
const char CMAKE_INFORMATION_DISPLAYNAME[] = "DisplayName";
|
||||||
|
const char CMAKE_INFORMATION_AUTORUN[] = "AutoRun";
|
||||||
const char CMAKE_INFORMATION_AUTODETECTED[] = "AutoDetected";
|
const char CMAKE_INFORMATION_AUTODETECTED[] = "AutoDetected";
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
@@ -57,6 +58,7 @@ CMakeTool::CMakeTool(const QVariantMap &map, bool fromSdk) : m_isAutoDetected(fr
|
|||||||
{
|
{
|
||||||
m_id = Core::Id::fromSetting(map.value(QLatin1String(CMAKE_INFORMATION_ID)));
|
m_id = Core::Id::fromSetting(map.value(QLatin1String(CMAKE_INFORMATION_ID)));
|
||||||
m_displayName = map.value(QLatin1String(CMAKE_INFORMATION_DISPLAYNAME)).toString();
|
m_displayName = map.value(QLatin1String(CMAKE_INFORMATION_DISPLAYNAME)).toString();
|
||||||
|
m_isAutoRun = map.value(QLatin1String(CMAKE_INFORMATION_AUTORUN), true).toBool();
|
||||||
|
|
||||||
//loading a CMakeTool from SDK is always autodetection
|
//loading a CMakeTool from SDK is always autodetection
|
||||||
if (!fromSdk)
|
if (!fromSdk)
|
||||||
@@ -82,6 +84,15 @@ void CMakeTool::setCMakeExecutable(const Utils::FileName &executable)
|
|||||||
CMakeToolManager::notifyAboutUpdate(this);
|
CMakeToolManager::notifyAboutUpdate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMakeTool::setAutorun(bool autoRun)
|
||||||
|
{
|
||||||
|
if (m_isAutoRun == autoRun)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_isAutoRun = autoRun;
|
||||||
|
CMakeToolManager::notifyAboutUpdate(this);
|
||||||
|
}
|
||||||
|
|
||||||
bool CMakeTool::isValid() const
|
bool CMakeTool::isValid() const
|
||||||
{
|
{
|
||||||
if (!m_id.isValid())
|
if (!m_id.isValid())
|
||||||
@@ -121,6 +132,7 @@ QVariantMap CMakeTool::toMap() const
|
|||||||
data.insert(QLatin1String(CMAKE_INFORMATION_DISPLAYNAME), m_displayName);
|
data.insert(QLatin1String(CMAKE_INFORMATION_DISPLAYNAME), m_displayName);
|
||||||
data.insert(QLatin1String(CMAKE_INFORMATION_ID), m_id.toSetting());
|
data.insert(QLatin1String(CMAKE_INFORMATION_ID), m_id.toSetting());
|
||||||
data.insert(QLatin1String(CMAKE_INFORMATION_COMMAND), m_executable.toString());
|
data.insert(QLatin1String(CMAKE_INFORMATION_COMMAND), m_executable.toString());
|
||||||
|
data.insert(QLatin1String(CMAKE_INFORMATION_AUTORUN), m_isAutoRun);
|
||||||
data.insert(QLatin1String(CMAKE_INFORMATION_AUTODETECTED), m_isAutoDetected);
|
data.insert(QLatin1String(CMAKE_INFORMATION_AUTODETECTED), m_isAutoDetected);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -130,6 +142,11 @@ Utils::FileName CMakeTool::cmakeExecutable() const
|
|||||||
return m_executable;
|
return m_executable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CMakeTool::isAutoRun() const
|
||||||
|
{
|
||||||
|
return m_isAutoRun;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList CMakeTool::supportedGenerators() const
|
QStringList CMakeTool::supportedGenerators() const
|
||||||
{
|
{
|
||||||
if (m_generators.isEmpty()) {
|
if (m_generators.isEmpty()) {
|
||||||
|
@@ -66,8 +66,10 @@ public:
|
|||||||
QVariantMap toMap () const;
|
QVariantMap toMap () const;
|
||||||
|
|
||||||
void setCMakeExecutable(const Utils::FileName &executable);
|
void setCMakeExecutable(const Utils::FileName &executable);
|
||||||
|
void setAutorun(bool autoRun);
|
||||||
|
|
||||||
Utils::FileName cmakeExecutable() const;
|
Utils::FileName cmakeExecutable() const;
|
||||||
|
bool isAutoRun() const;
|
||||||
QStringList supportedGenerators() const;
|
QStringList supportedGenerators() const;
|
||||||
TextEditor::Keywords keywords();
|
TextEditor::Keywords keywords();
|
||||||
|
|
||||||
@@ -87,6 +89,8 @@ private:
|
|||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
Utils::FileName m_executable;
|
Utils::FileName m_executable;
|
||||||
|
|
||||||
|
bool m_isAutoRun;
|
||||||
|
|
||||||
bool m_isAutoDetected;
|
bool m_isAutoDetected;
|
||||||
|
|
||||||
mutable bool m_didAttemptToRun;
|
mutable bool m_didAttemptToRun;
|
||||||
|
Reference in New Issue
Block a user