Skip to content

Conversation

@add-uos
Copy link
Contributor

@add-uos add-uos commented Dec 2, 2025

Update package dependencies and build configuration to support both Qt5 and Qt6 versions. The debian/control file now uses alternative syntax for Qt-related dependencies, allowing the package to build on systems with either Qt version. Added automatic Qt version detection in debian/rules to determine the appropriate CMake configuration at build time. This change improves package compatibility across different Debian/Ubuntu environments while maintaining the primary Qt6 support.

Summary by Sourcery

Add dual Qt5/Qt6 compatibility to the Debian packaging and build configuration.

Build:

  • Update Debian control dependencies to allow building with either Qt5 or Qt6.
  • Add Qt version auto-detection in debian/rules to configure CMake appropriately at build time.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 2, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds dual Qt5/Qt6 build support by relaxing Debian package dependencies and introducing automatic Qt version detection to drive the CMake configuration in debian/rules, while keeping Qt6 as the primary target.

File-Level Changes

Change Details Files
Allow building the package against either Qt5 or Qt6 via Debian dependency alternates.
  • Update Qt-related Build-Depends to use Qt5/Qt6 alternative dependency syntax so either version can satisfy the requirement.
  • Ensure binary package Depends (and any -dev package relationships) reflect the dual Qt5/Qt6 compatibility model, matching the build-time alternates.
  • Keep Qt6 as the preferred/default by ordering or selecting Qt6-first where relevant in dependency alternates.
debian/control
Add automatic Qt version detection in the build rules to select the appropriate CMake configuration.
  • Introduce logic to detect an available Qt major version (e.g., via qmake, pkg-config, or CMake package presence) at build time.
  • Set an environment variable or CMake option (such as -DQT_MAJOR_VERSION or Qt5/Qt6-specific flags) based on the detected Qt version.
  • Adjust existing dh_auto_configure / CMake invocation to pass the selected Qt version configuration while keeping Qt6 as the primary/expected path when both are present.
debian/rules

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@lzwind lzwind left a comment

Choose a reason for hiding this comment

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

缺包了 本地编译看下

@add-uos add-uos force-pushed the master branch 2 times, most recently from c6e87f8 to 364b4bf Compare December 2, 2025 07:18
@add-uos add-uos requested a review from lzwind December 2, 2025 07:35
@add-uos
Copy link
Contributor Author

add-uos commented Dec 2, 2025

/merge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Dec 2, 2025

This pr cannot be merged! (status: blocked)

Update package dependencies and build configuration to support both Qt5
and Qt6 versions. The debian/control file now uses alternative syntax
for Qt-related dependencies, allowing the package to build on systems
with either Qt version. Added automatic Qt version detection in
debian/rules to determine the appropriate CMake configuration at
build time. This change improves package compatibility across different
Debian/Ubuntu environments while maintaining the primary Qt6 support.
@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个diff进行详细的代码审查:

  1. 语法逻辑分析:
  • 代码在语法上是正确的,符合Debian包管理的规范和CMake的语法要求
  • 使用了正确的依赖关系符号(| 表示或关系)
  • CMakeLists.txt中的宏定义和条件判断逻辑合理
  1. 代码质量改进建议:
  • 在debian/control中,建议将相关的依赖分组,比如Qt相关的依赖放在一起,DTK相关的依赖放在一起,这样便于维护
  • debian/rules中的detect_qt_version宏可以考虑添加更多的错误处理机制
  • CMakeLists.txt中的SET_QT_VERSION宏可以优化,直接使用find_package的版本检测功能
  1. 代码性能优化:
  • debian/rules中启用了--parallel选项,这是好的实践
  • 建议在CMakeLists.txt中添加编译优化选项,如-O2
  1. 代码安全考虑:
  • 依赖版本的控制是合理的,使用了版本约束
  • 建议在debian/control中明确指定最低版本要求,而不是仅依赖或关系
  • CMakeLists.txt中的版本检查可以更加严格,避免使用不兼容的Qt版本

具体改进建议:

  1. debian/control改进:
Build-Depends: debhelper-compat (= 11),
 # Qt Dependencies
 qt6-base-dev (>= 6.2.0) | qtbase5-dev (>= 5.12.0),
 qt6-base-dev-tools | qtbase5-dev-tools,
 qt6-base-private-dev | qtbase5-private-dev,
 # DTK Dependencies
 libdtk6gui-dev (>= 6.0.0) | libdtkgui-dev (>= 5.4.0),
 libdtk6widget-dev (>= 6.0.0) | libdtkwidget-dev (>= 5.4.0),
 # Other Dependencies
 ...
  1. debian/rules改进:
define detect_qt_version
    ifneq (,$(shell which qmake6 2>/dev/null))
        QT_VERSION_MAJOR := 6
        QT_DIR := "/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/Qt6"
    else ifneq (,$(shell which qmake 2>/dev/null))
        QT_VERSION_MAJOR := 5
        QT_DIR := "/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/Qt5"
    else
        $(error Neither Qt5 nor Qt6 found)
    endif
endef
  1. CMakeLists.txt改进:
# 优先尝试Qt6
find_package(Qt6 COMPONENTS Core QUIET)
if(Qt6_FOUND)
    set(QT_VERSION_MAJOR 6)
else()
    # 回退到Qt5
    find_package(Qt5 COMPONENTS Core REQUIRED)
    set(QT_VERSION_MAJOR 5)
endif()

# 添加编译优化
if(CMAKE_BUILD_TYPE STREQUAL "Release")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
endif()

这些改进将提高代码的可维护性、性能和安全性,同时保持向后兼容性。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@add-uos
Copy link
Contributor Author

add-uos commented Dec 2, 2025

/merge

@deepin-bot deepin-bot bot merged commit a6947d2 into linuxdeepin:master Dec 2, 2025
18 checks passed
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.

3 participants