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>
bb10
Oliver Wolff 2022-01-31 12:32:10 +01:00
parent 0ad8dd4805
commit 2430172639
3 changed files with 31 additions and 6 deletions

View File

@ -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
)

View File

@ -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);

View File

@ -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