From 88ffd777851c4617ce131bc1efaccc6960c25c4c Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Wed, 10 Aug 2011 12:13:31 +0200
Subject: [PATCH] Add absolute paths to environment.

Change-Id: I0f23f8d372f3ceb3d4af301196e6fdea5f969998
Reviewed-on: http://codereview.qt.nokia.com/2819
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
---
 .../qt-desktop/qt4runconfiguration.cpp         | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp
index 6ffa52e8699..25048dea339 100644
--- a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp
+++ b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp
@@ -66,6 +66,8 @@
 #include <QtGui/QCheckBox>
 #include <QtGui/QToolButton>
 #include <QtGui/QComboBox>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDir>
 
 using namespace Qt4ProjectManager::Internal;
 using namespace Qt4ProjectManager;
@@ -607,9 +609,19 @@ Utils::Environment Qt4RunConfiguration::baseEnvironment() const
     // to find those libraries while actually running we explicitly prepend those
     // dirs to the library search path
     const Qt4ProFileNode *node = qt4Target()->qt4Project()->rootProjectNode()->findProFileFor(m_proFilePath);
-    if (node)
-        foreach(const QString &dir, node->variableValue(LibDirectoriesVar))
-            env.prependOrSetLibrarySearchPath(dir);
+    if (node) {
+        const QStringList libDirectories = node->variableValue(LibDirectoriesVar);
+        if (!libDirectories.isEmpty()) {
+            const QString proDirectory = QFileInfo(node->path()).absolutePath();
+            foreach (QString dir, libDirectories) {
+                // Fix up relative entries like "LIBS+=-L.."
+                const QFileInfo fi(dir);
+                if (!fi.isAbsolute())
+                    dir = QDir::cleanPath(proDirectory + QLatin1Char('/') + dir);
+                env.prependOrSetLibrarySearchPath(dir);
+            } // foreach
+        } // libDirectories
+    } // node
     return env;
 }
 
-- 
GitLab