Skip to content

Commit d766542

Browse files
Kakueeendeepin-bot[bot]
authored andcommitted
refactor: simplify Qt5 translation generation
Remove unnecessary find_program call for lrelease in Qt5 build configuration Use direct lrelease command instead of QT_LRELEASE_EXECUTABLE variable Remove redundant add_custom_target for translations since QM files are already handled as dependencies This simplifies the build configuration and avoids potential issues with lrelease executable detection Influence: 1. Verify Qt5 builds still generate translation files correctly 2. Test that language switching works properly in the application 3. Confirm build process completes without lrelease-related errors 4. Check that all translation files are properly included in the final binary refactor: 简化 Qt5 翻译生成流程 移除 Qt5 构建配置中不必要的 lrelease 程序查找调用 直接使用 lrelease 命令替代 QT_LRELEASE_EXECUTABLE 变量 移除冗余的 translations 自定义目标,因为 QM 文件已作为依赖项处理 这简化了构建配置并避免了 lrelease 可执行文件检测的潜在问题 Influence: 1. 验证 Qt5 构建仍能正确生成翻译文件 2. 测试应用程序中的语言切换功能正常工作 3. 确认构建过程不会出现 lrelease 相关错误 4. 检查所有翻译文件是否正确包含在最终二进制文件中
1 parent a3de818 commit d766542

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,18 @@ if (QT_VERSION_MAJOR MATCHES 6)
8484
)
8585
else()
8686
# Qt5 手动生成 QM 文件
87-
find_program(QT_LRELEASE_EXECUTABLE NAMES lrelease-qt5 lrelease)
8887
set(QM_FILES)
8988
foreach(TS_FILE ${TS_FILES})
9089
get_filename_component(TS_FILE_NAME ${TS_FILE} NAME_WE)
9190
set(QM_FILE "${CMAKE_CURRENT_BINARY_DIR}/${TS_FILE_NAME}.qm")
9291
add_custom_command(
9392
OUTPUT ${QM_FILE}
94-
COMMAND ${QT_LRELEASE_EXECUTABLE} -compress -nounfinished -removeidentical ${TS_FILE} -qm ${QM_FILE}
93+
COMMAND lrelease ${TS_FILE} -qm ${QM_FILE}
9594
DEPENDS ${TS_FILE}
9695
COMMENT "Generating ${QM_FILE} from ${TS_FILE}"
9796
)
9897
list(APPEND QM_FILES ${QM_FILE})
9998
endforeach()
100-
add_custom_target(translations ALL DEPENDS ${QM_FILES})
10199
endif()
102100

103101
# 在文件开头部分添加自动 moc 处理

0 commit comments

Comments
 (0)