summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-08-01 13:31:35 -0700
committerKai Koehne <kai.koehne@theqtcompany.com>2015-08-25 06:25:11 +0000
commit3accdb8086cca78fc006cfbe0d8b6eb66ebcc307 (patch)
tree3417bc4b97d0109f19c3e3b7996023fa0dc569fe /tools
parent31fb4379c81c58fe471fc7d8e799a6a00c4b4ba0 (diff)
Detect which C++ standard edition the compiler defaults to
Change-Id: I2991557a5cc74cd18e88ffff13f670bf25d5423e Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/configure/configureapp.cpp24
-rw-r--r--tools/configure/configureapp.h3
2 files changed, 24 insertions, 3 deletions
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index c4455eeb63..6a7a217446 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -2343,6 +2343,22 @@ void Configure::autoDetection()
dictionary["C++11"] = tryCompileProject("common/c++11") ? "yes" : "no";
}
+ if (!dictionary["QMAKESPEC"].contains("msvc")) {
+ if (tryCompileProject("common/c++default", QString(), false)) {
+ QFile iiFile(buildPath + "/config.tests/common/c++default/c++default.ii");
+ if (iiFile.open(QIODevice::ReadOnly)) {
+ QString content = QString::fromUtf8(iiFile.readAll());
+ QRegExp expr("\\b([0-9]+)L\\b");
+ if (expr.indexIn(content) != -1)
+ dictionary["CFG_STDCXX_DEFAULT"] = expr.cap(1);
+ }
+ }
+ if (dictionary["CFG_STDCXX_DEFAULT"].isEmpty()) {
+ cout << "Could not determine the C++ standard the compiler uses by default, assuming C++98." << endl;
+ dictionary["CFG_STDCXX_DEFAULT"] = "199711";
+ }
+ }
+
// Style detection
if (dictionary["STYLE_WINDOWSXP"] == "auto")
dictionary["STYLE_WINDOWSXP"] = checkAvailability("STYLE_WINDOWSXP") ? defaultTo("STYLE_WINDOWSXP") : "no";
@@ -2681,6 +2697,8 @@ void Configure::generateOutputVars()
if (dictionary[ "C++11" ] == "yes")
qtConfig += "c++11";
+ if (!dictionary[ "CFG_STDCXX_DEFAULT" ].isEmpty())
+ qmakeVars += "QT_COMPILER_STDCXX = " + dictionary[ "CFG_STDCXX_DEFAULT" ];
if (dictionary[ "USE_GOLD_LINKER" ] == "yes")
qmakeConfig += "use_gold_linker";
@@ -3289,7 +3307,8 @@ void Configure::detectArch()
QDir::setCurrent(oldpwd);
}
-bool Configure::tryCompileProject(const QString &projectPath, const QString &extraOptions)
+bool Configure::tryCompileProject(const QString &projectPath, const QString &extraOptions,
+ bool distClean)
{
QString oldpwd = QDir::currentPath();
@@ -3332,7 +3351,8 @@ bool Configure::tryCompileProject(const QString &projectPath, const QString &ext
//cout << output << endl;
// clean up
- Environment::execute(command + " distclean 2>&1");
+ if (distClean)
+ Environment::execute(command + " distclean 2>&1");
}
QDir::setCurrent(oldpwd);
diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h
index e58a0feb2b..de8d1a2469 100644
--- a/tools/configure/configureapp.h
+++ b/tools/configure/configureapp.h
@@ -158,7 +158,8 @@ private:
void saveCmdLine();
void addSysroot(QString *command);
- bool tryCompileProject(const QString &projectPath, const QString &extraOptions = QString());
+ bool tryCompileProject(const QString &projectPath, const QString &extraOptions = QString(),
+ bool distClean = true);
bool compilerSupportsFlag(const QString &compilerAndArgs);
void desc(const char *description, int startingAt = 0, int wrapIndent = 0);