forked from qt-creator/qt-creator
Cmake: Improve handling of build targets in makestep
* Update build targets as they change in CMakeLists.txt * Do not set "all" since that is the default anyway * Signal widget whenever the list of targets to build changes Change-Id: Ie90be143fa345e03576632ab39a5dc5f75b19daf Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -595,13 +595,6 @@ bool CMakeProject::fromMap(const QVariantMap &map)
|
||||
|
||||
parseCMakeLists();
|
||||
|
||||
if (!hasUserFile && hasBuildTarget(QLatin1String("all"))) {
|
||||
MakeStep *makeStep = qobject_cast<MakeStep *>(
|
||||
activeTarget()->activeBuildConfiguration()->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD)->at(0));
|
||||
Q_ASSERT(makeStep);
|
||||
makeStep->setBuildTarget(QLatin1String("all"), true);
|
||||
}
|
||||
|
||||
m_activeTarget = activeTarget();
|
||||
if (m_activeTarget)
|
||||
connect(m_activeTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
||||
|
||||
@@ -108,6 +108,9 @@ void MakeStep::ctor()
|
||||
this, SLOT(activeBuildConfigurationChanged()));
|
||||
activeBuildConfigurationChanged();
|
||||
}
|
||||
|
||||
connect(static_cast<CMakeProject *>(project()), SIGNAL(buildTargetsChanged()),
|
||||
this, SLOT(buildTargetsChanged()));
|
||||
}
|
||||
|
||||
MakeStep::~MakeStep()
|
||||
@@ -137,6 +140,16 @@ void MakeStep::activeBuildConfigurationChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void MakeStep::buildTargetsChanged()
|
||||
{
|
||||
QStringList filteredTargets;
|
||||
foreach (const QString t, static_cast<CMakeProject *>(project())->buildTargetTitles()) {
|
||||
if (m_buildTargets.contains(t))
|
||||
filteredTargets.append(t);
|
||||
}
|
||||
setBuildTargets(filteredTargets);
|
||||
}
|
||||
|
||||
void MakeStep::setClean(bool clean)
|
||||
{
|
||||
m_clean = clean;
|
||||
@@ -174,7 +187,7 @@ bool MakeStep::init()
|
||||
if (!tc) {
|
||||
m_tasks.append(Task(Task::Error, tr("Qt Creator needs a compiler set up to build. Configure a compiler in the kit options."),
|
||||
Utils::FileName(), -1,
|
||||
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
||||
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
|
||||
return true; // otherwise the tasks will not get reported
|
||||
}
|
||||
|
||||
@@ -274,12 +287,15 @@ void MakeStep::setBuildTarget(const QString &buildTarget, bool on)
|
||||
old << buildTarget;
|
||||
else if (!on && old.contains(buildTarget))
|
||||
old.removeOne(buildTarget);
|
||||
m_buildTargets = old;
|
||||
setBuildTargets(old);
|
||||
}
|
||||
|
||||
void MakeStep::setBuildTargets(const QStringList &targets)
|
||||
{
|
||||
if (targets != m_buildTargets) {
|
||||
m_buildTargets = targets;
|
||||
emit targetsToBuildChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void MakeStep::clearBuildTargets()
|
||||
@@ -336,7 +352,7 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
|
||||
fl->addRow(tr("Targets:"), m_buildTargetsList);
|
||||
|
||||
// TODO update this list also on rescans of the CMakeLists.txt
|
||||
CMakeProject *pro = static_cast<CMakeProject *>(m_makeStep->target()->project());
|
||||
CMakeProject *pro = static_cast<CMakeProject *>(m_makeStep->project());
|
||||
QStringList targetList = pro->buildTargetTitles();
|
||||
targetList.sort();
|
||||
foreach (const QString &buildTarget, targetList) {
|
||||
@@ -352,8 +368,8 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
|
||||
connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()),
|
||||
this, SLOT(updateDetails()));
|
||||
|
||||
connect(pro, SIGNAL(buildTargetsChanged()),
|
||||
this, SLOT(buildTargetsChanged()));
|
||||
connect(pro, SIGNAL(buildTargetsChanged()), this, SLOT(buildTargetsChanged()));
|
||||
connect(m_makeStep, SIGNAL(targetsToBuildChanged()), this, SLOT(selectedBuildTargetsChanged()));
|
||||
connect(pro, SIGNAL(environmentChanged()), this, SLOT(updateDetails()));
|
||||
connect(m_makeStep, SIGNAL(makeCommandChanged()), this, SLOT(updateDetails()));
|
||||
}
|
||||
@@ -389,6 +405,17 @@ void MakeStepConfigWidget::buildTargetsChanged()
|
||||
updateSummary();
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::selectedBuildTargetsChanged()
|
||||
{
|
||||
disconnect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
||||
for (int y = 0; y < m_buildTargetsList->count(); ++y) {
|
||||
QListWidgetItem *item = m_buildTargetsList->itemAt(0, y);
|
||||
item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
connect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
||||
updateSummary();
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::updateDetails()
|
||||
{
|
||||
BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
||||
|
||||
@@ -85,8 +85,12 @@ public slots:
|
||||
void setUseNinja(bool);
|
||||
void activeBuildConfigurationChanged();
|
||||
|
||||
private slots:
|
||||
void buildTargetsChanged();
|
||||
|
||||
signals:
|
||||
void makeCommandChanged();
|
||||
void targetsToBuildChanged();
|
||||
|
||||
protected:
|
||||
void processStarted();
|
||||
@@ -127,6 +131,8 @@ private slots:
|
||||
void additionalArgumentsEdited();
|
||||
void updateDetails();
|
||||
void buildTargetsChanged();
|
||||
void selectedBuildTargetsChanged();
|
||||
|
||||
private:
|
||||
MakeStep *m_makeStep;
|
||||
QListWidget *m_buildTargetsList;
|
||||
|
||||
Reference in New Issue
Block a user