From b5ed3cb7baeb6d77c375134719ee04ffcc211b9f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 1 Apr 2022 10:16:17 +0200 Subject: [PATCH] qmake: Add support for C++23 Add the CONFIG value c++2b that represent the upcoming C++23 standard. Add QMAKE_CXXFLAGS_CXX2B and QMAKE_CXXFLAGS_GNUCXX2B. On MSVC, use /std:c++latest when c++2b is active. This fixes an issue with MSVC where c++latest implied the /std:c++20 compiler flag. Pick-to: 5.15 6.2 6.3 Fixes: QTBUG-102202 Change-Id: Ie00ee5793c1a649195013c8c19efc8d59cf0acc9 Reviewed-by: Alexandru Croitor Reviewed-by: Kai Koehne --- mkspecs/common/clang.conf | 2 ++ mkspecs/common/g++-base.conf | 2 ++ mkspecs/common/msvc-version.conf | 1 + mkspecs/features/default_post.prf | 9 +++++---- mkspecs/features/qt_common.prf | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/mkspecs/common/clang.conf b/mkspecs/common/clang.conf index dad15a22a8..6eb08a9d2f 100644 --- a/mkspecs/common/clang.conf +++ b/mkspecs/common/clang.conf @@ -35,10 +35,12 @@ QMAKE_CXXFLAGS_CXX11 = -std=c++11 QMAKE_CXXFLAGS_CXX14 = -std=c++1y QMAKE_CXXFLAGS_CXX1Z = -std=c++1z QMAKE_CXXFLAGS_CXX2A = -std=c++2a +QMAKE_CXXFLAGS_CXX2B = -std=c++2b QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++11 QMAKE_CXXFLAGS_GNUCXX14 = -std=gnu++1y QMAKE_CXXFLAGS_GNUCXX1Z = -std=gnu++1z QMAKE_CXXFLAGS_GNUCXX2A = -std=gnu++2a +QMAKE_CXXFLAGS_GNUCXX2B = -std=gnu++2b QMAKE_LFLAGS_CXX11 = QMAKE_LFLAGS_CXX14 = diff --git a/mkspecs/common/g++-base.conf b/mkspecs/common/g++-base.conf index c337696304..d392879f66 100644 --- a/mkspecs/common/g++-base.conf +++ b/mkspecs/common/g++-base.conf @@ -33,10 +33,12 @@ QMAKE_CXXFLAGS_CXX11 = -std=c++11 QMAKE_CXXFLAGS_CXX14 = -std=c++1y QMAKE_CXXFLAGS_CXX1Z = -std=c++1z QMAKE_CXXFLAGS_CXX2A = -std=c++2a +QMAKE_CXXFLAGS_CXX2B = -std=c++2b QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++11 QMAKE_CXXFLAGS_GNUCXX14 = -std=gnu++1y QMAKE_CXXFLAGS_GNUCXX1Z = -std=gnu++1z QMAKE_CXXFLAGS_GNUCXX2A = -std=gnu++2a +QMAKE_CXXFLAGS_GNUCXX2B = -std=gnu++2b QMAKE_LFLAGS_CXX11 = QMAKE_LFLAGS_CXX14 = QMAKE_LFLAGS_CXX1Z = diff --git a/mkspecs/common/msvc-version.conf b/mkspecs/common/msvc-version.conf index 13dd349cf4..303b341e9d 100644 --- a/mkspecs/common/msvc-version.conf +++ b/mkspecs/common/msvc-version.conf @@ -120,6 +120,7 @@ greaterThan(QMAKE_MSC_VER, 1919) { MSVC_VER = 16.0 MSVC_TOOLSET_VER = 142 QMAKE_CXXFLAGS_CXX2A = -std:c++latest + QMAKE_CXXFLAGS_CXX2B = -std:c++latest QMAKE_CXXFLAGS += -Zc:externConstexpr } diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index b94aab3e9c..2be446e41e 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -123,17 +123,18 @@ breakpad { c++17: CONFIG += c++1z c++20: CONFIG += c++2a -c++latest: CONFIG *= c++2a c++1z c++14 c++11 +c++latest: CONFIG *= c++2b c++2a c++1z c++14 c++11 -!c++1z:!c++2a { +!c++1z:!c++2a:!c++2b { # Qt requires C++17 QT_COMPILER_STDCXX_no_L = $$replace(QT_COMPILER_STDCXX, "L$", "") !greaterThan(QT_COMPILER_STDCXX_no_L, 201402): CONFIG += c++1z } -c++1z|c++2a { +c++1z|c++2a|c++2b { # Disable special compiler flags for host builds !host_build|!cross_compile { - c++2a: cxxstd = CXX2A + c++2b: cxxstd = CXX2B + else:c++2a: cxxstd = CXX2A else: cxxstd = CXX1Z } else { # Fall back to c++17, because C++17 is required everywhere, diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf index f51b32660b..0f436ffacf 100644 --- a/mkspecs/features/qt_common.prf +++ b/mkspecs/features/qt_common.prf @@ -18,6 +18,7 @@ qtConfig(c++11): CONFIG += c++11 strict_c++ qtConfig(c++14): CONFIG += c++14 qtConfig(c++1z): CONFIG += c++1z qtConfig(c++2a): CONFIG += c++2a +qtConfig(c++2b): CONFIG += c++2b qtConfig(c99): CONFIG += c99 qtConfig(c11): CONFIG += c11 qtConfig(separate_debug_info): CONFIG += separate_debug_info @@ -162,4 +163,3 @@ warnings_are_errors:warning_clean { } unset(ver) } -