From f0e2c6fe1c4b89260844243a98862ebe672e3ad9 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 5 Sep 2012 10:31:49 +0200 Subject: Add c++11 option to configure.exe 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 Reviewed-by: Yuchen Deng Reviewed-by: Thiago Macieira --- config.tests/common/c++11/c++11.cpp | 53 +++++++++++++++++++++++++++++++++++++ config.tests/common/c++11/c++11.pro | 3 +++ config.tests/unix/c++11/c++11.cpp | 53 ------------------------------------- config.tests/unix/c++11/c++11.pro | 3 --- configure | 2 +- tools/configure/configureapp.cpp | 31 +++++++++++++++++++++- 6 files changed, 87 insertions(+), 58 deletions(-) create mode 100644 config.tests/common/c++11/c++11.cpp create mode 100644 config.tests/common/c++11/c++11.pro delete mode 100644 config.tests/unix/c++11/c++11.cpp delete mode 100644 config.tests/unix/c++11/c++11.pro diff --git a/config.tests/common/c++11/c++11.cpp b/config.tests/common/c++11/c++11.cpp new file mode 100644 index 0000000000..671723647e --- /dev/null +++ b/config.tests/common/c++11/c++11.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) +// Compiler claims to support C++11, trust it +#else +# error "__cplusplus must be >= 201103L, or __GXX_EXPERIMENTAL_CXX0X__ must be defined" +#endif + +#include +#if defined(__clang__) && !defined(_LIBCPP_VERSION) +# error "C++11 with clang requires libc++ runtime" +#endif + +int main(int, char **) { return 0; } diff --git a/config.tests/common/c++11/c++11.pro b/config.tests/common/c++11/c++11.pro new file mode 100644 index 0000000000..dd4042b8d6 --- /dev/null +++ b/config.tests/common/c++11/c++11.pro @@ -0,0 +1,3 @@ +SOURCES = c++11.cpp +CONFIG += c++11 +CONFIG -= qt app_bundle diff --git a/config.tests/unix/c++11/c++11.cpp b/config.tests/unix/c++11/c++11.cpp deleted file mode 100644 index 671723647e..0000000000 --- a/config.tests/unix/c++11/c++11.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) -// Compiler claims to support C++11, trust it -#else -# error "__cplusplus must be >= 201103L, or __GXX_EXPERIMENTAL_CXX0X__ must be defined" -#endif - -#include -#if defined(__clang__) && !defined(_LIBCPP_VERSION) -# error "C++11 with clang requires libc++ runtime" -#endif - -int main(int, char **) { return 0; } diff --git a/config.tests/unix/c++11/c++11.pro b/config.tests/unix/c++11/c++11.pro deleted file mode 100644 index dd4042b8d6..0000000000 --- a/config.tests/unix/c++11/c++11.pro +++ /dev/null @@ -1,3 +0,0 @@ -SOURCES = c++11.cpp -CONFIG += c++11 -CONFIG -= qt app_bundle diff --git a/configure b/configure index 8cc0d30ccf..b7f46ddae2 100755 --- 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!" diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index ff04eeb742..3c5e58b29b 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -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; -- cgit v1.2.3