Files
JSwitchDisplayApplet/CMakeLists.txt
T
Jokul 63face00a7 feat: 添加国际化支持,适配系统语言
- CMakeLists.txt 添加 LinguistTools 翻译构建流程
- 添加 zh_CN 翻译文件(11 条)
- 构建时自动用 lrelease 编译 .ts 到 .qm
- .qm 文件安装到 translations/ 目录,dde-shell 自动加载
- 添加 update_translations 目标用于手动更新翻译源文件
- .gitignore 忽略 .qm 编译产物
2026-07-13 20:31:06 +08:00

70 lines
2.0 KiB
CMake
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later
cmake_minimum_required(VERSION 3.16)
project(dde-graphics-driver-applet VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt6 REQUIRED COMPONENTS Core Quick DBus LinguistTools)
find_package(Dtk6 REQUIRED COMPONENTS Core)
# 插件 ID
set(PLUGIN_ID "org.deepin.ds.graphics-driver")
# 翻译源文件目录
set(TRANSLATIONS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/translations)
# 翻译文件列表
set(TS_FILES
${TRANSLATIONS_DIR}/${PLUGIN_ID}_zh_CN.ts
)
# 生成 .qm 编译翻译文件
set(QM_FILES
${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_ID}_zh_CN.qm
)
add_custom_command(
OUTPUT ${QM_FILES}
COMMAND /usr/lib/qt6/bin/lrelease ${TS_FILES} -qm ${QM_FILES}
DEPENDS ${TS_FILES}
COMMENT "Compiling translations to .qm files"
)
# 手动更新翻译源文件(不加入 ALL,仅在需要时手动 make update_translations
add_custom_target(update_translations
COMMAND /usr/lib/qt6/bin/lupdate ${CMAKE_CURRENT_SOURCE_DIR}/package -ts ${TS_FILES}
COMMENT "Updating translation source files"
)
add_library(org.deepin.ds.graphics-driver SHARED
graphicsdriverapplet.h
graphicsdriverapplet.cpp
${QM_FILES}
)
set_target_properties(org.deepin.ds.graphics-driver PROPERTIES PREFIX "")
target_include_directories(org.deepin.ds.graphics-driver PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
/usr/include/dde-shell
)
target_link_libraries(org.deepin.ds.graphics-driver PRIVATE
Qt6::Core
Qt6::Quick
Qt6::DBus
Dtk6::Core
)
# 安装到dde-shell插件目录
install(TARGETS org.deepin.ds.graphics-driver DESTINATION /usr/lib/x86_64-linux-gnu/dde-shell)
install(FILES package/metadata.json DESTINATION /usr/share/dde-shell/${PLUGIN_ID})
install(FILES package/driverview.qml DESTINATION /usr/share/dde-shell/${PLUGIN_ID})
install(FILES ${QM_FILES} DESTINATION /usr/share/dde-shell/${PLUGIN_ID}/translations)