From 6b5b8a6b5769e7cdfc502a44f9f439b77da47e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Wed, 20 Mar 2024 12:44:35 +0800 Subject: [PATCH] update --- example/CMakeLists.txt | 8 ++++++-- example/res/template/src/CMakeLists.txt.in | 7 +++++-- src/CMakeLists.txt | 9 +++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 03cd5acf..fae893c3 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -7,7 +7,6 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) #判断FluentUI库类型 @@ -74,8 +73,13 @@ configure_file( ) endif() +#加快qrc编译 +qt_add_big_resources(QRC_RESOURCES ${PROJECT_NAME}.qrc) +list(APPEND QRC_RESOURCES ${PROJECT_NAME}.qrc) +set_property(SOURCE ${PROJECT_NAME}.qrc PROPERTY SKIP_AUTORCC ON) +list(APPEND sources_files ${QRC_RESOURCES}) + #添加可执行文件 -list(APPEND sources_files ${PROJECT_NAME}.qrc) if(WIN32) list(APPEND sources_files ${EXAMPLE_VERSION_RC_PATH}) endif() diff --git a/example/res/template/src/CMakeLists.txt.in b/example/res/template/src/CMakeLists.txt.in index 46589882..911c337a 100644 --- a/example/res/template/src/CMakeLists.txt.in +++ b/example/res/template/src/CMakeLists.txt.in @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.20) project(%1 VERSION 0.1 LANGUAGES CXX) -set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) @@ -33,9 +32,13 @@ add_custom_target(Script-UpdateTranslations SOURCES ${TS_FILE_PATHS} ) +qt_add_big_resources(QRC_RESOURCES qml.qrc) +list(APPEND QRC_RESOURCES qml.qrc) +set_property(SOURCE qml.qrc PROPERTY SKIP_AUTORCC ON) + set(PROJECT_SOURCES main.cpp - qml.qrc + ${QRC_RESOURCES} ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7a50f9b5..d65981db 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,7 +40,7 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.3") else() set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) - set(CMAKE_AUTOUIC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) endif() #国际化 @@ -139,12 +139,17 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2") RESOURCE_PREFIX "/qt/qml" ) else() + #加快qrc编译 + set(QRC_FILE Qt5/imports/fluentui.qrc) + qt_add_big_resources(QRC_RESOURCES ${QRC_FILE}) + list(APPEND QRC_RESOURCES ${QRC_FILE}) + set_property(SOURCE ${QRC_FILE} PROPERTY SKIP_AUTORCC ON) #如果是Qt6.2版本以下,则使用add_qmlplugin函数添加资源文件,这是个自定义的函数,详情见.cmake/QmlPlugin.cmake include(QmlPlugin) add_qmlplugin(${PROJECT_NAME} URI "FluentUI" VERSION 1.0 - SOURCES ${sources_files} ${FLUENTUI_VERSION_RC_PATH} Qt5/imports/fluentui.qrc + SOURCES ${sources_files} ${FLUENTUI_VERSION_RC_PATH} ${QRC_RESOURCES} QMLFILES ${qml_files} QMLDIR imports/FluentUI BINARY_DIR ${FLUENTUI_QML_PLUGIN_DIRECTORY}