Add c++11 option to configure.exe
authorKai Koehne <kai.koehne@nokia.com>
Wed, 5 Sep 2012 08:31:49 +0000 (10:31 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 13 Sep 2012 14:47:27 +0000 (16:47 +0200)
Also check for c++11 support in configure.exe (which is also used by MinGW builds).
The c++11 check is therefore moved from 'unix' to 'common' directory.

Change-Id: I082848f032c2770e52e34f331b83820f395c06b6
Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org>
Reviewed-by: Yuchen Deng <loaden@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
config.tests/common/c++11/c++11.cpp [moved from config.tests/unix/c++11/c++11.cpp with 100% similarity]
config.tests/common/c++11/c++11.pro [moved from config.tests/unix/c++11/c++11.pro with 100% similarity]
configure
tools/configure/configureapp.cpp

index 8cc0d30..b7f46dd 100755 (executable)
--- a/configure
+++ b/configure
@@ -3819,7 +3819,7 @@ fi
 
 # Detect C++11 support
 if [ "$CFG_CXX11" != "no" ]; then
-    if compileTest unix/c++11 "C++11"; then
+    if compileTest common/c++11 "C++11"; then
         CFG_CXX11="yes"
     elif [ "$CFG_CXX11" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
         echo "C++11 support cannot be enabled due to functionality tests!"
index ff04eeb..3c5e58b 100644 (file)
@@ -272,6 +272,8 @@ Configure::Configure(int& argc, char** argv)
 
     dictionary[ "BUILDDEV" ]        = "no";
 
+    dictionary[ "C++11" ]           = "auto";
+
     dictionary[ "SHARED" ]          = "yes";
 
     dictionary[ "ZLIB" ]            = "auto";
@@ -452,7 +454,10 @@ void Configure::parseCmdLine()
             dictionary[ "BUILDALL" ] = "yes";
         else if (configCmdLine.at(i) == "-force-debug-info")
             dictionary[ "FORCEDEBUGINFO" ] = "yes";
-
+        else if (configCmdLine.at(i) == "-c++11")
+            dictionary[ "C++11" ] = "yes";
+        else if (configCmdLine.at(i) == "-no-c++11")
+            dictionary[ "C++11" ] = "no";
         else if (configCmdLine.at(i) == "-shared")
             dictionary[ "SHARED" ] = "yes";
         else if (configCmdLine.at(i) == "-static")
@@ -1597,6 +1602,9 @@ bool Configure::displayHelp()
         desc("OPENSOURCE", "opensource", "-opensource",   "Compile and link the Open-Source Edition of Qt.");
         desc("COMMERCIAL", "commercial", "-commercial",   "Compile and link the Commercial Edition of Qt.\n");
 
+        desc("C++11", "yes", "-c++11",                  "Compile Qt with C++11 support enabled.");
+        desc("C++11", "no", "-no-c++11",                "Do not compile Qt with C++11 support enabled.\n");
+
         desc("SHARED", "yes",   "-shared",              "Create and use shared Qt libraries.");
         desc("SHARED", "no",    "-static",              "Create and use static Qt libraries.\n");
 
@@ -2044,6 +2052,11 @@ bool Configure::checkAvailability(const QString &part)
 */
 void Configure::autoDetection()
 {
+    if (dictionary["C++11"] == "auto") {
+        if (!dictionary["QMAKESPEC"].contains("msvc"))
+            dictionary["C++11"] = tryCompileProject("common/c++11") ? "yes" : "no";
+    }
+
     // Style detection
     if (dictionary["STYLE_WINDOWSXP"] == "auto")
         dictionary["STYLE_WINDOWSXP"] = checkAvailability("STYLE_WINDOWSXP") ? defaultTo("STYLE_WINDOWSXP") : "no";
@@ -2150,6 +2163,18 @@ void Configure::autoDetection()
 
 bool Configure::verifyConfiguration()
 {
+    if (dictionary["C++11"] != "auto"
+            && dictionary["QMAKESPEC"].contains("msvc")) {
+        cout << "WARNING: Qt does not support disabling or enabling any existing C++11 support "
+                "with MSVC compilers.";
+        if (dictionary["C++11"] == "yes")
+            cout << "Therefore -c++11 is ignored." << endl << endl;
+        else
+            cout << "Therefore -no-c++11 is ignored." << endl << endl;
+
+        dictionary["C++11"] = "auto";
+    }
+
     if (dictionary["SQL_SQLITE_LIB"] == "no" && dictionary["SQL_SQLITE"] != "no") {
         cout << "WARNING: Configure could not detect the presence of a system SQLite3 lib." << endl
              << "Configure will therefore continue with the SQLite3 lib bundled with Qt." << endl
@@ -2256,6 +2281,9 @@ void Configure::generateOutputVars()
         qtConfig += "release";
     }
 
+    if (dictionary[ "C++11" ] == "yes")
+        qtConfig += "c++11";
+
     if (dictionary[ "SHARED" ] == "no")
         qtConfig += "static";
     else
@@ -3227,6 +3255,7 @@ void Configure::displayConfig()
     }
     if (dictionary[ "BUILD" ] == "release" || dictionary[ "BUILDALL" ] == "yes")
         sout << "Force debug info............" << dictionary[ "FORCEDEBUGINFO" ] << endl;
+    sout << "C++11 support..............." << dictionary[ "C++11" ] << endl;
     sout << "Link Time Code Generation..." << dictionary[ "LTCG" ] << endl;
     sout << "Accessibility support......." << dictionary[ "ACCESSIBILITY" ] << endl;
     sout << "RTTI support................" << dictionary[ "RTTI" ] << endl;