CMake: Do not forget "current executable" build target

Do not forget to build the current executable target when there is a change
of available build targets.

Task-number: QTCREATORBUG-16131
Change-Id: I7fb0dfcd06cdbe3d23dbd194ed27fd3825068c62
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2016-04-22 15:54:16 +02:00
parent 728229690a
commit e8b538985d

View File

@@ -70,6 +70,11 @@ const char ADD_RUNCONFIGURATION_ARGUMENT_KEY[] = "CMakeProjectManager.MakeStep.A
const char ADD_RUNCONFIGURATION_TEXT[] = "Current executable"; const char ADD_RUNCONFIGURATION_TEXT[] = "Current executable";
} }
static bool isCurrentExecutableTarget(const QString &target)
{
return target == QLatin1String(ADD_RUNCONFIGURATION_TEXT);
}
CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl) : AbstractProcessStep(bsl, Core::Id(MS_ID)) CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl) : AbstractProcessStep(bsl, Core::Id(MS_ID))
{ {
ctor(bsl); ctor(bsl);
@@ -124,9 +129,9 @@ CMakeRunConfiguration *CMakeBuildStep::targetsActiveRunConfiguration() const
void CMakeBuildStep::handleBuildTargetChanges() void CMakeBuildStep::handleBuildTargetChanges()
{ {
if (static_cast<CMakeProject *>(project())->buildTargetTitles().contains(m_buildTarget)) if (isCurrentExecutableTarget(m_buildTarget))
setBuildTarget(m_buildTarget); return; // Do not change just because a different set of build targets is there...
else if (!static_cast<CMakeProject *>(project())->buildTargetTitles().contains(m_buildTarget))
setBuildTarget(CMakeBuildStep::allTarget()); setBuildTarget(CMakeBuildStep::allTarget());
emit buildTargetsChanged(); emit buildTargetsChanged();
} }
@@ -180,7 +185,7 @@ bool CMakeBuildStep::init(QList<const BuildStep *> &earlierSteps)
} }
CMakeRunConfiguration *rc = targetsActiveRunConfiguration(); CMakeRunConfiguration *rc = targetsActiveRunConfiguration();
if ((m_buildTarget == QLatin1String(ADD_RUNCONFIGURATION_TEXT)) && (!rc || rc->title().isEmpty())) { if (isCurrentExecutableTarget(m_buildTarget) && (!rc || rc->title().isEmpty())) {
emit addTask(Task(Task::Error, emit addTask(Task(Task::Error,
QCoreApplication::translate("ProjectExplorer::Task", QCoreApplication::translate("ProjectExplorer::Task",
"You asked to build the current Run Configuration's build target only, " "You asked to build the current Run Configuration's build target only, "
@@ -336,7 +341,7 @@ QString CMakeBuildStep::allArguments(const CMakeRunConfiguration *rc) const
QString target; QString target;
if (m_buildTarget == QLatin1String(ADD_RUNCONFIGURATION_TEXT)) { if (isCurrentExecutableTarget(m_buildTarget)) {
if (rc) if (rc)
target = rc->title(); target = rc->title();
else else