From b7755b18c3656faa5bab042067d476fe70636f9c Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 22 May 2019 15:59:07 +0200 Subject: [PATCH] RemoteLinux: Add explanatory message on MakeInstallStep failure ... for the case of a cmake project without an install target. Change-Id: I599a10bc0683706dc7ced1e46e0adcdb9a44d6b7 Reviewed-by: hjk --- src/plugins/remotelinux/makeinstallstep.cpp | 20 ++++++++++++++++++++ src/plugins/remotelinux/makeinstallstep.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/src/plugins/remotelinux/makeinstallstep.cpp b/src/plugins/remotelinux/makeinstallstep.cpp index 7375de150c0..25d41289417 100644 --- a/src/plugins/remotelinux/makeinstallstep.cpp +++ b/src/plugins/remotelinux/makeinstallstep.cpp @@ -25,6 +25,7 @@ #include "makeinstallstep.h" +#include #include #include #include @@ -141,6 +142,12 @@ bool MakeInstallStep::init() env.set(it.key(), it.value()); processParameters()->setEnvironment(env); } + m_noInstallTarget = false; + const auto buildStep = buildConfiguration() + ->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD) + ->firstOfType(); + m_isCmakeProject = buildStep && buildStep->processParameters()->command().toString() + .contains("cmake"); return true; } @@ -157,10 +164,23 @@ void MakeInstallStep::finish(bool success) fi.dir().path().mid(installRoot().toString().length())); } target()->setDeploymentData(m_deploymentData); + } else if (m_noInstallTarget && m_isCmakeProject) { + emit addTask(Task(Task::Warning, tr("You need to add an install statement to your " + "CMakeLists.txt file for deployment to work."), + FileName(), -1, ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT)); } MakeStep::finish(success); } +void MakeInstallStep::stdError(const QString &line) +{ + // When using Makefiles: "No rule to make target 'install'" + // When using ninja: "ninja: error: unknown target 'install'" + if (line.contains("target 'install'")) + m_noInstallTarget = true; + MakeStep::stdError(line); +} + FileName MakeInstallStep::installRoot() const { return static_cast(aspect(InstallRootAspectId))->fileName(); diff --git a/src/plugins/remotelinux/makeinstallstep.h b/src/plugins/remotelinux/makeinstallstep.h index e9c4e9e25d1..c6a0fd5fff9 100644 --- a/src/plugins/remotelinux/makeinstallstep.h +++ b/src/plugins/remotelinux/makeinstallstep.h @@ -47,6 +47,7 @@ private: ProjectExplorer::BuildStepConfigWidget * createConfigWidget() override; bool init() override; void finish(bool success) override; + void stdError(const QString &line) override; Utils::FileName installRoot() const; bool cleanInstallRoot() const; @@ -56,6 +57,8 @@ private: void updateFullCommandLine(); ProjectExplorer::DeploymentData m_deploymentData; + bool m_noInstallTarget = false; + bool m_isCmakeProject = false; }; } // namespace Internal