From 0a406dbe1fbfad1c3e19c0e85561ae742f69eeaf Mon Sep 17 00:00:00 2001
From: dt <qtc-committer@nokia.com>
Date: Tue, 7 Apr 2009 15:00:16 +0200
Subject: [PATCH] Add a makestep that cleans up

Make clean and rebuild all work.
---
 src/plugins/cmakeprojectmanager/cmakeproject.cpp |  4 ++++
 src/plugins/cmakeprojectmanager/makestep.cpp     | 12 ++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index b66ebb70c6a..d1fe107412d 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -506,6 +506,10 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
         if (!copw.buildDirectory().isEmpty())
             setValue("all", "buildDirectory", copw.buildDirectory());
         //TODO save arguments somewhere copw.arguments()
+
+        MakeStep *cleanMakeStep = new MakeStep(this);
+        insertCleanStep(0, cleanMakeStep);
+        cleanMakeStep->setValue("clean", true);
     } else {
         // We have a user file, but we could still be missing the cbp file
         // TODO check that we have a cbp file and if not, open up a dialog ?
diff --git a/src/plugins/cmakeprojectmanager/makestep.cpp b/src/plugins/cmakeprojectmanager/makestep.cpp
index 83e433c0ca6..8209f3fc48d 100644
--- a/src/plugins/cmakeprojectmanager/makestep.cpp
+++ b/src/plugins/cmakeprojectmanager/makestep.cpp
@@ -99,10 +99,14 @@ bool MakeStep::init(const QString &buildConfiguration)
     setCommand(buildConfiguration, "make"); // TODO give full path here?
 #endif // Q_OS_WIN
 
-    QStringList arguments = value(buildConfiguration, "buildTargets").toStringList();
-    arguments << additionalArguments(buildConfiguration);
-    setArguments(buildConfiguration, arguments); // TODO
-    setEnvironment(buildConfiguration, m_pro->environment(buildConfiguration));
+    if (value("clean").isValid() && value("clean").toBool())  {
+       setArguments(buildConfiguration, QStringList() << "clean");
+   } else {
+        QStringList arguments = value(buildConfiguration, "buildTargets").toStringList();
+        arguments << additionalArguments(buildConfiguration);
+        setArguments(buildConfiguration, arguments); // TODO
+        setEnvironment(buildConfiguration, m_pro->environment(buildConfiguration));
+    }
     return AbstractProcessStep::init(buildConfiguration);
 }
 
-- 
GitLab