From 5b165f11bc1e540b524f7e049b8b3c727a5aa990 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 1 Apr 2022 10:16:17 +0200 Subject: 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. Task-number: QTBUG-102202 Change-Id: Ie00ee5793c1a649195013c8c19efc8d59cf0acc9 Reviewed-by: Alexandru Croitor Reviewed-by: Kai Koehne (cherry picked from commit b5ed3cb7baeb6d77c375134719ee04ffcc211b9f) Reviewed-by: Qt CI Bot --- config_help.txt | 2 +- configure.json | 22 +++++++++++++++++++++- configure.pri | 9 +++++++++ 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 +- qmake/doc/src/qmake-manual.qdoc | 3 +++ 9 files changed, 45 insertions(+), 7 deletions(-) diff --git a/config_help.txt b/config_help.txt index bce61577e7..14bbd3e869 100644 --- a/config_help.txt +++ b/config_help.txt @@ -142,7 +142,7 @@ Build options: sanitizers or generate instrumented code to collect execution counts and enable code coverage analysis, respectively. (Clang only) - -c++std .... Select C++ standard [c++2a/c++17/c++14/c++11] + -c++std .... Select C++ standard [c++2b/c++2a/c++17/c++14/c++11] (Not supported with MSVC 2015) -sse2 ................ Use SSE2 instructions [auto] diff --git a/configure.json b/configure.json index f0b5fed415..4763ff645f 100644 --- a/configure.json +++ b/configure.json @@ -380,6 +380,20 @@ "qmake": "CONFIG += c++11 c++14 c++17 c++2a" } }, + "cxx2b": { + "label": "C++2b support", + "type": "compile", + "test": { + "head": [ + "#if __cplusplus > 202002L", + "// Compiler claims to support experimental C++2b, trust it", + "#else", + "# error __cplusplus must be > 202002L (the value for C++20)", + "#endif" + ], + "qmake": "CONFIG += c++11 c++14 c++17 c++2a c++2b" + } + }, "precompile_header": { "label": "precompiled header support", "type": "compile", @@ -1002,6 +1016,12 @@ "condition": "features.c++17 && tests.cxx2a", "output": [ "publicFeature", "publicQtConfig" ] }, + "c++2b": { + "label": "C++2b", + "autoDetect": false, + "condition": "features.c++2a && tests.cxx2b", + "output": [ "publicFeature", "publicQtConfig" ] + }, "c89": { "label": "C89" }, @@ -1554,7 +1574,7 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5 { "message": "Using C++ standard", "type": "firstAvailableFeature", - "args": "c++2a c++17 c++14 c++11" + "args": "c++2b c++2a c++17 c++14 c++11" }, { "type": "feature", diff --git a/configure.pri b/configure.pri index 63d6b3f278..365a16403e 100644 --- a/configure.pri +++ b/configure.pri @@ -22,18 +22,27 @@ defineTest(qtConfCommandline_cxxstd) { qtConfCommandlineSetInput("c++14", "no") qtConfCommandlineSetInput("c++1z", "no") qtConfCommandlineSetInput("c++2a", "no") + qtConfCommandlineSetInput("c++2b", "no") } else: contains(val, "(c\+\+)?(14|1y)") { qtConfCommandlineSetInput("c++14", "yes") qtConfCommandlineSetInput("c++1z", "no") qtConfCommandlineSetInput("c++2a", "no") + qtConfCommandlineSetInput("c++2b", "no") } else: contains(val, "(c\+\+)?(17|1z)") { qtConfCommandlineSetInput("c++14", "yes") qtConfCommandlineSetInput("c++1z", "yes") qtConfCommandlineSetInput("c++2a", "no") + qtConfCommandlineSetInput("c++2b", "no") } else: contains(val, "(c\+\+)?(2a)") { qtConfCommandlineSetInput("c++14", "yes") qtConfCommandlineSetInput("c++1z", "yes") qtConfCommandlineSetInput("c++2a", "yes") + qtConfCommandlineSetInput("c++2b", "no") + } else: contains(val, "(c\+\+)?(2b)") { + qtConfCommandlineSetInput("c++14", "yes") + qtConfCommandlineSetInput("c++1z", "yes") + qtConfCommandlineSetInput("c++2a", "yes") + qtConfCommandlineSetInput("c++2b", "yes") } else { qtConfAddError("Invalid argument $$val to command line parameter $$arg") } 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 201c82b9f1..c8f7a07767 100644 --- a/mkspecs/common/msvc-version.conf +++ b/mkspecs/common/msvc-version.conf @@ -118,6 +118,7 @@ greaterThan(QMAKE_MSC_VER, 1919) { # Visual Studio 2019 (16.0) / Visual C++ 19.20 and up MSVC_VER = 16.0 QMAKE_CXXFLAGS_CXX2A = -std:c++latest + QMAKE_CXXFLAGS_CXX2B = -std:c++latest } diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index 462dbf7774..ac799047ab 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -122,17 +122,18 @@ breakpad { } c++17: CONFIG += c++1z -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++11:!c++14:!c++1z:!c++2a { +!c++11:!c++14:!c++1z:!c++2a:!c++2b { # Qt requires C++11 since 5.7, check if we need to force a compiler option QT_COMPILER_STDCXX_no_L = $$replace(QT_COMPILER_STDCXX, "L$", "") !greaterThan(QT_COMPILER_STDCXX_no_L, 199711): CONFIG += c++11 } -c++11|c++14|c++1z|c++2a { +c++11|c++14|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: c++1z: cxxstd = CXX1Z else: c++14: cxxstd = CXX14 else: cxxstd = CXX11 diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf index 269ec11be1..aed52752b7 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 @@ -158,4 +159,3 @@ warnings_are_errors:warning_clean { } unset(ver) } - diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index f86eb04962..2b58df073f 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -1217,6 +1217,9 @@ \row \li c++2a \li C++2a support is enabled. This option has no effect if the compiler does not support C++2a, or can't select the C++ standard. By default, support is disabled. + \row \li c++2b \li c++2b support is enabled. This option has no effect if + the compiler does not support c++2b, or can't select the C++ standard. + By default, support is disabled. \row \li c++latest \li Support for the latest C++ language standard is enabled that is supported by the compiler. By default, this option is disabled. -- cgit v1.2.3