summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
Diffstat (limited to 'qmake')
-rw-r--r--qmake/Makefile.win322
-rw-r--r--qmake/doc/src/qmake-manual.qdoc17
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp10
-rw-r--r--qmake/generators/makefile.cpp30
-rw-r--r--qmake/generators/unix/unixmake2.cpp15
-rw-r--r--qmake/generators/win32/mingw_make.cpp10
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp1
-rw-r--r--qmake/generators/win32/winmakefile.cpp8
-rw-r--r--qmake/library/qmakeevaluator.cpp57
9 files changed, 87 insertions, 63 deletions
diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32
index a049b28b5f..e1c2d98f06 100644
--- a/qmake/Makefile.win32
+++ b/qmake/Makefile.win32
@@ -40,7 +40,7 @@ CFLAGS_BARE = -c -Fo./ -Fdqmake.pdb \
-DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS \
-DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \
-DUNICODE -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_JSON_READONLY -DQT_NO_STANDARDPATHS
-CFLAGS = -Yuqmake_pch.h -FIqmake_pch.h -Fpqmake_pch.pch $(CFLAGS_BARE) $(CFLAGS) $(EXTRA_CPPFLAGS)
+CFLAGS = -Yuqmake_pch.h -FIqmake_pch.h -Fpqmake_pch.pch $(CFLAGS_BARE) $(CFLAGS)
CXXFLAGS_BARE = $(CFLAGS_BARE)
CXXFLAGS = $(CFLAGS)
diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc
index 202df7e03c..b78a742999 100644
--- a/qmake/doc/src/qmake-manual.qdoc
+++ b/qmake/doc/src/qmake-manual.qdoc
@@ -122,10 +122,10 @@
configuration options to fine tune the build process. For more information,
see \l{Building Common Project Types}.
- You can use the \l{external: Qt Creator Manual}{Qt Creator} new project
- wizard to create the project file. You choose the project template, and Qt
- Creator creates a project file with default values that enable you to build
- and run the project. You can modify the project file to suit your purposes.
+ You can use the \l{Qt Creator: Creating Projects}{Qt Creator new project wizard} to create the project file.
+ You choose the project template, and Qt Creator creates a project file with
+ default values that enable you to build and run the project. You can modify
+ the project file to suit your purposes.
You can also use qmake to generate project files. For a full description of
qmake command line options, see \l{Running qmake}.
@@ -1464,6 +1464,15 @@
executable needs to be specified as long as it is on a path contained
in the \c PATH variable when the Makefile is processed.
+ \section1 QMAKE_CFLAGS
+
+ Specifies the C compiler flags for building
+ a project. The value of this variable is typically handled by
+ qmake or \l{#QMAKESPEC}{qmake.conf} and rarely
+ needs to be modified. The flags specific to debug and release modes can be
+ adjusted by modifying the \c QMAKE_CFLAGS_DEBUG and
+ \c QMAKE_CFLAGS_RELEASE variables, respectively.
+
\target QMAKE_CFLAGS_DEBUG
\section1 QMAKE_CFLAGS_DEBUG
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp
index 0ff42500de..8f24c20712 100644
--- a/qmake/generators/mac/pbuilder_pbx.cpp
+++ b/qmake/generators/mac/pbuilder_pbx.cpp
@@ -739,13 +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()));
- if(pwd.isEmpty())
- pwd = ".";
- mkt << " -I" << pwd;
- }
+ mkt << "INCPATH =";
{
const ProStringList &incs = project->values("INCLUDEPATH");
for (ProStringList::ConstIterator incit = incs.begin(); incit != incs.end(); ++incit)
@@ -1497,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 3b807c4ccf..a9f22d8597 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,12 +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();
- if(pwd.isEmpty())
- pwd = ".";
- incDirs += pwd;
- }
QList<QMakeLocalFileName> deplist;
for (ProStringList::Iterator it = incDirs.begin(); it != incDirs.end(); ++it)
deplist.append(QMakeLocalFileName(unescapeFilePath((*it).toQString())));
@@ -850,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 8270f02feb..469f23340d 100644
--- a/qmake/generators/unix/unixmake2.cpp
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -184,13 +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()));
- if(pwd.isEmpty())
- pwd = ".";
- t << " -I" << pwd;
- }
+ t << "INCPATH =";
{
QString isystem = var("QMAKE_CFLAGS_ISYSTEM");
const ProStringList &incs = project->values("INCLUDEPATH");
@@ -1019,8 +1013,9 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << "\t-$(DEL_FILE) -r " << bundlePath << endl;
} else if(project->isActiveConfig("compile_libtool")) {
t << "\t-$(LIBTOOL) --mode=clean $(DEL_FILE) $(TARGET)\n";
- } else if(!project->isActiveConfig("staticlib") && project->values("QMAKE_APP_FLAG").isEmpty() &&
- !project->isActiveConfig("plugin")) {
+ } else if (project->isActiveConfig("staticlib")) {
+ t << "\t-$(DEL_FILE) " << destdir << "$(TARGET) \n";
+ } else if (project->values("QMAKE_APP_FLAG").isEmpty() && !project->isActiveConfig("plugin")) {
t << "\t-$(DEL_FILE) " << destdir << "$(TARGET) \n";
if (!project->isActiveConfig("unversioned_libname")) {
t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) "
@@ -1029,7 +1024,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << "\t-$(DEL_FILE) $(TARGETA)\n";
}
} else {
- t << "\t-$(DEL_FILE) " << destdir << "$(TARGET) \n";
+ t << "\t-$(DEL_FILE) $(TARGET) \n";
}
t << varGlue("QMAKE_DISTCLEAN","\t-$(DEL_FILE) "," ","\n");
{
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
index 42431f0131..247c53986e 100644
--- a/qmake/generators/win32/mingw_make.cpp
+++ b/qmake/generators/win32/mingw_make.cpp
@@ -311,13 +311,6 @@ void MingwMakefileGenerator::writeIncPart(QTextStream &t)
{
t << "INCPATH = ";
- if (!project->isActiveConfig("no_include_pwd")) {
- QString pwd = escapeFilePath(fileFixify(qmake_getpwd()));
- if (pwd.isEmpty())
- pwd = ".";
- 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) {
@@ -331,8 +324,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 61c0cda89e..4c228be310 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -1620,7 +1620,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 b6bcdbf366..a0b5a7f35f 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -546,12 +546,13 @@ void Win32MakefileGenerator::writeCleanParts(QTextStream &t)
const QString del_statement("-$(DEL_FILE)");
if(project->isActiveConfig("no_delete_multiple_files")) {
for (ProStringList::ConstIterator it = list.begin(); it != list.end(); ++it)
- t << "\n\t" << del_statement << " " << escapeFilePath((*it));
+ t << "\n\t" << del_statement
+ << ' ' << escapeFilePath(Option::fixPathToTargetOS((*it).toQString()));
} else {
QString files, file;
const int commandlineLimit = 2047; // NT limit, expanded
for (ProStringList::ConstIterator it = list.begin(); it != list.end(); ++it) {
- file = " " + escapeFilePath((*it));
+ file = ' ' + escapeFilePath(Option::fixPathToTargetOS((*it).toQString()));
if(del_statement.length() + files.length() +
qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit) {
t << "\n\t" << del_statement << files;
@@ -614,8 +615,7 @@ void Win32MakefileGenerator::writeIncPart(QTextStream &t)
if(!inc.isEmpty())
t << "-I\"" << inc << "\" ";
}
- t << "-I\"" << specdir() << "\""
- << endl;
+ t << endl;
}
void Win32MakefileGenerator::writeStandardParts(QTextStream &t)
diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp
index e6d666f1b7..68304c2030 100644
--- a/qmake/library/qmakeevaluator.cpp
+++ b/qmake/library/qmakeevaluator.cpp
@@ -980,6 +980,45 @@ void QMakeEvaluator::setTemplate()
}
}
+#if defined(Q_CC_MSVC)
+static ProString msvcBinDirToQMakeArch(QString subdir)
+{
+ int idx = subdir.indexOf(QLatin1Char('\\'));
+ if (idx == -1)
+ return ProString("x86");
+ subdir.remove(0, idx + 1);
+ idx = subdir.indexOf(QLatin1Char('_'));
+ if (idx >= 0)
+ subdir.remove(0, idx + 1);
+ subdir = subdir.toLower();
+ if (subdir == QStringLiteral("amd64"))
+ return ProString("x86_64");
+ return ProString(subdir);
+}
+
+static ProString defaultMsvcArchitecture()
+{
+ return ProString("x86");
+}
+
+static ProString msvcArchitecture(const QString &vcInstallDir, const QString &pathVar)
+{
+ if (vcInstallDir.isEmpty())
+ return defaultMsvcArchitecture();
+ QString vcBinDir = vcInstallDir;
+ if (vcBinDir.endsWith(QLatin1Char('\\')))
+ vcBinDir.chop(1);
+ foreach (const QString &dir, pathVar.split(QLatin1Char(';'))) {
+ if (!dir.startsWith(vcBinDir, Qt::CaseInsensitive))
+ continue;
+ const ProString arch = msvcBinDirToQMakeArch(dir.mid(vcBinDir.length() + 1));
+ if (!arch.isEmpty())
+ return arch;
+ }
+ return defaultMsvcArchitecture();
+}
+#endif // defined(Q_CC_MSVC)
+
void QMakeEvaluator::loadDefaults()
{
ProValueMap &vars = m_valuemapStack.top();
@@ -1041,21 +1080,9 @@ void QMakeEvaluator::loadDefaults()
vars[ProKey("QMAKE_HOST.arch")] << archStr;
# if defined(Q_CC_MSVC) // ### bogus condition, but nobody x-builds for msvc with a different qmake
- QLatin1Char backslash('\\');
- QString paths = m_option->getEnv(QLatin1String("PATH"));
- QString vcBin64 = m_option->getEnv(QLatin1String("VCINSTALLDIR"));
- if (!vcBin64.endsWith(backslash))
- vcBin64.append(backslash);
- vcBin64.append(QLatin1String("bin\\amd64"));
- QString vcBinX86_64 = m_option->getEnv(QLatin1String("VCINSTALLDIR"));
- if (!vcBinX86_64.endsWith(backslash))
- vcBinX86_64.append(backslash);
- vcBinX86_64.append(QLatin1String("bin\\x86_amd64"));
- if (paths.contains(vcBin64, Qt::CaseInsensitive)
- || paths.contains(vcBinX86_64, Qt::CaseInsensitive))
- vars[ProKey("QMAKE_TARGET.arch")] << ProString("x86_64");
- else
- vars[ProKey("QMAKE_TARGET.arch")] << ProString("x86");
+ vars[ProKey("QMAKE_TARGET.arch")] = msvcArchitecture(
+ m_option->getEnv(QLatin1String("VCINSTALLDIR")),
+ m_option->getEnv(QLatin1String("PATH")));
# endif
#elif defined(Q_OS_UNIX)
struct utsname name;