diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 343c6f5f7b1cb1ad49dbf5da29c4b2679313cbe3..9b3eccdf10a25c48b3e332f52636b58e0421aff0 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -921,8 +921,11 @@ ProFileReader *Qt4Project::createProFileReader(Qt4ProFileNode *qt4ProFileNode) if (activeTarget() && activeTarget()->activeBuildConfiguration()) { QtVersion *version = activeTarget()->activeBuildConfiguration()->qtVersion(); - if (version->isValid()) + if (version->isValid()) { m_proFileOption->properties = version->versionInfo(); + m_proFileOption->sysroot + = activeTarget()->activeBuildConfiguration()->toolChain()->sysroot(); + } } ProFileCacheManager::instance()->incRefCount(); diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 46124e62295960a132df24381007692089074f45..3b3771426dd511f1f24b7d9fb15ec62398ea37f3 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -216,6 +216,8 @@ public: QStringList qmakeMkspecPaths() const; QStringList qmakeFeaturePaths() const; + QString sysrootify(const QString &path, const QString &baseDir) const; + int m_skipLevel; int m_loopLevel; // To report unexpected break() and next()s bool m_cumulative; @@ -1468,6 +1470,13 @@ QString ProFileEvaluator::Private::currentDirectory() const return cur->directoryName(); } +QString ProFileEvaluator::Private::sysrootify(const QString &path, const QString &baseDir) const +{ + const bool isHostSystemPath = m_option->sysroot.isEmpty() || path.startsWith(m_option->sysroot) + || path.startsWith(baseDir) || path.startsWith(m_outputDir); + return isHostSystemPath ? path : m_option->sysroot + path; +} + // The (QChar*)current->constData() constructs below avoid pointless detach() calls // FIXME: This is inefficient. Should not make new string if it is a straight subsegment static ALWAYS_INLINE void appendChar(ushort unicode, @@ -3147,7 +3156,8 @@ QStringList ProFileEvaluator::absolutePathValues( { QStringList result; foreach (const QString &el, values(variable)) { - QString absEl = IoUtils::resolvePath(baseDirectory, el); + QString absEl = IoUtils::isAbsolutePath(el) + ? d->sysrootify(el, baseDirectory) : IoUtils::resolvePath(baseDirectory, el); if (IoUtils::fileType(absEl) == IoUtils::FileIsDir) result << QDir::cleanPath(absEl); } @@ -3162,11 +3172,12 @@ QStringList ProFileEvaluator::absoluteFileValues( foreach (const QString &el, pro ? values(variable, pro) : values(variable)) { QString absEl; if (IoUtils::isAbsolutePath(el)) { - if (IoUtils::exists(el)) { - result << QDir::cleanPath(el); + const QString elWithSysroot = d->sysrootify(el, baseDirectory); + if (IoUtils::exists(elWithSysroot)) { + result << QDir::cleanPath(elWithSysroot); goto next; } - absEl = el; + absEl = elWithSysroot; } else { foreach (const QString &dir, searchDirs) { QString fn = dir + QLatin1Char('/') + el; diff --git a/src/shared/proparser/profileevaluator.h b/src/shared/proparser/profileevaluator.h index 917a32ffbb8f68d59640be8ca4e6d2791bbbb17e..5ad5f8cf86815fb5456c2bec0a04d6811056de14 100644 --- a/src/shared/proparser/profileevaluator.h +++ b/src/shared/proparser/profileevaluator.h @@ -173,6 +173,7 @@ struct ProFileOption QString qmakespec; QString cachefile; QHash<QString, QString> properties; + QString sysroot; enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE, TARG_MAC9_MODE, TARG_QNX6_MODE }; TARG_MODE target_mode;