pack:打包包含styles文件。

This commit is contained in:
2025-11-16 21:22:07 +08:00
parent 504e3f14f2
commit 832b30c73b
2 changed files with 22 additions and 5 deletions

View File

@@ -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}Widgets.dll"
"${CMAKE_PREFIX_PATH}/bin/Qt${QT_DEFAULT_MAJOR_VERSION}Network.dll" "${CMAKE_PREFIX_PATH}/bin/Qt${QT_DEFAULT_MAJOR_VERSION}Network.dll"
) )
set(QT_DEP_DIRS set(QT_DEP_PLATFORM "${CMAKE_PREFIX_PATH}/plugins/platforms/qwindows.dll")
"${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() endif()
@@ -91,6 +93,20 @@ add_subdirectory(Console)
add_subdirectory(Struct) add_subdirectory(Struct)
add_subdirectory(Test) 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 frelayConsole DESTINATION bin)
install(TARGETS frelayServer DESTINATION bin) install(TARGETS frelayServer DESTINATION bin)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows") if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows")
@@ -98,7 +114,8 @@ install(FILES ${MINGW_DLLS} DESTINATION bin)
endif() endif()
if (WIN32) if (WIN32)
install(FILES ${QT_DEP_FILES} DESTINATION bin) 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() endif()
execute_process( execute_process(

View File

@@ -1,8 +1,8 @@
@echo on @echo on
set QT_DIR=C:/Qt/6.8.3 set QT_DIR=C:/Qt/Qt6
cd .. 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 cmake --build build-qt6 --config Release
cd build-qt6 cd build-qt6
cpack cpack