From 24301726390eb97f9bd00ab5cb40b70d70e119fc Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 31 Jan 2022 12:32:10 +0100 Subject: [PATCH] configure: Check for basic cpp/winrt support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some configurations (like MSVC2019 with c++20 on Windows 10) fail to compile winrt/cpp headers as these include experimental coroutines unconditionally. In these cases we can fall back to the legacy implementation. Pick-to: 6.2 6.3 Change-Id: Ibd574995f8ca1f865bbcdabede1ffcd0c340022f Reviewed-by: Fabian Kosmale Reviewed-by: Ivan Solovev Reviewed-by: Alexandru Croitor Reviewed-by: MÃ¥rten Nordheim --- src/corelib/configure.cmake | 26 +++++++++++++++++++ src/corelib/text/qlocale_win.cpp | 9 +++---- .../qnetworklistmanagerevents.h | 2 +- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index 107028bfac..96b580a0b6 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -460,6 +460,21 @@ closelog(); } ") +# cpp_winrt +qt_config_compile_test(cpp_winrt + LABEL "cpp/winrt" + LIBRARIES + runtimeobject + CODE +"// Including winrt/base.h causes an error in some configurations (Windows 10 SDK + c++20) +# include + +int main(void) +{ + return 0; +} +") + # xlocalescanprint qt_config_compile_test(xlocalescanprint LABEL "xlocale.h (or equivalents)" @@ -706,6 +721,11 @@ qt_feature("xmlstream" PUBLIC LABEL "XML Streaming APIs" PURPOSE "Provides a simple streaming API for XML." ) +qt_feature("cpp-winrt" PRIVATE + LABEL "cpp/winrt base" + PURPOSE "basic cpp/winrt language projection support" + CONDITION WIN32 AND TEST_cpp_winrt +) qt_feature_definition("xmlstream" "QT_NO_XMLSTREAM" NEGATE VALUE "1") qt_feature("xmlstreamreader" PUBLIC SECTION "Kernel" @@ -924,6 +944,7 @@ qt_configure_add_summary_entry(ARGS "glib") qt_configure_add_summary_entry(ARGS "icu") qt_configure_add_summary_entry(ARGS "system-libb2") qt_configure_add_summary_entry(ARGS "mimetype-database") +qt_configure_add_summary_entry(ARGS "cpp-winrt") qt_configure_add_summary_entry( TYPE "firstAvailableFeature" ARGS "etw lttng" @@ -970,3 +991,8 @@ qt_configure_add_report_entry( MESSAGE "Qt requires poll(), ppoll(), poll_ts() or select() on this platform" CONDITION ( UNIX OR INTEGRITY ) AND ( NOT QT_FEATURE_poll_ppoll ) AND ( NOT QT_FEATURE_poll_pollts ) AND ( NOT QT_FEATURE_poll_poll ) AND ( NOT QT_FEATURE_poll_select ) ) +qt_configure_add_report_entry( + TYPE WARNING + MESSAGE "Basic cpp/winrt support missing. Some features might not be available." + CONDITION MSVC AND NOT QT_FEATURE_cpp_winrt +) diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index dafe441ee0..e5f5781208 100644 --- a/src/corelib/text/qlocale_win.cpp +++ b/src/corelib/text/qlocale_win.cpp @@ -53,7 +53,7 @@ # include #endif -#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) +#if QT_CONFIG(cpp_winrt) && !defined(Q_CC_CLANG) # include // Workaround for Windows SDK bug. // See https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47 @@ -65,7 +65,7 @@ namespace winrt::impl # include # include # include -#endif // defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) +#endif // QT_CONFIG(cpp_winrt) && !defined(Q_CC_CLANG) QT_BEGIN_NAMESPACE @@ -694,16 +694,15 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS QVariant QSystemLocalePrivate::uiLanguages() { QStringList result; -#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) // msvc supports WinRT calls +#if QT_CONFIG(cpp_winrt) && !defined(Q_CC_CLANG) using namespace winrt; - using namespace Windows::Foundation; using namespace Windows::System::UserProfile; auto languages = GlobalizationPreferences::Languages(); for (const auto &lang : languages) result << QString::fromStdString(winrt::to_string(lang)); if (!result.isEmpty()) return result; // else just fall back to WIN32 API implementation -#endif // defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) +#endif // QT_CONFIG(cpp_winrt) && !defined(Q_CC_CLANG) // mingw and clang still have to use Win32 API unsigned long cnt = 0; QVarLengthArray buf(64); diff --git a/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h b/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h index 4c4625adb5..5bb2b2d9c0 100644 --- a/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h +++ b/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h @@ -51,7 +51,7 @@ #include #include -#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) +#if QT_CONFIG(cpp_winrt) && !defined(Q_CC_CLANG) #define SUPPORTS_WINRT 1 #endif