From deff5ac20fdddc80df6a423230ebbcc96260f807 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Date: Fri, 27 Mar 2009 20:45:53 +0100
Subject: [PATCH] re-use pre-existing builds

run "cmake . [...]" if a build already exists in the build dir. this
saves the user from reproducing all the arguments he may need.

on the downside, this will go utterly awry if the source dir of the
existing build is a different one than known to creator. this should be
a rather rare corner case, so ignore it for now. the nice solution would
be a checkbox (on by default) to request this new behavior.
---
 src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
index 0f92c8a53ff..959bc243097 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
@@ -116,10 +116,11 @@ QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QStrin
 #ifdef Q_OS_WIN
     QString generator = "-GCodeBlocks - MinGW Makefiles";
 #else // Q_OS_WIN
-   QString generator = "-GCodeBlocks - Unix Makefiles";
+    QString generator = "-GCodeBlocks - Unix Makefiles";
 #endif // Q_OS_WIN
-    qDebug()<<cmakeExecutable()<<sourceDirectory << arguments<<generator;
-    cmake->start(cmakeExecutable(), QStringList() << sourceDirectory << arguments << generator);
+    QString srcdir = buildDirectory.exists("CMakeCache.txt") ? QString(".") : sourceDirectory;
+    qDebug()<<cmakeExecutable()<<srcdir<<arguments<<generator;
+    cmake->start(cmakeExecutable(), QStringList() << srcdir << arguments << generator);
     return cmake;
 }
 
-- 
GitLab