diff options
author | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-01-09 13:42:57 +0100 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-01-11 03:35:34 +0100 |
commit | a90bb5b89a09490a1795064133f6d8ce33b6874e (patch) | |
tree | 5bf14095f73c7de73ccd8392972fee08cec48a1a | |
parent | cefaf61edac309216b7ff6c170602f5474aa1209 (diff) | |
download | qtbase-a90bb5b89a09490a1795064133f6d8ce33b6874e.tar.gz |
centralize/unify/sanitize INCLUDEPATH "enrichment"
instead of having each generator do its own magic (little surprisingly,
with different outcomes), add "stuff" to the search path in one place
used by all generators. this has several consequences:
- (unless disabled via CONFIG+=no_include_pwd) $$PWD is now consistently
prepended by all generators. most notably, this was entirely missing
from the MSVC generators (both nmake and VS) - despite them needing it
most. this also affects Xcode projects.
- $$OUT_PWD (if different from $$PWD) is now added right after $$PWD,
not at the end. this precedence clarification only makes sense, given
that qmake tries to make shadow builds as transparent as possible.
- the qmakespec's dir is now consistently appended. the UNIX and PBX
generators prepended it, while the rest already appended. few files
actually include qplatformdefs.h, so having it late in the search path
seems reasonable.
- the effect of CONFIG+=depend_includepath is now fully consistent with
the actual include path.
Change-Id: I5f7570183351ade29342ea74fef706a0738842bf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | qmake/generators/mac/pbuilder_pbx.cpp | 8 | ||||
-rw-r--r-- | qmake/generators/makefile.cpp | 28 | ||||
-rw-r--r-- | qmake/generators/unix/unixmake2.cpp | 6 | ||||
-rw-r--r-- | qmake/generators/win32/mingw_make.cpp | 8 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_vcproj.cpp | 1 | ||||
-rw-r--r-- | qmake/generators/win32/winmakefile.cpp | 3 |
6 files changed, 24 insertions, 30 deletions
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index f80c3e84c8..8f24c20712 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -739,11 +739,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) mkt << "DEFINES = " << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ") << varGlue("DEFINES","-D"," -D","") << endl; - mkt << "INCPATH = -I" << specdir(); - if(!project->isActiveConfig("no_include_pwd")) { - QString pwd = escapeFilePath(fileFixify(qmake_getpwd())); - mkt << " -I" << pwd; - } + mkt << "INCPATH ="; { const ProStringList &incs = project->values("INCLUDEPATH"); for (ProStringList::ConstIterator incit = incs.begin(); incit != incs.end(); ++incit) @@ -1495,7 +1491,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) t << "\t\t\t\t" << writeSettings("GCC_PRECOMPILE_PREFIX_HEADER", "YES") << ";\n" << "\t\t\t\t" << writeSettings("GCC_PREFIX_HEADER", escapeFilePath(project->first("PRECOMPILED_HEADER"))) << ";\n"; } - t << "\t\t\t\t" << writeSettings("HEADER_SEARCH_PATHS", fixListForOutput("INCLUDEPATH") + ProStringList(fixForOutput(specdir())), SettingsAsList, 5) << ";\n" + t << "\t\t\t\t" << writeSettings("HEADER_SEARCH_PATHS", fixListForOutput("INCLUDEPATH"), SettingsAsList, 5) << ";\n" << "\t\t\t\t" << writeSettings("LIBRARY_SEARCH_PATHS", fixListForOutput("QMAKE_PBX_LIBPATHS"), SettingsAsList, 5) << ";\n" << "\t\t\t\t" << writeSettings("FRAMEWORK_SEARCH_PATHS", fixListForOutput("QMAKE_FRAMEWORKPATH"), !project->values("QMAKE_FRAMEWORKPATH").isEmpty() ? SettingsAsList : 0, 5) << ";\n"; diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index e34b820a8b..804eab9ca7 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -444,6 +444,25 @@ MakefileGenerator::init() setSystemIncludes(v["QMAKE_DEFAULT_INCDIRS"]); + ProStringList &incs = project->values("INCLUDEPATH"); + if (!project->isActiveConfig("no_include_pwd")) { + if (Option::output_dir != qmake_getpwd()) { + // Pretend that the build dir is the source dir for #include purposes, + // consistently with the "transparent shadow builds" strategy. This is + // also consistent with #include "foo.h" falling back to #include <foo.h> + // behavior if it doesn't find the file in the source dir. + incs.prepend(Option::output_dir); + } + // This makes #include <foo.h> work if the header lives in the source dir. + // The benefit of that is questionable, as generally the user should use the + // correct include style, and extra compilers that put stuff in the source dir + // should add the dir themselves. + // More importantly, it makes #include "foo.h" work with MSVC when shadow-building, + // as this compiler looks files up relative to %CD%, not the source file's parent. + incs.prepend(qmake_getpwd()); + } + incs.append(project->specDir()); + const char * const cacheKeys[] = { "_QMAKE_STASH_", "_QMAKE_SUPER_CACHE_", 0 }; for (int i = 0; cacheKeys[i]; ++i) { if (v[cacheKeys[i]].isEmpty()) @@ -793,10 +812,6 @@ MakefileGenerator::init() ProStringList incDirs = v["DEPENDPATH"] + v["QMAKE_ABSOLUTE_SOURCE_PATH"]; if(project->isActiveConfig("depend_includepath")) incDirs += v["INCLUDEPATH"]; - if(!project->isActiveConfig("no_include_pwd")) { - QString pwd = qmake_getpwd(); - incDirs += pwd; - } QList<QMakeLocalFileName> deplist; for (ProStringList::Iterator it = incDirs.begin(); it != incDirs.end(); ++it) deplist.append(QMakeLocalFileName(unescapeFilePath((*it).toQString()))); @@ -848,11 +863,6 @@ MakefileGenerator::init() (*it) = Option::fixPathToLocalOS((*it).toQString()); } - if(!project->isActiveConfig("no_include_pwd")) { //get the output_dir into the pwd - if(Option::output_dir != qmake_getpwd()) - project->values("INCLUDEPATH").append("."); - } - //fix up the target deps static const char * const fixpaths[] = { "PRE_TARGETDEPS", "POST_TARGETDEPS", 0 }; for (int path = 0; fixpaths[path]; path++) { diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index 3f9df31a1c..469f23340d 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -184,11 +184,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) << varGlue("DEFINES","-D"," -D","") << endl; t << "CFLAGS = " << var("QMAKE_CFLAGS") << " $(DEFINES)\n"; t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " $(DEFINES)\n"; - t << "INCPATH = -I" << specdir(); - if(!project->isActiveConfig("no_include_pwd")) { - QString pwd = escapeFilePath(fileFixify(qmake_getpwd())); - t << " -I" << pwd; - } + t << "INCPATH ="; { QString isystem = var("QMAKE_CFLAGS_ISYSTEM"); const ProStringList &incs = project->values("INCLUDEPATH"); diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index 9bb5b1e416..f2d6678cdf 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -306,11 +306,6 @@ void MingwMakefileGenerator::writeIncPart(QTextStream &t) { t << "INCPATH = "; - if (!project->isActiveConfig("no_include_pwd")) { - QString pwd = escapeFilePath(fileFixify(qmake_getpwd())); - 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) { @@ -324,8 +319,7 @@ void MingwMakefileGenerator::writeIncPart(QTextStream &t) t << "-I"; t << quote << inc << quote << " "; } - t << "-I" << quote << specdir() << quote - << endl; + t << endl; } void MingwMakefileGenerator::writeLibsPart(QTextStream &t) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index f271eb0679..e3031d559c 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1688,7 +1688,6 @@ void VcprojGenerator::initOld() inc = QString("\"%1\"").arg(inc); // Quote all paths if not quoted already project->values("MSVCPROJ_INCPATH").append("-I" + inc); } - project->values("MSVCPROJ_INCPATH").append("-I" + specdir()); QString dest = Option::fixPathToTargetOS(project->first("TARGET").toQString()) + project->first("TARGET_EXT"); project->values("MSVCPROJ_TARGET") = ProStringList(dest); diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 663665897b..3a2e146a33 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -606,8 +606,7 @@ void Win32MakefileGenerator::writeIncPart(QTextStream &t) if(!inc.isEmpty()) t << "-I\"" << inc << "\" "; } - t << "-I\"" << specdir() << "\"" - << endl; + t << endl; } void Win32MakefileGenerator::writeStandardParts(QTextStream &t) |