forked from qt-creator/qt-creator
CMake: Add helper method to find the default build target for a BuildStep
Add a helper method to find the default build target for a CMakeBuildStep
based on the BuildStepList the step is part of. Use all/install/clean
targets as appropriate.
This change has been cherry-picked from master branch:
8b9821440d
Change-Id: Idc0c5fae7dfd255039b87ace77c02688cdd76e8f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -91,14 +91,8 @@ CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl) :
|
||||
}
|
||||
|
||||
// Set a good default build target:
|
||||
if (m_buildTarget.isEmpty()) {
|
||||
if (bsl->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN)
|
||||
setBuildTarget(cleanTarget());
|
||||
else if (bsl->id() == ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
|
||||
setBuildTarget(installTarget());
|
||||
else
|
||||
setBuildTarget(allTarget());
|
||||
}
|
||||
if (m_buildTarget.isEmpty())
|
||||
setBuildTarget(defaultBuildTarget());
|
||||
|
||||
connect(target(), &Target::kitChanged, this, &CMakeBuildStep::cmakeCommandChanged);
|
||||
connect(project(), &Project::parsingFinished,
|
||||
@@ -277,6 +271,17 @@ BuildStepConfigWidget *CMakeBuildStep::createConfigWidget()
|
||||
return new CMakeBuildStepConfigWidget(this);
|
||||
}
|
||||
|
||||
QString CMakeBuildStep::defaultBuildTarget() const
|
||||
{
|
||||
const ProjectConfiguration *const pc = qobject_cast<ProjectConfiguration *>(parent());
|
||||
const Core::Id parentId = pc ? pc->id() : Core::Id();
|
||||
if (parentId == ProjectExplorer::Constants::BUILDSTEPS_CLEAN)
|
||||
return cleanTarget();
|
||||
if (parentId == ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
|
||||
return installTarget();
|
||||
return allTarget();
|
||||
}
|
||||
|
||||
void CMakeBuildStep::stdOutput(const QString &line)
|
||||
{
|
||||
if (m_percentProgress.indexIn(line) != -1) {
|
||||
|
@@ -98,6 +98,8 @@ private:
|
||||
void doRun() override;
|
||||
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
|
||||
|
||||
QString defaultBuildTarget() const;
|
||||
|
||||
void runImpl();
|
||||
void handleProjectWasParsed(bool success);
|
||||
|
||||
|
Reference in New Issue
Block a user