build: macos, copy translations post build into the bundle no need to install them
This commit is contained in:
parent
82c18e26e5
commit
aa11dc94ba
1 changed files with 19 additions and 8 deletions
|
|
@ -27,23 +27,34 @@ qt_create_translation(TRS ${CMAKE_SOURCE_DIR}/src ${${CMAKE_PROJECT_NAME}_TRS} O
|
||||||
#ensure that the targets are built always
|
#ensure that the targets are built always
|
||||||
add_custom_target(app_translations ALL DEPENDS ${TRS})
|
add_custom_target(app_translations ALL DEPENDS ${TRS})
|
||||||
|
|
||||||
# install our translations
|
if (NOT APPLE)
|
||||||
install(FILES ${TRS} DESTINATION ${CMAKE_INSTALL_I18N_DIR})
|
# install our translations
|
||||||
|
install(FILES ${TRS} DESTINATION ${CMAKE_INSTALL_I18N_DIR})
|
||||||
|
elseif(APPLE)
|
||||||
|
#when making the bundle copy our translation into the bundle
|
||||||
|
set(BUNDLE_TR_DIR $<TARGET_BUNDLE_CONTENT_DIR:${CMAKE_PROJECT_PROPER_NAME}>/MacOS/translations)
|
||||||
|
|
||||||
if(APPLE)
|
# find the qt translation files needed to copy into the bundle
|
||||||
# find the qt translation files not deployed by macdeployqt
|
|
||||||
get_target_property(lupdate_executable Qt6::lupdate IMPORTED_LOCATION)
|
get_target_property(lupdate_executable Qt6::lupdate IMPORTED_LOCATION)
|
||||||
get_filename_component(_qt_bin_dir "${lupdate_executable}" DIRECTORY)
|
get_filename_component(_qt_bin_dir "${lupdate_executable}" DIRECTORY)
|
||||||
file(REAL_PATH "${_qt_bin_dir}/../" QT_ROOT_DIR)
|
file(REAL_PATH "${_qt_bin_dir}/../" QT_ROOT_DIR)
|
||||||
find_file(_QT_QM_FILE NAMES qtbase_en.qm PATHS ${QT_ROOT_DIR} PATH_SUFFIXES "translations" "share/qt/translations" REQUIRED)
|
find_file(_QT_QM_FILE NAMES qtbase_en.qm PATHS ${QT_ROOT_DIR} PATH_SUFFIXES "translations" "share/qt/translations" REQUIRED)
|
||||||
get_filename_component(MAC_QT_LANG_PATH "${_QT_QM_FILE}" DIRECTORY)
|
get_filename_component(MAC_QT_LANG_PATH "${_QT_QM_FILE}" DIRECTORY)
|
||||||
|
|
||||||
# install each lang file and rename to the same name
|
add_custom_command(
|
||||||
# rename does not work with a list so foreach is used instead
|
TARGET app_translations POST_BUILD
|
||||||
install(FILES ${MAC_QT_LANG_PATH}/qtbase_en.qm DESTINATION ${CMAKE_INSTALL_I18N_DIR} RENAME qt_en.qm)
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${BUNDLE_TR_DIR}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/*.qm" ${BUNDLE_TR_DIR}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${MAC_QT_LANG_PATH}/qtbase_en.qm" "${BUNDLE_TR_DIR}/qt_en.qm"
|
||||||
|
)
|
||||||
|
|
||||||
|
# install the other Qt lang files renamed to qt_lang.qm
|
||||||
foreach(LANG ${${CMAKE_PROJECT_NAME}_TRS})
|
foreach(LANG ${${CMAKE_PROJECT_NAME}_TRS})
|
||||||
string(REPLACE "${CMAKE_PROJECT_NAME}_" "" LANG ${LANG})
|
string(REPLACE "${CMAKE_PROJECT_NAME}_" "" LANG ${LANG})
|
||||||
string(REPLACE ".ts" "" LANG ${LANG})
|
string(REPLACE ".ts" "" LANG ${LANG})
|
||||||
install(FILES ${MAC_QT_LANG_PATH}/qtbase_${LANG}.qm DESTINATION ${CMAKE_INSTALL_I18N_DIR} RENAME qt_${LANG}.qm)
|
add_custom_command(
|
||||||
|
TARGET app_translations POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${MAC_QT_LANG_PATH}/qtbase_${LANG}.qm" "${BUNDLE_TR_DIR}/qt_${LANG}.qm"
|
||||||
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue