Commit e8b53898 authored by Tobias Hunger's avatar Tobias Hunger

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: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent 72822969
......@@ -70,6 +70,11 @@ const char ADD_RUNCONFIGURATION_ARGUMENT_KEY[] = "CMakeProjectManager.MakeStep.A
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))
{
ctor(bsl);
......@@ -124,9 +129,9 @@ CMakeRunConfiguration *CMakeBuildStep::targetsActiveRunConfiguration() const
void CMakeBuildStep::handleBuildTargetChanges()
{
if (static_cast<CMakeProject *>(project())->buildTargetTitles().contains(m_buildTarget))
setBuildTarget(m_buildTarget);
else
if (isCurrentExecutableTarget(m_buildTarget))
return; // Do not change just because a different set of build targets is there...
if (!static_cast<CMakeProject *>(project())->buildTargetTitles().contains(m_buildTarget))
setBuildTarget(CMakeBuildStep::allTarget());
emit buildTargetsChanged();
}
......@@ -180,7 +185,7 @@ bool CMakeBuildStep::init(QList<const BuildStep *> &earlierSteps)
}
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,
QCoreApplication::translate("ProjectExplorer::Task",
"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;
if (m_buildTarget == QLatin1String(ADD_RUNCONFIGURATION_TEXT)) {
if (isCurrentExecutableTarget(m_buildTarget)) {
if (rc)
target = rc->title();
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment