From 60b049b233e0695b3d259b0da7aca3a899a544ce Mon Sep 17 00:00:00 2001 From: liuxinhao <liuxinhao@kylinsec.com.cn> Date: Mon, 13 May 2024 19:59:27 +0800 Subject: [PATCH 16/16] fix(css generate): Adapting to lower version Qt themes, autorcc not correctly associating dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 适配低版本Qt css生成,autorcc未正确关联依赖 --- CMakeLists.txt | 5 +++++ style-helper/CMakeLists.txt | 12 +++++------- style/CMakeLists.txt | 7 +------ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b7eafc..b18b0f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,11 @@ list(APPEND ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules/) include(GNUInstallDirs) include(Qt5PluginInstallDirs) +find_package(Qt5 COMPONENTS Core Gui Widgets Svg DBus) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) + #共用代码,生成静态库 add_subdirectory(common) #QPlatformTheme插件 diff --git a/style-helper/CMakeLists.txt b/style-helper/CMakeLists.txt index 004222a..20b6a0b 100644 --- a/style-helper/CMakeLists.txt +++ b/style-helper/CMakeLists.txt @@ -27,21 +27,19 @@ add_custom_command( WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +# 生成资源文件 set(KIRANSTYLE_HELPER_QRC ${CMAKE_CURRENT_BINARY_DIR}/kiranstyle-helper.qrc) configure_file(kiranstyle-helper.qrc.in ${KIRANSTYLE_HELPER_QRC}) +# 手动添加resources,避免低版本Qt上AUTORCC未扫描到资源文件并关联上依赖关系 +qt5_add_resources(KIRANSTYLE_HELPER_QRC_SOURCE ${KIRANSTYLE_HELPER_QRC}) -message("${CMAKE_CURRENT_SOURCE_DIR}") -find_package(Qt5 COMPONENTS Core Gui Widgets) file(GLOB_RECURSE SRC "src/*.cpp" "src/*.h" "src/*.ui") file(GLOB_RECURSE INCLUDE "include/*.h") -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTORCC ON) - add_library(${TARGET_NAME} SHARED ${SRC} ${KIRANSTYLE_HELPER_QRC} + ${KIRANSTYLE_HELPER_QRC_SOURCE} ${INCLUDE} ${KIRAN_DARK_COLORS} ${KIRAN_LIGHT_COLORS}) @@ -72,4 +70,4 @@ install(FILES ${INCLUDE} DESTINATION ${KIRAN_STYLE_HELPER_INCLUDE_DIR}) configure_file(kiran-style-helper.pc.in kiran-style-helper.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kiran-style-helper.pc - DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig/) \ No newline at end of file + DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig/) diff --git a/style/CMakeLists.txt b/style/CMakeLists.txt index 6cb6fa6..f4f888a 100644 --- a/style/CMakeLists.txt +++ b/style/CMakeLists.txt @@ -1,12 +1,7 @@ set(TARGET_NAME "kiranstyle") -find_package(Qt5 COMPONENTS Widgets Svg DBus) file(GLOB_RECURSE SRC "src/*.cpp" "src/*.h" "src/*.ui") -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTORCC ON) - add_library( ${TARGET_NAME} SHARED ${SRC} ) @@ -27,4 +22,4 @@ target_link_libraries(${TARGET_NAME} Qt5::Svg) #kiran style 插件 -install(TARGETS ${TARGET_NAME} DESTINATION ${QT5_STYLE_INSTALL_DIR}) \ No newline at end of file +install(TARGETS ${TARGET_NAME} DESTINATION ${QT5_STYLE_INSTALL_DIR}) -- 2.27.0