From 83d5461c7f083277ee5948b6b4bbbd93b63415dc Mon Sep 17 00:00:00 2001
From: dt <qtc-commiter@nokia.com>
Date: Mon, 8 Dec 2008 12:44:28 +0100
Subject: [PATCH] Fixes:    Find the qplatformdefs.h file

Task:     -
RevBy:    -
AutoTest: -
Details:  Add the include path for qplatformdefs.h to the fot.
---
 .../cmakeprojectmanager/cmakeproject.cpp      |  2 +-
 src/plugins/qt4projectmanager/qt4project.cpp  |  3 ++
 .../qt4projectmanager/qtversionmanager.cpp    | 47 +++++++++++--------
 .../qt4projectmanager/qtversionmanager.h      |  2 +
 4 files changed, 33 insertions(+), 21 deletions(-)

diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 4eb31302e65..52c28cbc3d5 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -226,7 +226,7 @@ QStringList CMakeProject::files(FilesMode fileMode) const
 void CMakeProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer)
 {
     // TODO
-    Q_UNUSED(writer)
+    Q_UNUSED(writer);
 }
 
 void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp
index 501068af004..2e06e1ae4e5 100644
--- a/src/plugins/qt4projectmanager/qt4project.cpp
+++ b/src/plugins/qt4projectmanager/qt4project.cpp
@@ -474,6 +474,9 @@ void Qt4Project::updateCodeModel()
         }
     }
 
+    // Add mkspec directory
+    allIncludePaths.append(qtVersion(activeBuildConfiguration())->mkspecPath());
+
     QStringList files;
     files += m_projectFiles->files[HeaderType];
     files += m_projectFiles->generatedFiles[HeaderType];
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp
index 0c68fcd98eb..1262f901785 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.cpp
+++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp
@@ -728,6 +728,12 @@ QString QtVersion::mkspec() const
     return m_mkspec;
 }
 
+QString QtVersion::mkspecPath() const
+{
+    updateMkSpec();
+    return m_mkspecFullPath;
+}
+
 QHash<QString,QString> QtVersion::versionInfo() const
 {
     updateVersionInfo();
@@ -1023,24 +1029,24 @@ void QtVersion::updateMkSpec() const
     //qDebug()<<"Finding mkspec for"<<path();
 
     QString mkspec;
-    QFile f(path() + "/.qmake.cache");
-    if (f.exists() && f.open(QIODevice::ReadOnly)) {
-        while(!f.atEnd()) {
-            QByteArray line = f.readLine();
-            if(line.startsWith("QMAKESPEC")) {
-                const QList<QByteArray> &temp = line.split('=');
-                if(temp.size() == 2) {
-                    mkspec = temp.at(1).trimmed();
-                    if (mkspec.startsWith("$$QT_BUILD_TREE/mkspecs/"))
-                        mkspec = mkspec.mid(QString("$$QT_BUILD_TREE/mkspecs/").length());
-                    else if (mkspec.startsWith("$$QT_BUILD_TREE\\mkspecs\\"))
-                        mkspec = mkspec.mid(QString("$$QT_BUILD_TREE\\mkspecs\\").length());
-                }
-                break;
-            }
-        }
-        f.close();
-    } else {
+//    QFile f(path() + "/.qmake.cache");
+//    if (f.exists() && f.open(QIODevice::ReadOnly)) {
+//        while(!f.atEnd()) {
+//            QByteArray line = f.readLine();
+//            if(line.startsWith("QMAKESPEC")) {
+//                const QList<QByteArray> &temp = line.split('=');
+//                if(temp.size() == 2) {
+//                    mkspec = temp.at(1).trimmed();
+//                    if (mkspec.startsWith("$$QT_BUILD_TREE/mkspecs/"))
+//                        mkspec = mkspec.mid(QString("$$QT_BUILD_TREE/mkspecs/").length());
+//                    else if (mkspec.startsWith("$$QT_BUILD_TREE\\mkspecs\\"))
+//                        mkspec = mkspec.mid(QString("$$QT_BUILD_TREE\\mkspecs\\").length());
+//                }
+//                break;
+//            }
+//        }
+//        f.close();
+//    } else {
         // no .qmake.cache so look at the default mkspec
         QString mkspecPath = versionInfo().value("QMAKE_MKSPECS");
         if (mkspecPath.isEmpty())
@@ -1095,9 +1101,10 @@ void QtVersion::updateMkSpec() const
             mkspec = f2.symLinkTarget();
         }
 #endif
-    }
+//    }
 
-    int index =mkspec.lastIndexOf('/');
+    m_mkspecFullPath = mkspec;
+    int index = mkspec.lastIndexOf('/');
     if(index == -1)
         index = mkspec.lastIndexOf('\\');
     if (index >= 0 && QDir(mkspec.left(index)).canonicalPath() == QDir(m_path + "/mkspecs/").canonicalPath())
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h
index 5810cfa1c2d..a8ca9570895 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.h
+++ b/src/plugins/qt4projectmanager/qtversionmanager.h
@@ -67,6 +67,7 @@ public:
     QString path() const;
     QString sourcePath() const;
     QString mkspec() const;
+    QString mkspecPath() const;
     QString makeCommand() const;
     QString qmakeCommand() const;
     // Returns the PREFIX, BINPREFIX, DOCPREFIX and similar information
@@ -107,6 +108,7 @@ private:
     QString m_path;
     QString m_sourcePath;
     mutable QString m_mkspec; // updated lazily
+    mutable QString m_mkspecFullPath;
     QString m_mingwDirectory;
     QString m_prependPath;
     QString m_msvcVersion;
-- 
GitLab