forked from qt-creator/qt-creator
CMake: Add option to auto-create build directories
Add an option to CMakeTools to force auto-creation of build directories. This does lead to cmake cluttering up the file system with directories, but does not force users to go through the oftentimes long configuration process twice (once in a temporary directory and once in the real location). Task-number: QTCREATORBUG-16794 Change-Id: I68d92fc58638ad0a0a7622b7ef1621e055c9f2a7 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -66,13 +66,13 @@ public:
|
||||
|
||||
CMakeToolTreeItem *cmakeToolItem(const Core::Id &id) const;
|
||||
CMakeToolTreeItem *cmakeToolItem(const QModelIndex &index) const;
|
||||
QModelIndex addCMakeTool(const QString &name, const FileName &executable, const bool autoRun, const bool isAutoDetected);
|
||||
QModelIndex addCMakeTool(const QString &name, const FileName &executable, const bool autoRun, const bool autoCreate, const bool isAutoDetected);
|
||||
void addCMakeTool(const CMakeTool *item, bool changed);
|
||||
TreeItem *autoGroupItem() const;
|
||||
TreeItem *manualGroupItem() const;
|
||||
void reevaluateChangedFlag(CMakeToolTreeItem *item) const;
|
||||
void updateCMakeTool(const Core::Id &id, const QString &displayName, const FileName &executable,
|
||||
bool autoRun);
|
||||
bool autoRun, bool autoCreate);
|
||||
void removeCMakeTool(const Core::Id &id);
|
||||
void apply();
|
||||
|
||||
@@ -95,16 +95,18 @@ public:
|
||||
m_name(item->displayName()),
|
||||
m_executable(item->cmakeExecutable()),
|
||||
m_isAutoRun(item->isAutoRun()),
|
||||
m_autoCreateBuildDirectory(item->autoCreateBuildDirectory()),
|
||||
m_autodetected(item->isAutoDetected()),
|
||||
m_changed(changed)
|
||||
{}
|
||||
|
||||
CMakeToolTreeItem(const QString &name, const Utils::FileName &executable,
|
||||
bool autoRun, bool autodetected) :
|
||||
bool autoRun, bool autoCreate, bool autodetected) :
|
||||
m_id(Core::Id::fromString(QUuid::createUuid().toString())),
|
||||
m_name(name),
|
||||
m_executable(executable),
|
||||
m_isAutoRun(autoRun),
|
||||
m_autoCreateBuildDirectory(autoCreate),
|
||||
m_autodetected(autodetected),
|
||||
m_changed(true)
|
||||
{}
|
||||
@@ -143,6 +145,7 @@ public:
|
||||
QString m_name;
|
||||
FileName m_executable;
|
||||
bool m_isAutoRun = true;
|
||||
bool m_autoCreateBuildDirectory = false;
|
||||
bool m_autodetected = false;
|
||||
bool m_changed = true;
|
||||
};
|
||||
@@ -166,9 +169,10 @@ CMakeToolItemModel::CMakeToolItemModel()
|
||||
}
|
||||
|
||||
QModelIndex CMakeToolItemModel::addCMakeTool(const QString &name, const FileName &executable,
|
||||
const bool autoRun, const bool isAutoDetected)
|
||||
const bool autoRun, const bool autoCreate,
|
||||
const bool isAutoDetected)
|
||||
{
|
||||
CMakeToolTreeItem *item = new CMakeToolTreeItem(name, executable, autoRun, isAutoDetected);
|
||||
CMakeToolTreeItem *item = new CMakeToolTreeItem(name, executable, autoRun, autoCreate, isAutoDetected);
|
||||
if (isAutoDetected)
|
||||
autoGroupItem()->appendChild(item);
|
||||
else
|
||||
@@ -219,7 +223,8 @@ void CMakeToolItemModel::reevaluateChangedFlag(CMakeToolTreeItem *item) const
|
||||
}
|
||||
|
||||
void CMakeToolItemModel::updateCMakeTool(const Core::Id &id, const QString &displayName,
|
||||
const FileName &executable, bool autoRun)
|
||||
const FileName &executable, bool autoRun,
|
||||
bool autoCreate)
|
||||
{
|
||||
CMakeToolTreeItem *treeItem = cmakeToolItem(id);
|
||||
QTC_ASSERT(treeItem, return);
|
||||
@@ -227,6 +232,7 @@ void CMakeToolItemModel::updateCMakeTool(const Core::Id &id, const QString &disp
|
||||
treeItem->m_name = displayName;
|
||||
treeItem->m_executable = executable;
|
||||
treeItem->m_isAutoRun = autoRun;
|
||||
treeItem->m_autoCreateBuildDirectory = autoCreate;
|
||||
|
||||
reevaluateChangedFlag(treeItem);
|
||||
}
|
||||
@@ -262,6 +268,7 @@ void CMakeToolItemModel::apply()
|
||||
cmake->setDisplayName(item->m_name);
|
||||
cmake->setCMakeExecutable(item->m_executable);
|
||||
cmake->setAutorun(item->m_isAutoRun);
|
||||
cmake->setAutoCreateBuildDirectory(item->m_autoCreateBuildDirectory);
|
||||
} else {
|
||||
toRegister.append(item);
|
||||
}
|
||||
@@ -329,6 +336,7 @@ private:
|
||||
CMakeToolItemModel *m_model;
|
||||
QLineEdit *m_displayNameLineEdit;
|
||||
QCheckBox *m_autoRunCheckBox;
|
||||
QCheckBox *m_autoCreateBuildDirectoryCheckBox;
|
||||
PathChooser *m_binaryChooser;
|
||||
Core::Id m_id;
|
||||
bool m_loadingItem;
|
||||
@@ -349,11 +357,16 @@ CMakeToolItemConfigWidget::CMakeToolItemConfigWidget(CMakeToolItemModel *model)
|
||||
m_autoRunCheckBox->setText(tr("Autorun CMake"));
|
||||
m_autoRunCheckBox->setToolTip(tr("Automatically run CMake after changes to CMake project files."));
|
||||
|
||||
m_autoCreateBuildDirectoryCheckBox = new QCheckBox;
|
||||
m_autoCreateBuildDirectoryCheckBox->setText(tr("Auto-create build directories"));
|
||||
m_autoCreateBuildDirectoryCheckBox->setToolTip(tr("Automatically create build directories for CMake projects."));
|
||||
|
||||
QFormLayout *formLayout = new QFormLayout(this);
|
||||
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
||||
formLayout->addRow(new QLabel(tr("Name:")), m_displayNameLineEdit);
|
||||
formLayout->addRow(new QLabel(tr("Path:")), m_binaryChooser);
|
||||
formLayout->addRow(m_autoRunCheckBox);
|
||||
formLayout->addRow(m_autoCreateBuildDirectoryCheckBox);
|
||||
|
||||
connect(m_binaryChooser, &PathChooser::rawPathChanged,
|
||||
this, &CMakeToolItemConfigWidget::store);
|
||||
@@ -361,13 +374,16 @@ CMakeToolItemConfigWidget::CMakeToolItemConfigWidget(CMakeToolItemModel *model)
|
||||
this, &CMakeToolItemConfigWidget::store);
|
||||
connect(m_autoRunCheckBox, &QCheckBox::toggled,
|
||||
this, &CMakeToolItemConfigWidget::store);
|
||||
connect(m_autoCreateBuildDirectoryCheckBox, &QCheckBox::toggled,
|
||||
this, &CMakeToolItemConfigWidget::store);
|
||||
}
|
||||
|
||||
void CMakeToolItemConfigWidget::store() const
|
||||
{
|
||||
if (!m_loadingItem && m_id.isValid())
|
||||
m_model->updateCMakeTool(m_id, m_displayNameLineEdit->text(), m_binaryChooser->fileName(),
|
||||
m_autoRunCheckBox->checkState() == Qt::Checked);
|
||||
m_autoRunCheckBox->checkState() == Qt::Checked,
|
||||
m_autoCreateBuildDirectoryCheckBox->checkState() == Qt::Checked);
|
||||
}
|
||||
|
||||
void CMakeToolItemConfigWidget::load(const CMakeToolTreeItem *item)
|
||||
@@ -387,6 +403,7 @@ void CMakeToolItemConfigWidget::load(const CMakeToolTreeItem *item)
|
||||
m_binaryChooser->setFileName(item->m_executable);
|
||||
|
||||
m_autoRunCheckBox->setChecked(item->m_isAutoRun);
|
||||
m_autoCreateBuildDirectoryCheckBox->setChecked(item->m_autoCreateBuildDirectory);
|
||||
|
||||
m_id = item->m_id;
|
||||
m_loadingItem = false;
|
||||
@@ -492,7 +509,8 @@ void CMakeToolConfigWidget::cloneCMakeTool()
|
||||
|
||||
QModelIndex newItem = m_model.addCMakeTool(tr("Clone of %1").arg(m_currentItem->m_name),
|
||||
m_currentItem->m_executable,
|
||||
m_currentItem->m_isAutoRun, false);
|
||||
m_currentItem->m_isAutoRun,
|
||||
m_currentItem->m_autoCreateBuildDirectory, false);
|
||||
|
||||
m_cmakeToolsView->setCurrentIndex(newItem);
|
||||
}
|
||||
@@ -500,7 +518,7 @@ void CMakeToolConfigWidget::cloneCMakeTool()
|
||||
void CMakeToolConfigWidget::addCMakeTool()
|
||||
{
|
||||
QModelIndex newItem = m_model.addCMakeTool(m_model.uniqueDisplayName(tr("New CMake")),
|
||||
FileName(), true, false);
|
||||
FileName(), true, false, false);
|
||||
|
||||
m_cmakeToolsView->setCurrentIndex(newItem);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user