refactor: centralize PROJECT_VERSION_MAJOR configuration in root CMakeLists#284
Merged
Johnson-zs merged 1 commit intolinuxdeepin:masterfrom May 6, 2026
Merged
refactor: centralize PROJECT_VERSION_MAJOR configuration in root CMakeLists#284Johnson-zs merged 1 commit intolinuxdeepin:masterfrom
Johnson-zs merged 1 commit intolinuxdeepin:masterfrom
Conversation
…eLists Moved PROJECT_VERSION_MAJOR definition from submodule cmake files to root CMakeLists.txt for unified version management Qt6 build sets PROJECT_VERSION_MAJOR to 1 (libdfm-*.so.1) Qt5 build sets PROJECT_VERSION_MAJOR to 0 (libdfm-*.so.0) Removed redundant PROJECT_VERSION_MAJOR settings from: - src/dfm-burn/dfm-burn-lib/dfm-burn.cmake - src/dfm-io/dfm-io/dfm-io.cmake - src/dfm-mount/dfm-mount.cmake This change ensures consistent SOVERSION across all submodules and simplifies version management by having a single source of truth The change maintains binary compatibility while improving build configuration clarity Influence: 1. Verify libdfm-burn.so.* has correct SOVERSION after build 2. Verify libdfm-io.so.* has correct SOVERSION after build 3. Verify libdfm-mount.so.* has correct SOVERSION after build 4. Check Qt5 build produces libdfm-*.so.0 5. Check Qt6 build produces libdfm-*.so.1 refactor: 将 PROJECT_VERSION_MAJOR 配置集中到根 CMakeLists 中 将 PROJECT_VERSION_MAJOR 定义从子模块 cmake 文件移到根 CMakeLists.txt 实现统一的版本管理 Qt6 构建设置 PROJECT_VERSION_MAJOR 为 1 (libdfm-*.so.1) Qt5 构建设置 PROJECT_VERSION_MAJOR 为 0 (libdfm-*.so.0) 移除了以下文件中的冗余 PROJECT_VERSION_MAJOR 设置: - src/dfm-burn/dfm-burn-lib/dfm-burn.cmake - src/dfm-io/dfm-io/dfm-io.cmake - src/dfm-mount/dfm-mount.cmake 此变更确保所有子模块的 SOVERSION 一致,并通过单一配置源简化版本管理 该变更保持二进制兼容性的同时提高了构建配置的清晰度 Influence: 1. 验证构建后 libdfm-burn.so.* 具有正确的 SOVERSION 2. 验证构建后 libdfm-io.so.* 具有正确的 SOVERSION 3. 验证构建后 libdfm-mount.so.* 具有正确的 SOVERSION 4. 检查 Qt5 构建产生 libdfm-*.so.0 5. 检查 Qt6 构建产生 libdfm-*.so.1
deepin pr auto review这份 Git Diff 展示了对 CMake 构建系统中版本号管理逻辑的修改。主要改动是将 以下是对该改动的详细审查意见,涵盖语法逻辑、代码质量、代码性能和代码安全四个方面: 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
总结与改进建议代码建议对根 # ... 前面的代码 ...
# 确保 OPT_ENABLE_QT6 已定义
if(NOT DEFINED OPT_ENABLE_QT6)
option(OPT_ENABLE_QT6 "Build with Qt6" OFF)
endif()
if(OPT_ENABLE_QT6)
# 检查 Qt6 是否真的可用,而不仅仅是选项开启
find_package(Qt6 COMPONENTS Core QUIET)
if(Qt6_FOUND)
set(DFM_BUILD_WITH_QT6 TRUE)
set(QT_VERSION_MAJOR 6)
set(DFM_VERSION_MAJOR 6)
# 明确设置项目版本,建议与 Qt 版本解耦,除非它们确实是一一对应的
# 如果 Qt6 版本对应项目主版本 1,则保持原样
set(PROJECT_VERSION_MAJOR 1)
else()
message(WARNING "OPT_ENABLE_QT6 is ON, but Qt6 was not found. Falling back to Qt5.")
set(DFM_BUILD_WITH_QT6 FALSE)
endif()
endif()
# 统一处理非 Qt6 (即 Qt5) 的情况
if(NOT DFM_BUILD_WITH_QT6)
find_package(Qt5 COMPONENTS Core QUIET)
if(NOT Qt5_FOUND)
message(FATAL_ERROR "Neither Qt6 nor Qt5 was found.")
endif()
message(STATUS "Building with Qt5.")
set(QT_VERSION_MAJOR 5)
# 建议:根据项目规划设置 DFM_VERSION_MAJOR
# 如果 Qt5 分支是旧版本,设为 0 或 5 均可,但需明确
set(DFM_VERSION_MAJOR 5)
# 建议:明确 Qt5 构建对应的项目主版本
set(PROJECT_VERSION_MAJOR 0)
endif()
# ... 后面的代码 ...针对子模块 (dfm-burn.cmake 等) 的建议: 虽然移除了默认值设置,但建议保留一个断言,确保变量已被定义,以便在配置出错时提供清晰的错误信息: # 在子模块 .cmake 文件中
if (NOT VERSION)
set(VERSION "1.0.0")
endif()
# 防御性检查:确保根目录已经设置了主版本号
if(NOT DEFINED PROJECT_VERSION_MAJOR)
message(FATAL_ERROR "PROJECT_VERSION_MAJOR is not defined! Check root CMakeLists.txt.")
endif()
set_target_properties(
${BIN_NAME} PROPERTIES
VERSION ${VERSION}
# ... 其他属性
) |
Johnson-zs
approved these changes
May 6, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Johnson-zs, liyigang1 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moved PROJECT_VERSION_MAJOR definition from submodule cmake files to root CMakeLists.txt for unified version management
Qt6 build sets PROJECT_VERSION_MAJOR to 1 (libdfm-.so.1) Qt5 build sets PROJECT_VERSION_MAJOR to 0 (libdfm-.so.0) Removed redundant PROJECT_VERSION_MAJOR settings from:
This change ensures consistent SOVERSION across all submodules and simplifies version management by having a single source of truth
The change maintains binary compatibility while improving build configuration clarity
Influence:
refactor: 将 PROJECT_VERSION_MAJOR 配置集中到根 CMakeLists 中
将 PROJECT_VERSION_MAJOR 定义从子模块 cmake 文件移到根 CMakeLists.txt 实现统一的版本管理
Qt6 构建设置 PROJECT_VERSION_MAJOR 为 1 (libdfm-.so.1) Qt5 构建设置 PROJECT_VERSION_MAJOR 为 0 (libdfm-.so.0) 移除了以下文件中的冗余 PROJECT_VERSION_MAJOR 设置:
此变更确保所有子模块的 SOVERSION 一致,并通过单一配置源简化版本管理
该变更保持二进制兼容性的同时提高了构建配置的清晰度
Influence: