Skip to content

qt: fix Platform component #26524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

maksim-petukhov
Copy link
Contributor

@maksim-petukhov maksim-petukhov commented Feb 4, 2025

Summary

Changes to recipe: qt/6.x

Motivation and Details

Qt6::Platform component and its relationship with Qt6::Core differ from the upstream ones. This prevents me from compiling one of the closed-source libraries (QtitanRibbon) using Qt6 taken from CCI.

Actually Qt6::Core depends on Qt6::Platform, see <package>\lib\cmake\Qt6Core\Qt6CoreTargets.cmake:

set_target_properties(Qt6::Core PROPERTIES
  COMPATIBLE_INTERFACE_STRING "QT_MAJOR_VERSION;QT_COORD_TYPE"
  INTERFACE_COMPILE_DEFINITIONS "QT_CORE_LIB"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/QtCore;${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "Qt6::Platform;mpr;userenv;WrapAtomic::WrapAtomic;\$<\$<AND:\$<NOT:\$<BOOL:\$<TARGET_PROPERTY:qt_no_entrypoint>>>,\$<STREQUAL:\$<TARGET_PROPERTY:TYPE>,EXECUTABLE>,\$<BOOL:\$<TARGET_PROPERTY:WIN32_EXECUTABLE>>>:Qt6::EntryPointPrivate>"
  ...
)

And -permissive- and -Zc:__cplusplus flags come from Qt6::Platform, not from Qt6::Core, see <package>\lib\cmake\Qt6\Qt6Targets.cmake:

# Create imported target Qt6::Platform
add_library(Qt6::Platform INTERFACE IMPORTED)

set_target_properties(Qt6::Platform PROPERTIES
  INTERFACE_COMPILE_DEFINITIONS "WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;_WIN64;\$<\$<NOT:\$<BOOL:\$<TARGET_PROPERTY:QT_NO_UNICODE_DEFINES>>>:UNICODE\$<SEMICOLON>_UNICODE>"
  INTERFACE_COMPILE_FEATURES "cxx_std_17"
  INTERFACE_COMPILE_OPTIONS "\$<\$<AND:\$<CXX_COMPILER_ID:MSVC>,\$<COMPILE_LANGUAGE:CXX>>:-Zc:__cplusplus;-permissive->;\$<\$<AND:\$<NOT:\$<BOOL:\$<TARGET_PROPERTY:QT_NO_UTF8_SOURCE>>>,\$<COMPILE_LANGUAGE:C,CXX>>:\$<\$<CXX_COMPILER_ID:MSVC>:-utf-8>>"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/mkspecs/win32-msvc;${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "Threads::Threads"
  _qt_package_version "6.7.3"
)

there we can also see that it "links" to Threads::Threads. There are also conditional compile definitions and compile options which are missing (_UNICODE and -utf-8). You can look at this file https://github.com/qt/qtbase/blob/92b685784960eea6eb353688cf0edeb94d69c6cd/cmake/QtPlatformTargetHelpers.cmake#L61 to get a better idea where they come from (see calls to qt_set_msvc_cplusplus_options, qt_enable_utf8_sources, qt_internal_enable_unicode_defines). And you can also notice that Qt6::Platform requires log library on Android.

These changes are also required for these documented functions to work: https://doc.qt.io/qt-6/qt-disable-unicode-defines.html, https://doc.qt.io/qt-6/qt-allow-non-utf8-sources.html.


@maksim-petukhov maksim-petukhov changed the title qt6: fix Platform component qt: fix Platform component Mar 25, 2025
@maksim-petukhov maksim-petukhov force-pushed the qt6-platform branch 2 times, most recently from 85e7087 to 6fcccd9 Compare March 27, 2025 15:34
@maksim-petukhov
Copy link
Contributor Author

@jcar87 @uilianries @perseoGI @AbrilRBS @franramirez688 friendly pinging for a review

Copy link
Member

@uilianries uilianries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maksim-petukhov Hello 👋

Thank you for giving those details, it's clear there is a window for improvement.

This prevents me from compiling one of the closed-source libraries (QtitanRibbon) using Qt6 taken from CCI.

At least you could inform what error occurs and the compilation error? So we can have a better view of the current limitation of this component.

@maksim-petukhov
Copy link
Contributor Author

@uilianries Hi

I believe these were the compilation errors:

D:/conan2/qtd87b8da2e6f46/p/lib/cmake/Qt6Core/../../../include/QtCore/6.7.3\QtCore/private/qthread_p.h(20,10): fatal error C1083: Cannot open include file: qplatformdefs.h: No such file or directory, (compiling D:\conan2\b\qtitaa7da151c5cba7\b\src\base\QtnBackstageWidget.cpp) [D:\conan2\b\qtitaa7da151c5cba7\b\build\QtitanRibbon.vcxproj]
D:\conan2\b\qtitaa7da151c5cba7\b\src\base\QtnPlatform_win.cpp(1328,64): error C2664: "QFont QWindowsFontDatabaseBase::LOGFONT_to_QFont(const LOGFONT &,int)": cannot convert argument 1 from "const LOGFONTW" to "const LOGFONT &" [D:\conan2\b\qtitaa7da151c5cba7\b\build\QtitanRibbon.vcxproj]

The initial comment in this PR already includes some context around the issue: this component is clearly not aligned with the upstream version. Feel free to take another look at the initial comment when you get a chance - that might help clarify things a bit further

@maksim-petukhov
Copy link
Contributor Author

@uilianries is there anything else I can do to move this forward?

@uilianries
Copy link
Member

@maksim-petukhov Hello, we have been discussing internally about this PR and we doing a very detailed review, as the Qt package is really fragile and affects several users.

My only concern right now is the UTF-8 extra code in this PR. It fits for this current version, but it's one more extra point to be always reviewed in the future, to make sure nothing changed in Qt and result in unexpected behavior based on the upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants