summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
Diffstat (limited to 'qmake')
-rw-r--r--qmake/generators/makefile.cpp2
-rw-r--r--qmake/generators/makefiledeps.cpp24
-rw-r--r--qmake/generators/makefiledeps.h6
-rw-r--r--qmake/generators/unix/unixmake2.cpp8
-rw-r--r--qmake/generators/win32/mingw_make.cpp8
5 files changed, 46 insertions, 2 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index ac8bd8f9a7..83d38d1b14 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -456,6 +456,8 @@ MakefileGenerator::init()
if (v["QMAKE_LINK_O_FLAG"].isEmpty())
v["QMAKE_LINK_O_FLAG"].append("-o ");
+ setSystemIncludes(v["QMAKE_DEFAULT_INCDIRS"]);
+
ProStringList &quc = v["QMAKE_EXTRA_COMPILERS"];
//make sure the COMPILERS are in the correct input/output chain order
diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp
index df37957f9b..e1fb42e0a4 100644
--- a/qmake/generators/makefiledeps.cpp
+++ b/qmake/generators/makefiledeps.cpp
@@ -345,6 +345,30 @@ bool QMakeSourceFileInfo::containsSourceFile(const QString &f, SourceFileType ty
return false;
}
+bool QMakeSourceFileInfo::isSystemInclude(const QString &name)
+{
+ if (QDir::isRelativePath(name)) {
+ // if we got a relative path here, it's either an -I flag with a relative path
+ // or an include file we couldn't locate. Either way, conclude it's not
+ // a system include.
+ return false;
+ }
+
+ for (int i = 0; i < systemIncludes.size(); ++i) {
+ // check if name is located inside the system include dir:
+ QDir systemDir(systemIncludes.at(i));
+ QString relativePath = systemDir.relativeFilePath(name);
+
+ // the relative path might be absolute if we're crossing drives on Windows
+ if (QDir::isAbsolutePath(relativePath) || relativePath.startsWith("../"))
+ continue;
+ debug_msg(5, "File/dir %s is in system dir %s, skipping",
+ qPrintable(name), qPrintable(systemIncludes.at(i)));
+ return true;
+ }
+ return false;
+}
+
char *QMakeSourceFileInfo::getBuffer(int s) {
if(!spare_buffer || spare_buffer_size < s)
spare_buffer = (char *)realloc(spare_buffer, spare_buffer_size=s);
diff --git a/qmake/generators/makefiledeps.h b/qmake/generators/makefiledeps.h
index ba55c36998..516abd4afd 100644
--- a/qmake/generators/makefiledeps.h
+++ b/qmake/generators/makefiledeps.h
@@ -78,6 +78,7 @@ private:
SourceFiles *files, *includes;
bool files_changed;
QList<QMakeLocalFileName> depdirs;
+ QStringList systemIncludes;
//sleezy buffer code
char *spare_buffer;
@@ -98,6 +99,7 @@ protected:
virtual QFileInfo findFileInfo(const QMakeLocalFileName &);
public:
+
QMakeSourceFileInfo(const QString &cachefile="");
virtual ~QMakeSourceFileInfo();
@@ -108,11 +110,15 @@ public:
inline void setDependencyMode(DependencyMode mode) { dep_mode = mode; }
inline DependencyMode dependencyMode() const { return dep_mode; }
+ void setSystemIncludes(const ProStringList &list)
+ { systemIncludes = list.toQStringList(); }
+
enum SourceFileType { TYPE_UNKNOWN, TYPE_C, TYPE_UI, TYPE_QRC };
enum SourceFileSeek { SEEK_DEPS=0x01, SEEK_MOCS=0x02 };
void addSourceFiles(const ProStringList &, uchar seek, SourceFileType type=TYPE_C);
void addSourceFile(const QString &, uchar seek, SourceFileType type=TYPE_C);
bool containsSourceFile(const QString &, SourceFileType type=TYPE_C);
+ bool isSystemInclude(const QString &);
int included(const QString &file);
QStringList dependencies(const QString &file);
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
index 1444161ca9..8e18f69c03 100644
--- a/qmake/generators/unix/unixmake2.cpp
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -125,10 +125,16 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << " -I" << pwd;
}
{
+ QString isystem = var("QMAKE_CFLAGS_ISYSTEM");
const ProStringList &incs = project->values("INCLUDEPATH");
for(int i = 0; i < incs.size(); ++i) {
ProString inc = escapeFilePath(incs.at(i));
- if(!inc.isEmpty())
+ if (inc.isEmpty())
+ continue;
+
+ if (!isystem.isEmpty() && isSystemInclude(inc.toQString()))
+ t << ' ' << isystem << ' ' << inc;
+ else
t << " -I" << inc;
}
}
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
index 1aeaef1d23..6d5764f59c 100644
--- a/qmake/generators/win32/mingw_make.cpp
+++ b/qmake/generators/win32/mingw_make.cpp
@@ -321,12 +321,18 @@ void MingwMakefileGenerator::writeIncPart(QTextStream &t)
t << "-I" << pwd << " ";
}
+ QString isystem = var("QMAKE_CFLAGS_ISYSTEM");
const ProStringList &incs = project->values("INCLUDEPATH");
for (ProStringList::ConstIterator incit = incs.begin(); incit != incs.end(); ++incit) {
QString inc = (*incit).toQString();
inc.replace(QRegExp("\\\\$"), "");
inc.replace(QRegExp("\""), "");
- t << "-I" << quote << inc << quote << " ";
+
+ if (!isystem.isEmpty() && isSystemInclude(inc))
+ t << isystem << ' ';
+ else
+ t << "-I";
+ t << quote << inc << quote << " ";
}
t << "-I" << quote << specdir() << quote
<< endl;