Skip to content

Conversation

@deepin-ci-robot
Copy link
Contributor

@deepin-ci-robot deepin-ci-robot commented Jan 6, 2026

Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#556

Summary by Sourcery

Switch the build configuration to derive DTK/Qt major version and naming from a DTK5 option and the VERSION file, unifying how DTK5 and DTK6 variants are handled.

Build:

  • Read the project version directly from the VERSION file and propagate it via DTK_VERSION variables for use in CMake, packaging, and documentation.
  • Replace PROJECT_VERSION-based DTK/Qt selection with a DTK5 option that controls DTK/Qt major version, library/binary naming suffixes, and install/config paths.
  • Rename CMake export targets, pkg-config files, examples, and plugins to consistently use the DTK_NAME_SUFFIX-based naming for DTK5 and DTK6 builds.

Documentation:

  • Use the unified DTK_VERSION for Doxygen project numbering and adjust Qt help tooling selection based on the DTK5 option.

Tests:

  • Enable CTest for the test suite and align test build conditions and resource handling with the new DTK5 toggle.

Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#556
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 6, 2026

Reviewer's Guide

Synchronizes the build and packaging configuration with upstream dtkdeclarative by switching from version-derived Qt/DTK selection to an explicit DTK5 option, introducing DTK name suffix handling, and consistently updating library, module, examples, tests, and docs CMake files to use the new variables and versioning scheme.

Flow diagram for DTK5 option and version configuration in CMakeLists

flowchart TD
    A_read_version[file_READ_VERSION]
    B_strip_version[string_STRIP_VERSION]
    C_project[project_DtkDeclarative_VERSION_FILE_VERSION]
    D_option_DTK5[option_DTK5_default_ON]
    E{DTK5}
    F_set_DTK5[set_DTK_VERSION_MAJOR_5\nset_DTK_NAME_SUFFIX_empty]
    G_set_DTK6[set_DTK_VERSION_MAJOR_6\nset_DTK_NAME_SUFFIX_6]
    H_set_DTK_VERSION[set_DTK_VERSION_MINOR\nset_DTK_VERSION_PATCH\nset_DTK_VERSION]
    I_set_QT_VERSION_MAJOR[set_QT_VERSION_MAJOR_DTK_VERSION_MAJOR]
    J_set_LIB_NAME[set_LIB_NAME_dtk_DTK_NAME_SUFFIX_declarative]
    K_set_paths[set_INCLUDE_INSTALL_DIR_dtk_DTK_VERSION_MAJOR\nset_CONFIG_INSTALL_DIR_Dtk_DTK_NAME_SUFFIX_Declarative\nset_DDECLARATIVE_TRANSLATIONS_DIR_dtk_DTK_VERSION_MAJOR]
    L_add_subdirs_DTK5[add_subdirectory_src\nadd_subdirectory_qmlplugin]
    M_add_subdirs_DTK6[add_subdirectory_qt6]
    N_enable_testing[enable_testing_if_BUILD_TESTING]
    O_config_files[configure_package_config_file_Dtk_DTK_NAME_SUFFIX_DeclarativeConfig\nwrite_basic_package_version_file_Dtk_DTK_NAME_SUFFIX_DeclarativeConfigVersion]

    A_read_version --> B_strip_version --> C_project --> D_option_DTK5 --> E
    E -->|ON| F_set_DTK5
    E -->|OFF| G_set_DTK6
    F_set_DTK5 --> H_set_DTK_VERSION
    G_set_DTK6 --> H_set_DTK_VERSION
    H_set_DTK_VERSION --> I_set_QT_VERSION_MAJOR --> J_set_LIB_NAME --> K_set_paths
    E -->|DTK5_ON| L_add_subdirs_DTK5
    E -->|DTK5_OFF| M_add_subdirs_DTK6
    H_set_DTK_VERSION --> N_enable_testing
    H_set_DTK_VERSION --> O_config_files
Loading

File-Level Changes

Change Details Files
Refactor top-level CMake project versioning and DTK/Qt selection to use FILE_VERSION and a DTK5 option with DTK name suffix support.
  • Read VERSION into FILE_VERSION and use it directly as the project VERSION instead of a cached DTK_VERSION variable.
  • Replace PROJECT_VERSION_MAJOR-based DTK/Qt switching with a DTK5 option that sets DTK_VERSION_MAJOR and DTK_NAME_SUFFIX for DTK5 vs DTK6 builds.
  • Derive DTK_VERSION, QT_VERSION_MAJOR, and library name (LIB_NAME) from DTK_VERSION_MAJOR/DTK_NAME_SUFFIX instead of project version majors.
  • Adjust install/include/config/translation directory variables to use DTK_VERSION_MAJOR or DTK_NAME_SUFFIX as appropriate.
  • Enable CTest via enable_testing() when BUILD_TESTING is ON and adjust test dependencies based on DTK5 flag.
  • Update QML template Qt version index logic to check DTK5 instead of EnableQt5.
  • Change CMake package config and version file names, pkg-config file names, and install paths to be based on DTK_NAME_SUFFIX and DTK_VERSION.
CMakeLists.txt
Update example applications, main library targets, and QML plugins to use DTK_NAME_SUFFIX-based package names and refined DTK5 conditions.
  • Rename example binary and adjust example install dir to use DTK_NAME_SUFFIX/DTK_VERSION_MAJOR and DTK5 logic.
  • Change find_package and target_link_libraries references from Dtk${DTK_VERSION_MAJOR}* to Dtk${DTK_NAME_SUFFIX}* in examples, src targets, qml plugins, and tests.
  • Switch Qt resource selection and compilation in examples and tests from EnableQt5/EnableQt6 to DTK5-based conditionals.
  • Align library VERSION/SOVERSION properties with DTK_VERSION/DTK_VERSION_MAJOR instead of CMAKE_PROJECT_VERSION/CMAKE_PROJECT_VERSION_MAJOR.
  • Adjust export target names, namespaces, and install exports for Declarative and DeclarativeProperties to use DTK_NAME_SUFFIX.
examples/exhibition/CMakeLists.txt
examples/qml-inspect/CMakeLists.txt
src/targets.cmake
src/src.cmake
qt6/src/CMakeLists.txt
qmlplugin/targets.cmake
chameleon/CMakeLists.txt
tests/CMakeLists.txt
tests/apploaderplugindump/maincomponentplugin/CMakeLists.txt
tests/apploaderplugindump/preloadplugin/CMakeLists.txt
Align DTK5/DTK6-specific source selection and documentation versioning with the new DTK5 flag and DTK_VERSION variable.
  • Replace EnableDtk5/EnableDtk6 usage with DTK5/NOT DTK5 in src.cmake for handling DTK5-only headers and DTK6-only removals.
  • Normalize indentation in DTK6-only removal lists.
  • Set Doxygen project number to DTK_VERSION instead of CMAKE_PROJECT_VERSION and update Qt component search to use DTK5 flag instead of EnableQt5.
src/src.cmake
docs/CMakeLists.txt
misc/DtkDeclarativeConfig.cmake.in
misc/dtkdeclarative.pc.in
misc/qt_lib_dtkdeclarative.pri.in

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

@deepin-ci-robot
Copy link
Contributor Author

deepin pr auto review

我来对这个CMakeLists.txt的变更进行审查:

  1. 语法逻辑改进:
  • 将原来基于版本号的条件判断改为基于DTK5选项的判断,这样更直观且易于维护
  • 使用option(DTK5)替代了原来的版本号判断,逻辑更清晰
  • 统一使用DTK_NAME_SUFFIX变量来处理版本后缀,避免了多处重复的版本号判断
  1. 代码质量改进:
  • 添加了enable_testing(),使测试框架更完整
  • 删除了一些不必要的变量定义和条件判断
  • 统一了命名风格,如DTK_VERSION相关变量的命名更加一致
  • 优化了版本控制逻辑,使用DTK5选项来控制不同版本的构建
  1. 性能改进:
  • 移除了冗余的条件判断,减少了CMake配置时间
  • 简化了版本控制逻辑,提高了构建效率
  1. 安全性改进:
  • 统一了版本控制方式,降低了因版本判断不一致导致的安全风险
  • 使用更严格的变量作用域控制

建议:

  1. 考虑添加对DTK5选项的验证,确保其值只能是ON或OFF
  2. 可以考虑添加对DTK_VERSION的格式验证,确保版本号格式正确
  3. 建议在关键路径添加更多的错误检查和错误信息输出

总的来说,这次变更主要改进了版本控制逻辑,使代码更加清晰和易于维护,是一个正向的改进。

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 - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `docs/CMakeLists.txt:20` </location>
<code_context>
+if (DTK5)
     find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Help)
 else()
     find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ToolsTools)
</code_context>

<issue_to_address>
**issue (bug_risk):** The `ToolsTools` Qt component name looks like a typo and will likely break `find_package`.

The original code used `Help`, and Qt modules are typically named `Tools`, not `ToolsTools`. This will likely cause CMake configuration to fail. Please verify the correct module name (e.g., `Tools`) and update the `find_package` call.
</issue_to_address>

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.

if (DTK5)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Help)
else()
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ToolsTools)
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): The ToolsTools Qt component name looks like a typo and will likely break find_package.

The original code used Help, and Qt modules are typically named Tools, not ToolsTools. This will likely cause CMake configuration to fail. Please verify the correct module name (e.g., Tools) and update the find_package call.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

  • 敏感词检查失败, 检测到1个文件存在敏感词
详情
{
    "CMakeLists.txt": [
        {
            "line": "    HOMEPAGE_URL \"https://github.com/linuxdeepin/dtkdeclarative\"",
            "line_number": 9,
            "rule": "S35",
            "reason": "Url link | e63b02d733"
        }
    ]
}

@deepin-ci-robot
Copy link
Contributor Author

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-ci-robot

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

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