summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2012-05-29 07:10:09 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-05 12:30:13 +0200
commitbf84d1a1fe1550fb7cb86d686bf0138c1c41e87b (patch)
tree83ca6ac60c54ae23592ac1dc96efa39e94f945ba
parenta6d6719c26a6d8e43250d05e2b587dbcc3e59366 (diff)
configure: Auto-detect and enable C++11 support if available
Enabling support for C++11 adds CONFIG+=c++11 to the Qt build. Projects using Qt can check for C++11 support using contains(QT_CONFIG, c++11) in their .pr[iof] files. The QMAKE_CXXFLAGS_CXX11 and QMAKE_LFLAGS_CXX11 qmake varibles contain any arguments the compiler needs to enable C++11. CONFIG+=c++11 adds these arguments to the build. Support for clang, g++, and the Intel C++ Compiler for Linux are included in this commit. Change-Id: Id77f86d7ad4d5c740b890446a40b105879a0d327 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
-rw-r--r--config.tests/unix/c++11/c++11.cpp48
-rw-r--r--config.tests/unix/c++11/c++11.pro3
-rwxr-xr-xconfigure32
-rw-r--r--dist/changes-5.0.06
-rw-r--r--mkspecs/common/clang.conf3
-rw-r--r--mkspecs/common/g++-base.conf3
-rw-r--r--mkspecs/features/c++11.prf3
-rw-r--r--mkspecs/features/qt_module_config.prf1
-rw-r--r--mkspecs/features/qt_plugin.prf1
-rw-r--r--mkspecs/linux-icc/qmake.conf2
10 files changed, 100 insertions, 2 deletions
diff --git a/config.tests/unix/c++11/c++11.cpp b/config.tests/unix/c++11/c++11.cpp
new file mode 100644
index 0000000000..d541144bf9
--- /dev/null
+++ b/config.tests/unix/c++11/c++11.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** 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"
+#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
new file mode 100644
index 0000000000..dd4042b8d6
--- /dev/null
+++ b/config.tests/unix/c++11/c++11.pro
@@ -0,0 +1,3 @@
+SOURCES = c++11.cpp
+CONFIG += c++11
+CONFIG -= qt app_bundle
diff --git a/configure b/configure
index 747ebf3b20..d605fe07e2 100755
--- a/configure
+++ b/configure
@@ -802,6 +802,7 @@ CFG_ICU=auto
CFG_FORCE_ASSERTS=no
CFG_PCRE=auto
QPA_PLATFORM_GUARD=yes
+CFG_CXX11=auto
# initalize variables used for installation
QT_INSTALL_PREFIX=
@@ -918,7 +919,7 @@ while [ "$#" -gt 0 ]; do
VAL=no
;;
#Qt style yes options
- -profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-xinput2|-egl|-reduce-exports|-pch|-separate-debug-info|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-xcb|-eglfs|-directfb|-nis|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-debug-and-release|-harfbuzz|-prefix-install|-silent|-optimized-qmake|-reduce-relocations|-sse|-openssl|-openssl-linked|-phonon-backend|-audio-backend|-qml-debug|-javascript-jit|-rpath|-pkg-config|-force-pkg-config|-icu|-force-asserts|-testcocoon)
+ -profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-xinput2|-egl|-reduce-exports|-pch|-separate-debug-info|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-xcb|-eglfs|-directfb|-nis|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-debug-and-release|-harfbuzz|-prefix-install|-silent|-optimized-qmake|-reduce-relocations|-sse|-openssl|-openssl-linked|-phonon-backend|-audio-backend|-qml-debug|-javascript-jit|-rpath|-pkg-config|-force-pkg-config|-icu|-force-asserts|-testcocoon|-c++11)
VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
VAL=yes
;;
@@ -1986,6 +1987,13 @@ while [ "$#" -gt 0 ]; do
UNKNOWN_OPT=yes
fi
;;
+ c++11)
+ if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
+ CFG_CXX11="$VAL"
+ else
+ UNKNOWN_OPT=yes
+ fi
+ ;;
*)
UNKNOWN_OPT=yes
;;
@@ -2871,7 +2879,7 @@ if [ "$OPT_HELP" = "yes" ]; then
Usage: $relconf [-h] [-prefix <dir>] [-prefix-install] [-bindir <dir>] [-libdir <dir>]
[-docdir <dir>] [-headerdir <dir>] [-plugindir <dir> ] [-importdir <dir>] [-datadir <dir>]
[-translationdir <dir>] [-sysconfdir <dir>] [-examplesdir <dir>] [-testsdir <dir>]
- [-release] [-debug] [-debug-and-release]
+ [-release] [-debug] [-debug-and-release] [-c++11] [-no-c++11]
[-developer-build] [-shared] [-static] [-no-fast] [-fast] [-no-largefile]
[-largefile] [-no-accessibility] [-accessibility] [-no-sql-<driver>] [-sql-<driver>]
[-plugin-sql-<driver>] [-system-sqlite]
@@ -2961,6 +2969,8 @@ Configure options:
-opensource ........ Compile and link the Open-Source Edition of Qt.
-commercial ........ Compile and link the Commercial Edition of Qt.
+ -no-c++11 .......... Do not compile Qt with C++11 support enabled.
+ + -c++11 ............. Compile Qt with C++11 support enabled.
* -shared ............ Create and use shared Qt libraries.
-static ............ Create and use static Qt libraries.
@@ -3728,6 +3738,21 @@ fi
# functionality tests
#-------------------------------------------------------------------------------
+# Detect C++11 support
+if [ "$CFG_CXX11" != "no" ]; then
+ if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/c++11 "C++11" $L_FLAGS $I_FLAGS $l_FLAGS; 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!"
+ echo " Turn on verbose messaging (-v) to $0 to see the final report."
+ echo " If you believe this message is in error you may use the continue"
+ echo " switch (-continue) to $0 to continue."
+ exit 101
+ else
+ CFG_CXX11="no"
+ fi
+fi
+
# detect availability of float math.h functions
if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/floatmath "floatmath" $L_FLAGS $I_FLAGS $D_FLAGS $l_FLAGS; then
CFG_USE_FLOATMATH=yes
@@ -5006,6 +5031,8 @@ fi
# ask for all that hasn't been auto-detected or specified in the arguments
#-------------------------------------------------------------------------------
+[ "$CFG_CXX11" = "yes" ] && QT_CONFIG="$QT_CONFIG c++11"
+
# ### Vestige
if [ "$CFG_PHONON_BACKEND" = "yes" ]; then
QT_CONFIG="$QT_CONFIG phonon-backend"
@@ -5938,6 +5965,7 @@ if [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
else
echo "Debug .................. $CFG_DEBUG"
fi
+echo "C++11 support .......... $CFG_CXX11"
if [ -n "$PKG_CONFIG" ]; then
echo "pkg-config ............. yes"
else
diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0
index 7b13952826..1775a4c556 100644
--- a/dist/changes-5.0.0
+++ b/dist/changes-5.0.0
@@ -287,6 +287,12 @@ General Improvements
more closely match the directory structure of the code under test.
Integration tests have been moved to tests/auto/integrationtests.
+- Qt is compiled with C++11 support enabled by default, provided the compiler
+ supports C++11. Qmake based projects can enable C++11 support explicitly
+ using 'CONFIG+=c++11' in their .pro files. To enable it conditionally, use
+ 'contains(QT_CONFIG,c++11):CONFIG+=c++11'. This will enable C++11 support
+ only if Qt was built with C++11 support.
+
Third party components
----------------------
diff --git a/mkspecs/common/clang.conf b/mkspecs/common/clang.conf
index 069cdfafec..67fdf4c1f4 100644
--- a/mkspecs/common/clang.conf
+++ b/mkspecs/common/clang.conf
@@ -15,3 +15,6 @@ QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_
QMAKE_CFLAGS_USE_PRECOMPILE = -Xclang -include-pch -Xclang ${QMAKE_PCH_OUTPUT}
QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+
+QMAKE_CXXFLAGS_CXX11 = -std=c++11
+QMAKE_LFLAGS_CXX11 =
diff --git a/mkspecs/common/g++-base.conf b/mkspecs/common/g++-base.conf
index eb5b7d6188..35f86e5bf1 100644
--- a/mkspecs/common/g++-base.conf
+++ b/mkspecs/common/g++-base.conf
@@ -28,3 +28,6 @@ QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH
QMAKE_CFLAGS_USE_PRECOMPILE = -include ${QMAKE_PCH_OUTPUT_BASE}
QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+
+QMAKE_CXXFLAGS_CXX11 = -std=c++0x
+QMAKE_LFLAGS_CXX11 =
diff --git a/mkspecs/features/c++11.prf b/mkspecs/features/c++11.prf
new file mode 100644
index 0000000000..4b56fa9fd2
--- /dev/null
+++ b/mkspecs/features/c++11.prf
@@ -0,0 +1,3 @@
+QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_CXX11
+QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_CXXFLAGS_CXX11
+QMAKE_LFLAGS += $$QMAKE_LFLAGS_CXX11
diff --git a/mkspecs/features/qt_module_config.prf b/mkspecs/features/qt_module_config.prf
index 217572e143..b6b0c2ca37 100644
--- a/mkspecs/features/qt_module_config.prf
+++ b/mkspecs/features/qt_module_config.prf
@@ -50,6 +50,7 @@ contains(QT_CONFIG, largefile):CONFIG += largefile
contains(QT_CONFIG, build_all):CONFIG += build_all
contains(QT_CONFIG, separate_debug_info):CONFIG += separate_debug_info
contains(QT_CONFIG, separate_debug_info_nocopy):CONFIG += separate_debug_info_nocopy
+contains(QT_CONFIG, c++11):CONFIG += c++11
#mac frameworks
mac:!static:contains(QT_CONFIG, qt_framework) {
diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf
index a63ffab868..768918f65b 100644
--- a/mkspecs/features/qt_plugin.prf
+++ b/mkspecs/features/qt_plugin.prf
@@ -11,6 +11,7 @@ TARGET = $$qtLibraryTarget($$TARGET)
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
contains(QT_CONFIG, separate_debug_info):CONFIG += separate_debug_info
contains(QT_CONFIG, separate_debug_info_nocopy):CONFIG += separate_debug_info_nocopy
+contains(QT_CONFIG, c++11):CONFIG += c++11
load(qt_targets)
diff --git a/mkspecs/linux-icc/qmake.conf b/mkspecs/linux-icc/qmake.conf
index 4884ea1d1f..eb837254e1 100644
--- a/mkspecs/linux-icc/qmake.conf
+++ b/mkspecs/linux-icc/qmake.conf
@@ -35,6 +35,7 @@ QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB
QMAKE_CXXFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_STATIC_LIB
QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC
QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD
+QMAKE_CXXFLAGS_CXX11 = -std=c++0x
QMAKE_INCDIR =
QMAKE_LIBDIR =
@@ -56,6 +57,7 @@ QMAKE_LFLAGS_SONAME = -Wl,-soname,
QMAKE_LFLAGS_THREAD =
QMAKE_LFLAGS_NOUNDEF = -Wl,-z,defs
QMAKE_LFLAGS_RPATH = -Wl,-rpath,
+QMAKE_LFLAGS_CXX11 =
QMAKE_LIBS =
QMAKE_LIBS_DYNLOAD = -ldl