CMake: Unify setup of default build target in CMakeBuildStep

Change-Id: I3d087356a4dd5a3b8ab07d5b64cd5aeb93ae0f47
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tobias Hunger
2017-04-26 15:34:04 +02:00
parent 10d6a3bc3d
commit 11c87bd918
2 changed files with 11 additions and 9 deletions

View File

@@ -545,15 +545,10 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(Proj
auto cleanStep = new CMakeBuildStep(cleanSteps);
cleanSteps->insertStep(0, cleanStep);
cleanStep->setBuildTarget(CMakeBuildStep::cleanTarget());
bc->setBuildDirectory(copy.buildDirectory);
bc->setCMakeConfiguration(copy.configuration);
// Default to all
if (project->hasBuildTarget(CMakeBuildStep::allTarget()))
buildStep->setBuildTarget(CMakeBuildStep::allTarget());
return bc;
}

View File

@@ -108,6 +108,16 @@ void CMakeBuildStep::ctor(BuildStepList *bsl)
bc = qobject_cast<CMakeBuildConfiguration *>(t->activeBuildConfiguration());
}
// 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());
}
connect(target(), &Target::kitChanged, this, &CMakeBuildStep::cmakeCommandChanged);
connect(bc, &CMakeBuildConfiguration::dataAvailable, this, &CMakeBuildStep::handleBuildTargetChanges);
}
@@ -554,10 +564,7 @@ QList<BuildStepInfo> CMakeBuildStepFactory::availableSteps(BuildStepList *parent
BuildStep *CMakeBuildStepFactory::create(BuildStepList *parent, Core::Id id)
{
Q_UNUSED(id);
auto step = new CMakeBuildStep(parent);
if (parent->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN)
step->setBuildTarget(CMakeBuildStep::cleanTarget());
return step;
return new CMakeBuildStep(parent);
}
BuildStep *CMakeBuildStepFactory::clone(BuildStepList *parent, BuildStep *source)