forked from qt-creator/qt-creator
CMakePM: Make "Autorun CMake" a global setting
The "Autorun CMake" is only visible in the Tools settings page when the user clicks on CMake tool. This is not very visible and it doesn't have to be per CMake version. Change-Id: I57ded0b2e6a3ecb731bb8bc1495b6b61bc04c8b6 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -832,8 +832,8 @@ void CMakeBuildSystem::wireUpConnections()
|
|||||||
|
|
||||||
connect(project(), &Project::projectFileIsDirty, this, [this] {
|
connect(project(), &Project::projectFileIsDirty, this, [this] {
|
||||||
if (buildConfiguration()->isActive() && !isParsing()) {
|
if (buildConfiguration()->isActive() && !isParsing()) {
|
||||||
const auto cmake = CMakeKitAspect::cmakeTool(kit());
|
auto settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||||
if (cmake && cmake->isAutoRun()) {
|
if (settings->autorunCMake.value()) {
|
||||||
qCDebug(cmakeBuildSystemLog) << "Requesting parse due to dirty project file";
|
qCDebug(cmakeBuildSystemLog) << "Requesting parse due to dirty project file";
|
||||||
reparse(CMakeBuildSystem::REPARSE_FORCE_CMAKE_RUN);
|
reparse(CMakeBuildSystem::REPARSE_FORCE_CMAKE_RUN);
|
||||||
}
|
}
|
||||||
|
@@ -58,8 +58,7 @@ public:
|
|||||||
void updateCMakeTool(const Utils::Id &id,
|
void updateCMakeTool(const Utils::Id &id,
|
||||||
const QString &displayName,
|
const QString &displayName,
|
||||||
const FilePath &executable,
|
const FilePath &executable,
|
||||||
const FilePath &qchFile,
|
const FilePath &qchFile);
|
||||||
bool autoRun);
|
|
||||||
void removeCMakeTool(const Utils::Id &id);
|
void removeCMakeTool(const Utils::Id &id);
|
||||||
void apply();
|
void apply();
|
||||||
|
|
||||||
@@ -82,7 +81,6 @@ public:
|
|||||||
, m_qchFile(item->qchFilePath())
|
, m_qchFile(item->qchFilePath())
|
||||||
, m_versionDisplay(item->versionDisplay())
|
, m_versionDisplay(item->versionDisplay())
|
||||||
, m_detectionSource(item->detectionSource())
|
, m_detectionSource(item->detectionSource())
|
||||||
, m_isAutoRun(item->isAutoRun())
|
|
||||||
, m_autodetected(item->isAutoDetected())
|
, m_autodetected(item->isAutoDetected())
|
||||||
, m_isSupported(item->hasFileApi())
|
, m_isSupported(item->hasFileApi())
|
||||||
, m_changed(changed)
|
, m_changed(changed)
|
||||||
@@ -280,8 +278,7 @@ void CMakeToolItemModel::reevaluateChangedFlag(CMakeToolTreeItem *item) const
|
|||||||
void CMakeToolItemModel::updateCMakeTool(const Id &id,
|
void CMakeToolItemModel::updateCMakeTool(const Id &id,
|
||||||
const QString &displayName,
|
const QString &displayName,
|
||||||
const FilePath &executable,
|
const FilePath &executable,
|
||||||
const FilePath &qchFile,
|
const FilePath &qchFile)
|
||||||
bool autoRun)
|
|
||||||
{
|
{
|
||||||
CMakeToolTreeItem *treeItem = cmakeToolItem(id);
|
CMakeToolTreeItem *treeItem = cmakeToolItem(id);
|
||||||
QTC_ASSERT(treeItem, return );
|
QTC_ASSERT(treeItem, return );
|
||||||
@@ -289,7 +286,6 @@ void CMakeToolItemModel::updateCMakeTool(const Id &id,
|
|||||||
treeItem->m_name = displayName;
|
treeItem->m_name = displayName;
|
||||||
treeItem->m_executable = executable;
|
treeItem->m_executable = executable;
|
||||||
treeItem->m_qchFile = qchFile;
|
treeItem->m_qchFile = qchFile;
|
||||||
treeItem->m_isAutoRun = autoRun;
|
|
||||||
|
|
||||||
treeItem->updateErrorFlags();
|
treeItem->updateErrorFlags();
|
||||||
|
|
||||||
@@ -331,7 +327,6 @@ void CMakeToolItemModel::apply()
|
|||||||
cmake->setFilePath(item->m_executable);
|
cmake->setFilePath(item->m_executable);
|
||||||
cmake->setQchFilePath(item->m_qchFile);
|
cmake->setQchFilePath(item->m_qchFile);
|
||||||
cmake->setDetectionSource(item->m_detectionSource);
|
cmake->setDetectionSource(item->m_detectionSource);
|
||||||
cmake->setAutorun(item->m_isAutoRun);
|
|
||||||
} else {
|
} else {
|
||||||
toRegister.append(item);
|
toRegister.append(item);
|
||||||
}
|
}
|
||||||
@@ -399,7 +394,6 @@ private:
|
|||||||
|
|
||||||
CMakeToolItemModel *m_model;
|
CMakeToolItemModel *m_model;
|
||||||
QLineEdit *m_displayNameLineEdit;
|
QLineEdit *m_displayNameLineEdit;
|
||||||
QCheckBox *m_autoRunCheckBox;
|
|
||||||
PathChooser *m_binaryChooser;
|
PathChooser *m_binaryChooser;
|
||||||
PathChooser *m_qchFileChooser;
|
PathChooser *m_qchFileChooser;
|
||||||
QLabel *m_versionLabel;
|
QLabel *m_versionLabel;
|
||||||
@@ -428,24 +422,17 @@ CMakeToolItemConfigWidget::CMakeToolItemConfigWidget(CMakeToolItemModel *model)
|
|||||||
|
|
||||||
m_versionLabel = new QLabel(this);
|
m_versionLabel = new QLabel(this);
|
||||||
|
|
||||||
m_autoRunCheckBox = new QCheckBox;
|
|
||||||
m_autoRunCheckBox->setText(Tr::tr("Autorun CMake"));
|
|
||||||
m_autoRunCheckBox->setToolTip(Tr::tr("Automatically run CMake after changes to CMake project files."));
|
|
||||||
|
|
||||||
auto formLayout = new QFormLayout(this);
|
auto formLayout = new QFormLayout(this);
|
||||||
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
||||||
formLayout->addRow(new QLabel(Tr::tr("Name:")), m_displayNameLineEdit);
|
formLayout->addRow(new QLabel(Tr::tr("Name:")), m_displayNameLineEdit);
|
||||||
formLayout->addRow(new QLabel(Tr::tr("Path:")), m_binaryChooser);
|
formLayout->addRow(new QLabel(Tr::tr("Path:")), m_binaryChooser);
|
||||||
formLayout->addRow(new QLabel(Tr::tr("Version:")), m_versionLabel);
|
formLayout->addRow(new QLabel(Tr::tr("Version:")), m_versionLabel);
|
||||||
formLayout->addRow(new QLabel(Tr::tr("Help file:")), m_qchFileChooser);
|
formLayout->addRow(new QLabel(Tr::tr("Help file:")), m_qchFileChooser);
|
||||||
formLayout->addRow(m_autoRunCheckBox);
|
|
||||||
|
|
||||||
connect(m_binaryChooser, &PathChooser::browsingFinished, this, &CMakeToolItemConfigWidget::onBinaryPathEditingFinished);
|
connect(m_binaryChooser, &PathChooser::browsingFinished, this, &CMakeToolItemConfigWidget::onBinaryPathEditingFinished);
|
||||||
connect(m_binaryChooser, &PathChooser::editingFinished, this, &CMakeToolItemConfigWidget::onBinaryPathEditingFinished);
|
connect(m_binaryChooser, &PathChooser::editingFinished, this, &CMakeToolItemConfigWidget::onBinaryPathEditingFinished);
|
||||||
connect(m_qchFileChooser, &PathChooser::rawPathChanged, this, &CMakeToolItemConfigWidget::store);
|
connect(m_qchFileChooser, &PathChooser::rawPathChanged, this, &CMakeToolItemConfigWidget::store);
|
||||||
connect(m_displayNameLineEdit, &QLineEdit::textChanged, this, &CMakeToolItemConfigWidget::store);
|
connect(m_displayNameLineEdit, &QLineEdit::textChanged, this, &CMakeToolItemConfigWidget::store);
|
||||||
connect(m_autoRunCheckBox, &QCheckBox::toggled,
|
|
||||||
this, &CMakeToolItemConfigWidget::store);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeToolItemConfigWidget::store() const
|
void CMakeToolItemConfigWidget::store() const
|
||||||
@@ -454,8 +441,7 @@ void CMakeToolItemConfigWidget::store() const
|
|||||||
m_model->updateCMakeTool(m_id,
|
m_model->updateCMakeTool(m_id,
|
||||||
m_displayNameLineEdit->text(),
|
m_displayNameLineEdit->text(),
|
||||||
m_binaryChooser->filePath(),
|
m_binaryChooser->filePath(),
|
||||||
m_qchFileChooser->filePath(),
|
m_qchFileChooser->filePath());
|
||||||
m_autoRunCheckBox->checkState() == Qt::Checked);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeToolItemConfigWidget::onBinaryPathEditingFinished()
|
void CMakeToolItemConfigWidget::onBinaryPathEditingFinished()
|
||||||
@@ -493,8 +479,6 @@ void CMakeToolItemConfigWidget::load(const CMakeToolTreeItem *item)
|
|||||||
|
|
||||||
m_versionLabel->setText(item->m_versionDisplay);
|
m_versionLabel->setText(item->m_versionDisplay);
|
||||||
|
|
||||||
m_autoRunCheckBox->setChecked(item->m_isAutoRun);
|
|
||||||
|
|
||||||
m_id = item->m_id;
|
m_id = item->m_id;
|
||||||
m_loadingItem = false;
|
m_loadingItem = false;
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,13 @@ CMakeSpecificSettings::CMakeSpecificSettings()
|
|||||||
setSettingsGroup("CMakeSpecificSettings");
|
setSettingsGroup("CMakeSpecificSettings");
|
||||||
setAutoApply(false);
|
setAutoApply(false);
|
||||||
|
|
||||||
|
registerAspect(&autorunCMake);
|
||||||
|
autorunCMake.setSettingsKey("AutorunCMake");
|
||||||
|
autorunCMake.setDefaultValue(true);
|
||||||
|
autorunCMake.setLabelText(::CMakeProjectManager::Tr::tr("Autorun CMake"));
|
||||||
|
autorunCMake.setToolTip(::CMakeProjectManager::Tr::tr(
|
||||||
|
"Automatically run CMake after changes to CMake project files."));
|
||||||
|
|
||||||
registerAspect(&afterAddFileSetting);
|
registerAspect(&afterAddFileSetting);
|
||||||
afterAddFileSetting.setSettingsKey("ProjectPopupSetting");
|
afterAddFileSetting.setSettingsKey("ProjectPopupSetting");
|
||||||
afterAddFileSetting.setDefaultValue(AfterAddFileAction::AskUser);
|
afterAddFileSetting.setDefaultValue(AfterAddFileAction::AskUser);
|
||||||
@@ -85,6 +92,7 @@ CMakeSpecificSettingsPage::CMakeSpecificSettingsPage(CMakeSpecificSettings *sett
|
|||||||
title(::CMakeProjectManager::Tr::tr("Adding Files")),
|
title(::CMakeProjectManager::Tr::tr("Adding Files")),
|
||||||
Column { s.afterAddFileSetting }
|
Column { s.afterAddFileSetting }
|
||||||
},
|
},
|
||||||
|
s.autorunCMake,
|
||||||
s.packageManagerAutoSetup,
|
s.packageManagerAutoSetup,
|
||||||
s.askBeforeReConfigureInitialParams,
|
s.askBeforeReConfigureInitialParams,
|
||||||
s.showSourceSubFolders,
|
s.showSourceSubFolders,
|
||||||
|
@@ -20,6 +20,7 @@ class CMakeSpecificSettings final : public Utils::AspectContainer
|
|||||||
public:
|
public:
|
||||||
CMakeSpecificSettings();
|
CMakeSpecificSettings();
|
||||||
|
|
||||||
|
Utils::BoolAspect autorunCMake;
|
||||||
Utils::SelectionAspect afterAddFileSetting;
|
Utils::SelectionAspect afterAddFileSetting;
|
||||||
Utils::StringAspect ninjaPath;
|
Utils::StringAspect ninjaPath;
|
||||||
Utils::BoolAspect packageManagerAutoSetup;
|
Utils::BoolAspect packageManagerAutoSetup;
|
||||||
|
@@ -151,15 +151,6 @@ FilePath CMakeTool::filePath() const
|
|||||||
return m_executable;
|
return m_executable;
|
||||||
}
|
}
|
||||||
|
|
||||||
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() || !m_introspection)
|
if (!m_id.isValid() || !m_introspection)
|
||||||
|
@@ -61,8 +61,6 @@ public:
|
|||||||
Utils::Id id() const { return m_id; }
|
Utils::Id id() const { return m_id; }
|
||||||
QVariantMap toMap () const;
|
QVariantMap toMap () const;
|
||||||
|
|
||||||
void setAutorun(bool autoRun);
|
|
||||||
|
|
||||||
void setFilePath(const Utils::FilePath &executable);
|
void setFilePath(const Utils::FilePath &executable);
|
||||||
Utils::FilePath filePath() const;
|
Utils::FilePath filePath() const;
|
||||||
Utils::FilePath cmakeExecutable() const;
|
Utils::FilePath cmakeExecutable() const;
|
||||||
|
@@ -4,6 +4,8 @@
|
|||||||
#include "cmaketoolmanager.h"
|
#include "cmaketoolmanager.h"
|
||||||
|
|
||||||
#include "cmakeprojectmanagertr.h"
|
#include "cmakeprojectmanagertr.h"
|
||||||
|
#include "cmakeprojectplugin.h"
|
||||||
|
#include "cmakespecificsettings.h"
|
||||||
#include "cmaketoolsettingsaccessor.h"
|
#include "cmaketoolsettingsaccessor.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
@@ -138,6 +140,14 @@ void CMakeToolManager::restoreCMakeTools()
|
|||||||
updateDocumentation();
|
updateDocumentation();
|
||||||
|
|
||||||
emit m_instance->cmakeToolsLoaded();
|
emit m_instance->cmakeToolsLoaded();
|
||||||
|
|
||||||
|
// Store the default CMake tool "Autorun CMake" value globally
|
||||||
|
auto settings = Internal::CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||||
|
if (settings->autorunCMake.value() == settings->autorunCMake.defaultValue()) {
|
||||||
|
CMakeTool *cmake = defaultCMakeTool();
|
||||||
|
settings->autorunCMake.setValue(cmake ? cmake->isAutoRun() : true);
|
||||||
|
settings->writeSettings(Core::ICore::settings());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeToolManager::updateDocumentation()
|
void CMakeToolManager::updateDocumentation()
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "cmakeprocess.h"
|
#include "cmakeprocess.h"
|
||||||
#include "cmakeprojectmanagertr.h"
|
#include "cmakeprojectmanagertr.h"
|
||||||
|
#include "cmakeprojectplugin.h"
|
||||||
|
#include "cmakespecificsettings.h"
|
||||||
#include "fileapidataextractor.h"
|
#include "fileapidataextractor.h"
|
||||||
#include "fileapiparser.h"
|
#include "fileapiparser.h"
|
||||||
|
|
||||||
@@ -106,7 +108,8 @@ void FileApiReader::parse(bool forceCMakeRun,
|
|||||||
// * A query file is newer than the reply file
|
// * A query file is newer than the reply file
|
||||||
const bool hasArguments = !args.isEmpty();
|
const bool hasArguments = !args.isEmpty();
|
||||||
const bool replyFileMissing = !replyFile.exists();
|
const bool replyFileMissing = !replyFile.exists();
|
||||||
const bool cmakeFilesChanged = m_parameters.cmakeTool() && m_parameters.cmakeTool()->isAutoRun()
|
const auto settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||||
|
const bool cmakeFilesChanged = m_parameters.cmakeTool() && settings->autorunCMake.value()
|
||||||
&& anyOf(m_cmakeFiles, [&replyFile](const CMakeFileInfo &info) {
|
&& anyOf(m_cmakeFiles, [&replyFile](const CMakeFileInfo &info) {
|
||||||
return !info.isGenerated
|
return !info.isGenerated
|
||||||
&& info.path.lastModified() > replyFile.lastModified();
|
&& info.path.lastModified() > replyFile.lastModified();
|
||||||
|
Reference in New Issue
Block a user