Repository navigation
fix: explicitly find Qt6 private components on Qt >= 6.10 - #256
Conversation
Reviewer's GuideConfigurationExplicitly find Qt 6.10+ private components so the application can resolve the WidgetsPrivate and GuiPrivate targets while preserving older Qt behavior.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="application/CMakeLists.txt" line_range="31" />
<code_context>
+# Qt 6.10 起,私有模块目标(如 Qt6::WidgetsPrivate/GuiPrivate)拆分为独立 CMake 包,
+# 不再随主模块查找自动创建,需显式查找;更早版本由各 Targets.cmake 自动创建
+if (QT_VERSION_MAJOR MATCHES 6 AND Qt6_VERSION VERSION_GREATER_EQUAL 6.10)
+ find_package(Qt6 REQUIRED COMPONENTS WidgetsPrivate GuiPrivate)
+endif()
+
</code_context>
<issue_to_address>
**Private headers remain unavailable**
When configuring with Qt 6.10 or newer and compiling code in an earlier or sibling directory that needs Qt GUI private headers, `find_package` creates the private targets in the application directory, so earlier and sibling directories cannot use them; meanwhile, `target_include_directories` treats `Qt6::GuiPrivate` as a directory string instead of applying its interface include paths. Compilation fails to find the private headers.
Make the private targets available to all consuming directories and link the appropriate private target to each consumer instead of passing it to `target_include_directories`.
Also at `application/CMakeLists.txt:32`.
</issue_to_address>| # Qt 6.10 起,私有模块目标(如 Qt6::WidgetsPrivate/GuiPrivate)拆分为独立 CMake 包, | ||
| # 不再随主模块查找自动创建,需显式查找;更早版本由各 Targets.cmake 自动创建 | ||
| if (QT_VERSION_MAJOR MATCHES 6 AND Qt6_VERSION VERSION_GREATER_EQUAL 6.10) | ||
| find_package(Qt6 REQUIRED COMPONENTS WidgetsPrivate GuiPrivate) |
There was a problem hiding this comment.
🟠 High · Private headers remain unavailable
When configuring with Qt 6.10 or newer and compiling code in an earlier or sibling directory that needs Qt GUI private headers, find_package creates the private targets in the application directory, so earlier and sibling directories cannot use them; meanwhile, target_include_directories treats Qt6::GuiPrivate as a directory string instead of applying its interface include paths. Compilation fails to find the private headers.
Make the private targets available to all consuming directories and link the appropriate private target to each consumer instead of passing it to target_include_directories.
Also at application/CMakeLists.txt:32.
Prompt for AI agents
In `application/CMakeLists.txt` at line 31:
**Private headers remain unavailable**
When configuring with Qt 6.10 or newer and compiling code in an earlier or sibling directory that needs Qt GUI private headers, `find_package` creates the private targets in the application directory, so earlier and sibling directories cannot use them; meanwhile, `target_include_directories` treats `Qt6::GuiPrivate` as a directory string instead of applying its interface include paths. Compilation fails to find the private headers.
Make the private targets available to all consuming directories and link the appropriate private target to each consumer instead of passing it to `target_include_directories`.
Also at `application/CMakeLists.txt:32`.1. Qt 6.10 splits private module targets into standalone CMake packages, so Qt6::WidgetsPrivate/GuiPrivate are no longer auto-created by the main module's Targets.cmake 2. Linking Qt6::WidgetsPrivate now fails at configure time on the Qt 6.12 build server: Target "deepin-diskmanager" links to Qt6::WidgetsPrivate but the target was not found 3. GuiPrivate in target_include_directories silently degrades to a literal string on 6.12, losing private header paths; find it too 4. Gate behind Qt6_VERSION >= 6.10; Qt <= 6.9 (incl. 6.8 baseline) keeps the auto-created targets, behavior unchanged Log: Fixed diskmanager configure failure on Qt 6.12 caused by private module targets being split into standalone CMake packages Influence: 1. Configure deepin-diskmanager against Qt 6.12, cmake passes 2. Verify private widget/gui headers still resolve at compile time 3. On Qt 6.8 confirm configure and build behavior unchanged fix: 显式查找 Qt6 私有组件以适配 Qt 6.10+ 1. Qt 6.10 将私有模块目标拆分为独立 CMake 包, Qt6::WidgetsPrivate/GuiPrivate 不再随主模块查找自动创建 2. Qt 6.12 服务器上链接 Qt6::WidgetsPrivate 在 configure 阶段 失败:Target "deepin-diskmanager" links to Qt6::WidgetsPrivate but the target was not found 3. target_include_directories 中的 GuiPrivate 在 6.12 下退化为 普通字符串,丢失私有头文件路径,一并显式查找 4. 以 Qt6_VERSION >= 6.10 门禁;Qt <= 6.9(含 6.8 基线)保持 自动创建行为不变 Log: 修复磁盘管理在 Qt 6.12 下因私有模块目标拆分导致的 configure 失败 Influence: 1. 在 Qt 6.12 环境配置磁盘管理,cmake 通过 2. 验证编译期私有 widget/gui 头文件路径仍正确解析 3. 在 Qt 6.8 环境确认 configure 与构建行为不变
a1f0539 to
e152df4
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
Problem
Building deepin-diskmanager 6.0.28 on the Qt 6.12 build server fails at the cmake configure step:
Since Qt 6.10, private module targets are shipped as standalone CMake packages (
Qt6WidgetsPrivateConfig.cmake, installed byqt6-base-devundercmake/Qt6WidgetsPrivate/) and are no longer auto-created by the main module'sTargets.cmake. Both usages inapplication/CMakeLists.txtare affected:target_link_libraries(... Qt6::WidgetsPrivate ...)— hard configure error (the reported failure)target_include_directories(... Qt6::GuiPrivate ...)— silently degrades to a literal string on 6.12, losing the private header include paths (compile failure later)Same failure family and same fix pattern as linuxdeepin/deepin-screensaver#139 and linuxdeepin/dde-device-formatter#52.
Solution
After the main
find_package(Qt...)call, explicitlyfind_package(Qt6 REQUIRED COMPONENTS WidgetsPrivate GuiPrivate)gated byQt6_VERSION >= 6.10. On Qt <= 6.9 (including the 6.8 baseline) the version gate evaluates false and the targets are still auto-created — behavior unchanged.Testing
qt6-base-dev 6.12.0-1package contents:cmake/Qt6WidgetsPrivate/Qt6WidgetsPrivateTargets.cmake:69andcmake/Qt6GuiPrivate/Qt6GuiPrivateTargets.cmake:69both defineadd_library(Qt6::... INTERFACE IMPORTED)— exactly the packages this explicit lookup consumesSummary by Sourcery
Fix CMake configuration for Qt 6.10 and newer by explicitly finding the private Qt Widgets and Gui components.
Bug Fixes:
Build: