C++23/c++2b support
Change-Id: I33b2a48312ae94e3d5ebb4097e50c4953e14d533 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
4d2ef82089
commit
dc3b2ac81d
@ -938,8 +938,10 @@ function(qt_config_compile_test name)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(arg_CXX_STANDARD)
|
if(arg_CXX_STANDARD)
|
||||||
|
if(${arg_CXX_STANDARD} LESS 23 OR ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20")
|
||||||
set(CMAKE_CXX_STANDARD "${arg_CXX_STANDARD}")
|
set(CMAKE_CXX_STANDARD "${arg_CXX_STANDARD}")
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_FLAGS ${arg_COMPILE_OPTIONS})
|
set(CMAKE_REQUIRED_FLAGS ${arg_COMPILE_OPTIONS})
|
||||||
|
|
||||||
|
@ -230,7 +230,9 @@ endfunction()
|
|||||||
|
|
||||||
function(qt_set_language_standards)
|
function(qt_set_language_standards)
|
||||||
## Use the latest standard the compiler supports (same as qt_common.prf)
|
## Use the latest standard the compiler supports (same as qt_common.prf)
|
||||||
if (QT_FEATURE_cxx20)
|
if (QT_FEATURE_cxx2b)
|
||||||
|
set(CMAKE_CXX_STANDARD 23 PARENT_SCOPE)
|
||||||
|
elseif (QT_FEATURE_cxx20)
|
||||||
set(CMAKE_CXX_STANDARD 20 PARENT_SCOPE)
|
set(CMAKE_CXX_STANDARD 20 PARENT_SCOPE)
|
||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_STANDARD 17 PARENT_SCOPE)
|
set(CMAKE_CXX_STANDARD 17 PARENT_SCOPE)
|
||||||
|
@ -110,7 +110,7 @@ Build options:
|
|||||||
for example, -sanitize address cannot be combined with
|
for example, -sanitize address cannot be combined with
|
||||||
-sanitize thread.
|
-sanitize thread.
|
||||||
|
|
||||||
-c++std <edition> .... Select C++ standard <edition> [c++20/c++17/c++14/c++11]
|
-c++std <edition> .... Select C++ standard <edition> [c++2b/c++20/c++17/c++14/c++11]
|
||||||
|
|
||||||
-sse2 ................ Use SSE2 instructions [auto]
|
-sse2 ................ Use SSE2 instructions [auto]
|
||||||
-sse3/-ssse3/-sse4.1/-sse4.2/-avx/-avx2/-avx512
|
-sse3/-ssse3/-sse4.1/-sse4.2/-avx/-avx2/-avx512
|
||||||
|
@ -177,6 +177,25 @@ int main(void)
|
|||||||
CXX_STANDARD 20
|
CXX_STANDARD 20
|
||||||
)
|
)
|
||||||
|
|
||||||
|
qt_config_compile_test(cxx2b
|
||||||
|
LABEL "C++2b support"
|
||||||
|
CODE
|
||||||
|
"#if __cplusplus > 202002L
|
||||||
|
// Compiler claims to support C++2B, trust it
|
||||||
|
#else
|
||||||
|
# error __cplusplus must be > 202002L (the value for C++20)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
/* BEGIN TEST: */
|
||||||
|
/* END TEST: */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
CXX_STANDARD 23
|
||||||
|
)
|
||||||
|
|
||||||
# precompile_header
|
# precompile_header
|
||||||
qt_config_compile_test(precompile_header
|
qt_config_compile_test(precompile_header
|
||||||
LABEL "precompiled header support"
|
LABEL "precompiled header support"
|
||||||
@ -642,6 +661,11 @@ qt_feature("c++2b" PUBLIC
|
|||||||
AUTODETECT OFF
|
AUTODETECT OFF
|
||||||
)
|
)
|
||||||
qt_feature_config("c++2b" QMAKE_PUBLIC_QT_CONFIG)
|
qt_feature_config("c++2b" QMAKE_PUBLIC_QT_CONFIG)
|
||||||
|
qt_feature("c++2b" PUBLIC
|
||||||
|
LABEL "C++2b"
|
||||||
|
AUTODETECT FALSE
|
||||||
|
CONDITION QT_FEATURE_cxx20 AND (CMAKE_VERSION VERSION_GREATER_EQUAL "3.20") AND TEST_cxx2b
|
||||||
|
)
|
||||||
qt_feature("c89"
|
qt_feature("c89"
|
||||||
LABEL "C89"
|
LABEL "C89"
|
||||||
)
|
)
|
||||||
@ -1061,7 +1085,7 @@ qt_configure_add_summary_entry(
|
|||||||
)
|
)
|
||||||
qt_configure_add_summary_entry(
|
qt_configure_add_summary_entry(
|
||||||
TYPE "firstAvailableFeature"
|
TYPE "firstAvailableFeature"
|
||||||
ARGS "c++20 c++17 c++14 c++11"
|
ARGS "c++2b c++20 c++17 c++14 c++11"
|
||||||
MESSAGE "Using C++ standard"
|
MESSAGE "Using C++ standard"
|
||||||
)
|
)
|
||||||
qt_configure_add_summary_entry(
|
qt_configure_add_summary_entry(
|
||||||
|
@ -138,18 +138,27 @@ function(qt_commandline_cxxstd arg val nextok)
|
|||||||
qtConfCommandlineSetInput(c++14 no)
|
qtConfCommandlineSetInput(c++14 no)
|
||||||
qtConfCommandlineSetInput(c++17 no)
|
qtConfCommandlineSetInput(c++17 no)
|
||||||
qtConfCommandlineSetInput(c++20 no)
|
qtConfCommandlineSetInput(c++20 no)
|
||||||
|
qtConfCommandlineSetInput(c++2b no)
|
||||||
elseif(val MATCHES "(c\\+\\+)?(14|1y)")
|
elseif(val MATCHES "(c\\+\\+)?(14|1y)")
|
||||||
qtConfCommandlineSetInput(c++14 yes)
|
qtConfCommandlineSetInput(c++14 yes)
|
||||||
qtConfCommandlineSetInput(c++17 no)
|
qtConfCommandlineSetInput(c++17 no)
|
||||||
qtConfCommandlineSetInput(c++20 no)
|
qtConfCommandlineSetInput(c++20 no)
|
||||||
|
qtConfCommandlineSetInput(c++2b no)
|
||||||
elseif(val MATCHES "(c\\+\\+)?(17|1z)")
|
elseif(val MATCHES "(c\\+\\+)?(17|1z)")
|
||||||
qtConfCommandlineSetInput(c++14 yes)
|
qtConfCommandlineSetInput(c++14 yes)
|
||||||
qtConfCommandlineSetInput(c++17 yes)
|
qtConfCommandlineSetInput(c++17 yes)
|
||||||
qtConfCommandlineSetInput(c++20 no)
|
qtConfCommandlineSetInput(c++20 no)
|
||||||
|
qtConfCommandlineSetInput(c++2b no)
|
||||||
elseif(val MATCHES "(c\\+\\+)?(20|2a)")
|
elseif(val MATCHES "(c\\+\\+)?(20|2a)")
|
||||||
qtConfCommandlineSetInput(c++14 yes)
|
qtConfCommandlineSetInput(c++14 yes)
|
||||||
qtConfCommandlineSetInput(c++17 yes)
|
qtConfCommandlineSetInput(c++17 yes)
|
||||||
qtConfCommandlineSetInput(c++20 yes)
|
qtConfCommandlineSetInput(c++20 yes)
|
||||||
|
qtConfCommandlineSetInput(c++2b no)
|
||||||
|
elseif(val MATCHES "(c\\+\\+)?(2b)")
|
||||||
|
qtConfCommandlineSetInput(c++14 yes)
|
||||||
|
qtConfCommandlineSetInput(c++17 yes)
|
||||||
|
qtConfCommandlineSetInput(c++20 yes)
|
||||||
|
qtConfCommandlineSetInput(c++2b yes)
|
||||||
else()
|
else()
|
||||||
qtConfAddError("Invalid argument '${val}' to command line parameter '${arg}'")
|
qtConfAddError("Invalid argument '${val}' to command line parameter '${arg}'")
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user