summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2022-01-31 12:32:10 +0100
committerOliver Wolff <oliver.wolff@qt.io>2022-02-01 16:51:01 +0100
commit24301726390eb97f9bd00ab5cb40b70d70e119fc (patch)
treef7a37fe535e79c87230248e34cda74fba26e72e5 /src
parent0ad8dd480509369091f91c2370ddfdd86506cd85 (diff)
configure: Check for basic cpp/winrt support
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 <fabian.kosmale@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/configure.cmake26
-rw-r--r--src/corelib/text/qlocale_win.cpp9
-rw-r--r--src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h2
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 <winrt/base.h>
+
+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 <time.h>
#endif
-#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG)
+#if QT_CONFIG(cpp_winrt) && !defined(Q_CC_CLANG)
# include <winrt/base.h>
// 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 <winrt/Windows.Foundation.h>
# include <winrt/Windows.Foundation.Collections.h>
# include <winrt/Windows.System.UserProfile.h>
-#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<wchar_t, 64> 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 <wrl/wrappers/corewrappers.h>
#include <comdef.h>
-#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG)
+#if QT_CONFIG(cpp_winrt) && !defined(Q_CC_CLANG)
#define SUPPORTS_WINRT 1
#endif