mirror of
https://github.com/c0re100/qBittorrent-Enhanced-Edition.git
synced 2025-01-08 11:57:51 +08:00
CMake: Use installed Qt's translations for packaging
This commit is contained in:
parent
8d408ffc8b
commit
665bbc2421
25
cmake/Modules/FindQtTranslations.cmake
Normal file
25
cmake/Modules/FindQtTranslations.cmake
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Return Qt translations files as list of paths
|
||||||
|
# It will return .qm files of qt/qtbase that aren't stub files.
|
||||||
|
# Requires that Qt has been found first because it depends on qmake being available
|
||||||
|
|
||||||
|
function(qbt_get_qt_translations qt_translations)
|
||||||
|
get_target_property(QT_QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION)
|
||||||
|
execute_process(COMMAND "${QT_QMAKE_EXECUTABLE}" -query QT_INSTALL_TRANSLATIONS
|
||||||
|
OUTPUT_VARIABLE QT_TRANSLATIONS_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
FILE(GLOB QT_TEMP_TRANSLATIONS CONFIGURE_DEPENDS
|
||||||
|
"${QT_TRANSLATIONS_DIR}/qt_??.qm"
|
||||||
|
"${QT_TRANSLATIONS_DIR}/qt_??_??.qm"
|
||||||
|
"${QT_TRANSLATIONS_DIR}/qtbase_??.qm"
|
||||||
|
"${QT_TRANSLATIONS_DIR}/qtbase_??_??.qm")
|
||||||
|
|
||||||
|
foreach(TRANSLATION ${QT_TEMP_TRANSLATIONS})
|
||||||
|
FILE(SIZE "${TRANSLATION}" translation_size)
|
||||||
|
# Consider files less than 10KB as stub translations
|
||||||
|
if (translation_size GREATER_EQUAL 10240)
|
||||||
|
list(APPEND QT_FINAL_TRANSLATIONS "${TRANSLATION}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
SET(${qt_translations} ${QT_FINAL_TRANSLATIONS} PARENT_SCOPE)
|
||||||
|
endfunction()
|
@ -16,11 +16,6 @@ if (WEBUI)
|
|||||||
"${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc" COPYONLY)
|
"${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc" COPYONLY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
FILE(GLOB QT_TRANSLATIONS "${qBittorrent_SOURCE_DIR}/dist/qt-translations/qtbase_*.qm")
|
|
||||||
foreach(EXTRA_TRANSLATION IN ITEMS "fa" "gl" "lt" "pt" "sl" "sv" "zh_CN")
|
|
||||||
list(APPEND QT_TRANSLATIONS "${qBittorrent_SOURCE_DIR}/dist/qt-translations/qt_${EXTRA_TRANSLATION}.qm")
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Executable target configuration
|
# Executable target configuration
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@ -65,16 +60,17 @@ endif()
|
|||||||
# Additional platform specific configuration
|
# Additional platform specific configuration
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
set_source_files_properties(${QT_TRANSLATIONS} PROPERTIES MACOSX_PACKAGE_LOCATION translations)
|
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||||
set_source_files_properties(
|
include(FindQtTranslations)
|
||||||
|
qbt_get_qt_translations(QT_TRANSLATIONS)
|
||||||
|
set_source_files_properties(${QT_TRANSLATIONS} PROPERTIES MACOSX_PACKAGE_LOCATION translations)
|
||||||
|
set_source_files_properties(
|
||||||
"${qBittorrent_SOURCE_DIR}/dist/mac/qt.conf"
|
"${qBittorrent_SOURCE_DIR}/dist/mac/qt.conf"
|
||||||
"${qBittorrent_SOURCE_DIR}/dist/mac/qBitTorrentDocument.icns"
|
"${qBittorrent_SOURCE_DIR}/dist/mac/qBitTorrentDocument.icns"
|
||||||
"${qBittorrent_SOURCE_DIR}/dist/mac/qbittorrent_mac.icns"
|
"${qBittorrent_SOURCE_DIR}/dist/mac/qbittorrent_mac.icns"
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
MACOSX_PACKAGE_LOCATION Resources
|
MACOSX_PACKAGE_LOCATION Resources
|
||||||
)
|
)
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
|
||||||
# provide variables for substitution in dist/mac/Info.plist
|
# provide variables for substitution in dist/mac/Info.plist
|
||||||
get_target_property(EXECUTABLE_NAME qbt_app OUTPUT_NAME)
|
get_target_property(EXECUTABLE_NAME qbt_app OUTPUT_NAME)
|
||||||
# This variable name should be changed once qmake is no longer used. Refer to the discussion in PR #14813
|
# This variable name should be changed once qmake is no longer used. Refer to the discussion in PR #14813
|
||||||
|
Loading…
Reference in New Issue
Block a user