From 832b30c73bc9e2527feb4a8a875c3643d53a2c0e Mon Sep 17 00:00:00 2001 From: taynpg Date: Sun, 16 Nov 2025 21:22:07 +0800 Subject: [PATCH] =?UTF-8?q?pack=EF=BC=9A=E6=89=93=E5=8C=85=E5=8C=85?= =?UTF-8?q?=E5=90=ABstyles=E6=96=87=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 23 ++++++++++++++++++++--- Script/qt6build.bat | 4 ++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbf9a1c..bba1e7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,8 +61,10 @@ set(QT_DEP_FILES "${CMAKE_PREFIX_PATH}/bin/Qt${QT_DEFAULT_MAJOR_VERSION}Widgets.dll" "${CMAKE_PREFIX_PATH}/bin/Qt${QT_DEFAULT_MAJOR_VERSION}Network.dll" ) -set(QT_DEP_DIRS -"${CMAKE_PREFIX_PATH}/plugins/platforms/qwindows.dll" +set(QT_DEP_PLATFORM "${CMAKE_PREFIX_PATH}/plugins/platforms/qwindows.dll") +set(QT_DEP_STYLES +"${CMAKE_PREFIX_PATH}/plugins/styles/qmodernwindowsstyle.dll" +"${CMAKE_PREFIX_PATH}/plugins/styles/qwindowsvistastyle.dll" ) endif() @@ -91,6 +93,20 @@ add_subdirectory(Console) add_subdirectory(Struct) add_subdirectory(Test) +function(safe_install_files files_list destination) + set(existing_files) + foreach(file ${files_list}) + if(EXISTS ${file}) + list(APPEND existing_files ${file}) + else() + message(STATUS "跳过: ${file}") + endif() + endforeach() + if(existing_files) + install(FILES ${existing_files} DESTINATION ${destination}) + endif() +endfunction() + install(TARGETS frelayConsole DESTINATION bin) install(TARGETS frelayServer DESTINATION bin) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows") @@ -98,7 +114,8 @@ install(FILES ${MINGW_DLLS} DESTINATION bin) endif() if (WIN32) install(FILES ${QT_DEP_FILES} DESTINATION bin) -install(FILES ${QT_DEP_DIRS} DESTINATION bin/platforms) +safe_install_files("${QT_DEP_PLATFORM}" "bin/platforms") +safe_install_files("${QT_DEP_STYLES}" "bin/styles") endif() execute_process( diff --git a/Script/qt6build.bat b/Script/qt6build.bat index c3a4bd4..484e5b8 100644 --- a/Script/qt6build.bat +++ b/Script/qt6build.bat @@ -1,8 +1,8 @@ @echo on -set QT_DIR=C:/Qt/6.8.3 +set QT_DIR=C:/Qt/Qt6 cd .. -cmake -Bbuild-qt6 -S. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=%QT_DIR% -DQT_DEFAULT_MAJOR_VERSION=6 -DCOMPILE_GUI=ON -DRELEASE_MARK=ON +cmake -Bbuild-qt6 -S. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=%QT_DIR% -DQT_DEFAULT_MAJOR_VERSION=6 -DCOMPILE_GUI=ON -DRELEASE_MARK=ON cmake --build build-qt6 --config Release cd build-qt6 cpack