Add detection of C++14 and C++1z compiler features

[ChangeLog][General Improvements] Qt's buildsystem now detects whether
the compiler supports C++14 and experimental support for C++1z. If the
compiler supports it, then Qt is automatically compiled using that
support.
\
This does not apply to user applications built using qmake: those are
still built with C++11 support only. To enable support for C++14 in your
application, add to your .pro file: CONFIG += c++14 (similarly for
C++1z).

Change-Id: Ib056b47dde3341ef9a52ffff13ef1f5d01c42596
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
Thiago Macieira 2015-07-08 17:21:30 -07:00 committed by Allan Sandfeld Jensen
parent 041fae0035
commit 4684c1afe5
18 changed files with 256 additions and 78 deletions

View File

@ -0,0 +1,40 @@
/****************************************************************************
**
** Copyright (C) 2015 Intel Corporation.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the configuration module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#if __cplusplus > 201103L
// Compiler claims to support C++14, trust it
#else
# error "__cplusplus must be > 201103L (the value of C++11)"
#endif
int main(int, char **) { return 0; }

View File

@ -0,0 +1,3 @@
SOURCES = c++14.cpp
CONFIG += c++11 c++14 console
CONFIG -= qt

View File

@ -0,0 +1,40 @@
/****************************************************************************
**
** Copyright (C) 2015 Intel Corporation.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the configuration module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#if __cplusplus > 201402L
// Compiler claims to support experimental C++1z, trust it
#else
# error "__cplusplus must be > 201402L (the value for C++14)"
#endif
int main(int, char **) { return 0; }

View File

@ -0,0 +1,3 @@
SOURCES = c++1z.cpp
CONFIG += c++11 c++14 c++1z console
CONFIG -= qt

97
configure vendored
View File

@ -769,7 +769,7 @@ CFG_SANITIZE_MEMORY=no
CFG_SANITIZE_UNDEFINED=no
CFG_PCRE=auto
QPA_PLATFORM_GUARD=yes
CFG_CXX11=auto
CFG_STDCXX=auto
CFG_DIRECTWRITE=no
CFG_WERROR=auto
CFG_HEADERSCLEAN=auto
@ -935,6 +935,7 @@ while [ "$#" -gt 0 ]; do
-sdk| \
-arch| \
-host-arch| \
-c++std | \
-mysql_config| \
-psql_config| \
-qpa| \
@ -2234,12 +2235,31 @@ while [ "$#" -gt 0 ]; do
fi
;;
c++11)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_CXX11="$VAL"
if [ "$VAL" = "yes" ]; then
CFG_STDCXX="c++11"
elif [ "$VAL" = "no" ]; then
CFG_STDCXX="c++98"
else
UNKNOWN_OPT=yes
fi
;;
c++std)
case "$VAL" in
c++98|c++11|c++14|c++1z|auto)
CFG_STDCXX="$VAL"
;;
98|11|14|1z)
CFG_STDCXX="c++$VAL"
;;
1y|c++1y)
CFG_STDCXX="c++14"
;;
*)
echo >&2 "Invalid C++ edition: $VAL; valid options are: c++98 c++11 c++14 c++1z auto"
ERROR=yes
;;
esac
;;
system-proxies)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_SYSTEM_PROXIES="$VAL"
@ -2411,8 +2431,8 @@ Configure options:
-confirm-license ... Automatically acknowledge the license (use with
either -opensource or -commercial)
-no-c++11 .......... Do not compile Qt with C++11 support enabled.
+ -c++11 ............. Compile Qt with C++11 support enabled.
-c++std <edition> .. Compile Qt with C++ standard edition (c++98, c++11, c++14, c++1z)
Default: highest supported
* -shared ............ Create and use shared Qt libraries.
-static ............ Create and use static Qt libraries.
@ -4323,24 +4343,47 @@ if [ "$CFG_SEPARATE_DEBUG_INFO" = "yes" ]; then
fi
fi
# Detect C++11 support
if [ "$CFG_CXX11" != "no" ]; then
# Configure detects compiler features based on cross compiler, so we need
# to explicitly disable C++11 on Mac to avoid breaking builds where the
# host compiler does not support it.
if [ "$BUILD_ON_MAC" = "yes" ] && [ "$XPLATFORM_ANDROID" = "yes" ]; then
CFG_CXX11="no"
elif 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!"
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
# Detect C++11 & up support
# Configure detects compiler features based on cross compiler, so we need
# to explicitly disable C++11 on Mac to avoid breaking builds where the
# host compiler does not support it.
stdcxx_error=false
if [ "$BUILD_ON_MAC" = "yes" ] && [ "$XPLATFORM_ANDROID" = "yes" ]; then
CFG_STDCXX="c++98"
elif [ "$CFG_STDCXX" = "c++98" ]; then
: # CFG_STDCXX is correct
elif ! compileTest common/c++11 "C++11"; then
if [ "$CFG_STDCXX" != "auto" ]; then
stdcxx_error=true
else
CFG_CXX11="no"
CFG_STDCXX="c++98"
fi
elif [ "$CFG_STDCXX" = "c++11" ]; then
: # CFG_STDCXX is correct
elif ! compileTest common/c++14 "C++14"; then
if [ "$CFG_STDCXX" != "auto" ]; then
stdcxx_error=true
else
CFG_STDCXX="c++11"
fi
elif [ "$CFG_STDCXX" = "c++14" ]; then
: # CFG_STDCXX is correct
elif ! compileTest common/c++1z "C++1z"; then
if [ "$CFG_STDCXX" != "auto" ]; then
stdcxx_error=true
else
CFG_STDCXX="c++14"
fi
else
CFG_STDCXX="c++1z"
fi
if $stdcxx_error && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
echo "$CFG_STDCXX 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
fi
# Detect which edition of the C++ standard the compiler defaults to
@ -6086,7 +6129,15 @@ fi
# ask for all that hasn't been auto-detected or specified in the arguments
#-------------------------------------------------------------------------------
[ "$CFG_CXX11" = "yes" ] && QT_CONFIG="$QT_CONFIG c++11"
if [ "$CFG_STDCXX" != "c++98" ]; then
QT_CONFIG="$QT_CONFIG c++11"
if [ "$CFG_STDCXX" != "c++11" ]; then
QT_CONFIG="$QT_CONFIG c++14"
if [ "$CFG_STDCXX" != "c++14" ]; then
QT_CONFIG="$QT_CONFIG c++1z"
fi
fi
fi
if [ "$CFG_SILENT" = "yes" ]; then
QMAKE_CONFIG="$QMAKE_CONFIG silent"
@ -7104,7 +7155,7 @@ else
fi
unset build_mode release
echo " Using sanitizer(s)...... $CFG_SANITIZERS"
echo " Using C++11 ............ $CFG_CXX11"
echo " Using C++ standard ..... $CFG_STDCXX"
echo " Using gold linker....... $CFG_USE_GOLD_LINKER"
echo " Using new DTAGS ........ $CFG_ENABLE_NEW_DTAGS"
echo " Using PCH .............. $CFG_PRECOMPILE"

View File

@ -27,9 +27,15 @@ QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
QMAKE_CXXFLAGS_DISABLE_LTCG = $$QMAKE_CFLAGS_DISABLE_LTCG
QMAKE_CXXFLAGS_CXX11 = -std=c++11
QMAKE_CXXFLAGS_CXX14 = -std=c++1y
QMAKE_CXXFLAGS_CXX1Z = -std=c++1z
QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++11
QMAKE_CXXFLAGS_GNUCXX14 = -std=gnu++1y
QMAKE_CXXFLAGS_GNUCXX1Z = -std=gnu++1z
QMAKE_LFLAGS_CXX11 =
QMAKE_LFLAGS_CXX14 =
QMAKE_LFLAGS_CXX1Z =
QMAKE_LFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
# Wrapper tools that understand .o/.a files with LLVM bytecode instead of machine code

View File

@ -28,5 +28,11 @@ QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_P
QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
QMAKE_CXXFLAGS_CXX11 = -std=c++0x
QMAKE_CXXFLAGS_CXX14 = -std=c++1y
QMAKE_CXXFLAGS_CXX1Z = -std=c++1z
QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++0x
QMAKE_CXXFLAGS_GNUCXX14 = -std=gnu++1y
QMAKE_CXXFLAGS_GNUCXX1Z = -std=gnu++1z
QMAKE_LFLAGS_CXX11 =
QMAKE_LFLAGS_CXX14 =
QMAKE_LFLAGS_CXX1Z =

View File

@ -45,6 +45,8 @@ QMAKE_LIBDIR = $${QNX_DIR}/$${QNX_CPUDIR}/lib $${QNX_DIR}/$${QNX_CPUD
QMAKE_LFLAGS += -Wl,-rpath-link,$${QNX_DIR}/$${QNX_CPUDIR}/lib -Wl,-rpath-link,$${QNX_DIR}/$${QNX_CPUDIR}/usr/lib
QMAKE_CXXFLAGS_CXX11 = -Wc,-std=gnu++0x
QMAKE_CXXFLAGS_CXX14 = -Wc,-std=gnu++1y
QMAKE_CXXFLAGS_CXX1Z = -Wc,-std=gnu++1z
QMAKE_LINK_C = $$QMAKE_CC
QMAKE_LINK_C_SHLIB = $$QMAKE_CC

View File

@ -1,9 +0,0 @@
strict_c++|isEmpty(QMAKE_CXXFLAGS_GNUCXX11) {
QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_CXX11
QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_CXXFLAGS_CXX11
QMAKE_LFLAGS += $$QMAKE_LFLAGS_CXX11
} else {
QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_GNUCXX11
QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_CXXFLAGS_GNUCXX11
QMAKE_LFLAGS += $$QMAKE_LFLAGS_GNUCXX11
}

View File

@ -1,23 +0,0 @@
intel_icc {
# ICC does not support C++14 yet
} else: clang {
# Clang has supported -std=c++1y since version 3.2
greaterThan(QT_CLANG_MAJOR_VERSION, 3)|greaterThan(QT_CLANG_MINOR_VERSION, 1) {
QMAKE_CXXFLAGS_CXX11 = -std=c++1y
QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++1y
}
# Unknown how long Apple Clang has supported -std=c++1y, but at least since XCode 5.0
greaterThan(QT_APPLE_CLANG_MAJOR_VERSION, 4) {
QMAKE_CXXFLAGS_CXX11 = -std=c++1y
QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++1y
}
} else: gcc {
# GCC has supported -std=c++1y since 4.8
greaterThan(QT_GCC_MAJOR_VERSION, 4)|greaterThan(QT_GCC_MINOR_VERSION, 7) {
QMAKE_CXXFLAGS_CXX11 = -std=c++1y
QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++1y
}
}
# Delegate to c++11.prf
include(c++11.prf)

View File

@ -98,6 +98,21 @@ breakpad {
!isEmpty(QMAKE_STRIP):QMAKE_POST_LINK = $$QMAKE_POST_LINK$$escape_expand(\\n\\t)$$quote($$QMAKE_STRIP $$DEBUGFILENAME)
}
c++11|c++14|c++1z {
c++1z: cxxstd = CXX1Z
else: c++14: cxxstd = CXX14
else: cxxstd = CXX11
# Check if we should disable the GNU extensions or not
!strict_c++:!isEmpty(QMAKE_CXXFLAGS_GNU$$cxxstd): cxxstd = GNU$$cxxstd
QMAKE_CXXFLAGS += $$eval(QMAKE_CXXFLAGS_$$cxxstd)
QMAKE_OBJECTIVE_CFLAGS += $$eval(QMAKE_CXXFLAGS_$$cxxstd)
QMAKE_LFLAGS += $$eval(QMAKE_LFLAGS_$$cxxstd)
unset(cxxstd)
}
!precompile_header: SOURCES += $$NO_PCH_SOURCES
QMAKE_INCDIR += $$QMAKE_INCDIR_POST

View File

@ -72,9 +72,6 @@ isEmpty(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.platform_name) {
# FIXME: Get the version_min_flag out of the platform's 'Native Build System.xcspec'
version_identifier = $$replace(QMAKE_MAC_PLATFORM_NAME, iphonesimulator, ios-simulator)
# C++11 support may affect the deployment target
c++11: load(c++11)
ios:!host_build: \
deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET
else: \

View File

@ -13,6 +13,8 @@ QMAKE_DIR_REPLACE_SANE += DESTDIR
CONFIG -= debug_and_release_target
contains(QT_CONFIG, c++11): CONFIG += c++11 strict_c++
contains(QT_CONFIG, c++14): CONFIG += c++14
contains(QT_CONFIG, c++1z): CONFIG += c++1z
contains(TEMPLATE, .*lib) {
# module and plugins
!host_build:contains(QT_CONFIG, reduce_exports): CONFIG += hide_symbols

View File

@ -50,7 +50,11 @@ QMAKE_CXXFLAGS_SPLIT_SECTIONS = $$QMAKE_CFLAGS_SPLIT_SECTIONS
# Disabling exceptions disabled - workaround for QTBUG-36577
#QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -fno-exceptions
QMAKE_CXXFLAGS_CXX11 = -std=c++0x
QMAKE_CXXFLAGS_CXX14 = -std=c++1y
QMAKE_CXXFLAGS_CXX1Z = -std=c++1z
QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++0x
QMAKE_CXXFLAGS_GNUCXX14 = -std=gnu++1y
QMAKE_CXXFLAGS_GNUCXX1Z = -std=gnu++1z
QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
QMAKE_INCDIR =
@ -73,6 +77,8 @@ QMAKE_LFLAGS_NOUNDEF = -Wl,-z,defs
QMAKE_LFLAGS_RPATH = -Wl,-rpath,
QMAKE_LFLAGS_RPATHLINK = -Wl,-rpath-link,
QMAKE_LFLAGS_CXX11 =
QMAKE_LFLAGS_CXX14 =
QMAKE_LFLAGS_CXX1Z =
QMAKE_LFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
QMAKE_LIBS =

View File

@ -53,7 +53,11 @@ 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++11
QMAKE_CXXFLAGS_CXX14 = -std=c++1y
QMAKE_CXXFLAGS_CXX1Z = -std=c++1z
QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++11
QMAKE_CXXFLAGS_GNUCXX14 = -std=gnu++1y
QMAKE_CXXFLAGS_GNUCXX1Z = -std=gnu++1z
QMAKE_CXXFLAGS_SPLIT_SECTIONS = $$QMAKE_CFLAGS_SPLIT_SECTIONS
QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG

View File

@ -56,7 +56,11 @@ QMAKE_CXXFLAGS_RTTI_OFF = -fno-rtti
QMAKE_CXXFLAGS_EXCEPTIONS_ON = -fexceptions -mthreads
QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -fno-exceptions
QMAKE_CXXFLAGS_CXX11 = -std=c++0x
QMAKE_CXXFLAGS_CXX14 = -std=c++1y
QMAKE_CXXFLAGS_CXX1Z = -std=c++1z
QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++0x
QMAKE_CXXFLAGS_GNUCXX14 = -std=gnu++1y
QMAKE_CXXFLAGS_GNUCXX1Z = -std=gnu++1z
QMAKE_CXXFLAGS_SPLIT_SECTIONS = $$QMAKE_CFLAGS_SPLIT_SECTIONS
QMAKE_INCDIR =
@ -77,6 +81,8 @@ QMAKE_LFLAGS_CONSOLE = -Wl,-subsystem,console
QMAKE_LFLAGS_WINDOWS = -Wl,-subsystem,windows
QMAKE_LFLAGS_DLL = -shared
QMAKE_LFLAGS_CXX11 =
QMAKE_LFLAGS_CXX14 =
QMAKE_LFLAGS_CXX1Z =
QMAKE_LFLAGS_GCSECTIONS = -Wl,--gc-sections
QMAKE_LFLAGS_USE_GOLD = -fuse-ld=gold
QMAKE_LINK_OBJECT_MAX = 10

View File

@ -46,6 +46,9 @@ QMAKE_CXXFLAGS_RTTI_OFF =
QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc
QMAKE_CXXFLAGS_EXCEPTIONS_OFF =
QMAKE_CXXFLAGS_CXX11 = -Qstd=c++11
# ICC supports the following but Qt won't compile
#QMAKE_CXXFLAGS_CXX14 = -Qstd=c++14
#QMAKE_CXXFLAGS_CXX1Z = -Qstd=c++1z
QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
QMAKE_INCDIR =

View File

@ -238,7 +238,7 @@ Configure::Configure(int& argc, char** argv)
dictionary[ "COMPILE_EXAMPLES" ] = "yes";
dictionary[ "C++11" ] = "auto";
dictionary[ "C++STD" ] = "auto";
dictionary[ "USE_GOLD_LINKER" ] = "no";
@ -464,9 +464,29 @@ void Configure::parseCmdLine()
}
else if (configCmdLine.at(i) == "-c++11")
dictionary[ "C++11" ] = "yes";
dictionary[ "C++STD" ] = "c++11";
else if (configCmdLine.at(i) == "-no-c++11")
dictionary[ "C++11" ] = "no";
dictionary[ "C++STD" ] = "c++98";
else if (configCmdLine.at(i) == "-c++std") {
++i;
if (i == argCount)
break;
QString level = configCmdLine.at(i);
if (level == "c++98" || level == "c++11" || level == "c++14" || level == "c++1z"
|| level == "auto") {
dictionary[ "C++STD" ] = level;
} else if (level == "98" || level == "11" || level == "14" || level == "1z") {
dictionary[ "C++STD" ] = "c++" + level;
} else {
dictionary[ "DONE" ] = "error";
cout << "ERROR: invalid C++ standard " << level
<< "; valid options are: c++98 c++11 c++14 c++1z auto" << endl;
return;
}
}
else if (configCmdLine.at(i) == "-use-gold-linker")
dictionary[ "USE_GOLD_LINKER" ] = "yes";
else if (configCmdLine.at(i) == "-no-use-gold-linker")
@ -1791,8 +1811,8 @@ 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( "-c++std <edition>", "Compile Qt with C++ standard edition (c++98, c++11, c++14, c++1z)\n"
"Default: highest supported. This option is not supported for MSVC.\n");
desc("USE_GOLD_LINKER", "yes", "-use-gold-linker", "Link using the GNU gold linker (gcc only).");
desc("USE_GOLD_LINKER", "no", "-no-use-gold-linker", "Do not link using the GNU gold linker.\n");
@ -2117,7 +2137,7 @@ QString Configure::defaultTo(const QString &option)
return "no";
// keep 'auto' default for msvc, since we can't set the language supported
if (option == "C++11"
if (option == "C++STD"
&& dictionary["QMAKESPEC"].contains("msvc"))
return "auto";
@ -2338,9 +2358,16 @@ void Configure::autoDetection()
// Auto-detect CPU architectures.
detectArch();
if (dictionary["C++11"] == "auto") {
if (!dictionary["QMAKESPEC"].contains("msvc"))
dictionary["C++11"] = tryCompileProject("common/c++11") ? "yes" : "no";
if (dictionary["C++STD"] == "auto" && !dictionary["QMAKESPEC"].contains("msvc")) {
if (!tryCompileProject("common/c++11")) {
dictionary["C++STD"] = "c++98";
} else if (!tryCompileProject("common/c++14")) {
dictionary["C++STD"] = "c++11";
} else if (!tryCompileProject("common/c++1z")) {
dictionary["C++STD"] = "c++14";
} else {
dictionary["C++STD"] = "c++1z";
}
}
if (!dictionary["QMAKESPEC"].contains("msvc")) {
@ -2544,16 +2571,11 @@ void Configure::autoDetection()
bool Configure::verifyConfiguration()
{
bool prompt = false;
if (dictionary["C++11"] != "auto"
if (dictionary["C++STD"] != "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";
cout << "WARNING: It is not possible to change the C++ standard edition with MSVC compilers. "
"Therefore, the option -c++std " << dictionary["C++STD"] << " was ignored." << endl << endl;
dictionary["C++STD"] = "auto";
}
if (dictionary["STATIC_RUNTIME"] == "yes" && dictionary["SHARED"] == "yes") {
@ -2695,8 +2717,12 @@ void Configure::generateOutputVars()
qtConfig += "release";
}
if (dictionary[ "C++11" ] == "yes")
if (dictionary[ "C++STD" ] == "c++11")
qtConfig += "c++11";
else if (dictionary[ "C++STD" ] == "c++14")
qtConfig += "c++11 c++14";
else if (dictionary[ "C++STD" ] == "c++1z")
qtConfig += "c++11 c++14 c++1z";
if (!dictionary[ "CFG_STDCXX_DEFAULT" ].isEmpty())
qmakeVars += "QT_COMPILER_STDCXX = " + dictionary[ "CFG_STDCXX_DEFAULT" ];
@ -3773,7 +3799,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 << "C++ language standard......." << dictionary[ "C++STD" ] << endl;
sout << "Link Time Code Generation..." << dictionary[ "LTCG" ] << endl;
sout << "Accessibility support......." << dictionary[ "ACCESSIBILITY" ] << endl;
sout << "RTTI support................" << dictionary[ "RTTI" ] << endl;