Add a separate QT_FEATURE for std::format
We want tst_qfloat16 to be built in C++20 mode, even if Qt itself is not built in C++20 mode, which means we can't use QT_FEATURE_cxx20 as check in tst_qfloat16's CMakeLists.txt. In addition, even if the compiler supports C++20, the standard library may not support all features we need. Specifically, due to the deployment target of macOS being 12 we can't rely on std::to_chars being available, as is only available since macOS 13.4. This patch introduces a separate QT_FEATURE_cxx20_format, and adjusts the tst_qfloat16's CMakeLists.txt to use this feature. Note that we intentionally do not add QT_FEATURE_cxx20 as a hard condition to the new check, because it might be disabled during the Qt configuration, but we still want the test to be built in C++20 mode. Note also, that we cannot use the QT_CONFIG(cxx20_format) check in the qtformat_impl.h header, because the std::format support is header-only, and user project might be compiled for a different minimal macOS version, so we do not want to rely on the Qt-specific config. Pick-to: 6.9 6.8 Change-Id: Ibc43d243dbb24fcb922647fe2d90f61491144eb7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
d8fb42bb79
commit
f0573e93df
@ -552,6 +552,28 @@ int main(void)
|
||||
}
|
||||
")
|
||||
|
||||
# std::format support
|
||||
qt_config_compile_test(cxx20_format
|
||||
LABEL "C++20 std::format support"
|
||||
CODE
|
||||
"#include <format>
|
||||
#include <string>
|
||||
|
||||
#if !defined(__cpp_lib_format) || (__cpp_lib_format < 202106L)
|
||||
#error
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* BEGIN TEST: */
|
||||
const auto s = std::format(\"{}\", 1);
|
||||
/* END TEST: */
|
||||
return 0;
|
||||
}
|
||||
"
|
||||
CXX_STANDARD 20
|
||||
)
|
||||
|
||||
# <stacktrace>
|
||||
qt_config_compile_test(cxx23_stacktrace
|
||||
LABEL "C++23 <stacktrace> support"
|
||||
@ -849,6 +871,11 @@ qt_feature("backtrace" PRIVATE
|
||||
LABEL "backtrace"
|
||||
CONDITION UNIX AND QT_FEATURE_regularexpression AND WrapBacktrace_FOUND
|
||||
)
|
||||
qt_feature("cxx20_format" PRIVATE
|
||||
LABEL "C++20 std::format support"
|
||||
CONDITION TEST_cxx20_format # intentionally not checking QT_FEATURE_cxx20!
|
||||
AUTODETECT TRUE
|
||||
)
|
||||
qt_feature("cxx23_stacktrace" PRIVATE
|
||||
LABEL "C++23 <stacktrace>"
|
||||
CONDITION TEST_cxx23_stacktrace AND QT_FEATURE_cxx2b
|
||||
|
@ -19,7 +19,7 @@ qt_internal_add_test(tst_qfloat16
|
||||
)
|
||||
|
||||
# To test std::format support, if possible
|
||||
if(NOT VXWORKS)
|
||||
if(QT_FEATURE_cxx20_format)
|
||||
set_target_properties(tst_qfloat16
|
||||
PROPERTIES
|
||||
CXX_STANDARD 20
|
||||
|
Loading…
x
Reference in New Issue
Block a user