Build translations via helper from qtutilities

It handles the case of cross-compilation correctly and this way also code
for handling different Qt versions can be removed.
This commit is contained in:
Martchus 2023-06-06 00:10:51 +02:00
parent 17c3a3c584
commit 7d0f5faf23
2 changed files with 14 additions and 24 deletions

View File

@ -109,9 +109,6 @@ endif ()
find_package(${PACKAGE_NAMESPACE_PREFIX}c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.20.0 REQUIRED)
use_cpp_utilities(VISIBILITY PUBLIC)
# apply basic configuration
include(BasicConfig)
# find qtutilities
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.11.0 REQUIRED)
use_qt_utilities()
@ -122,6 +119,10 @@ if (NOT DATA_DIR)
set(DATA_DIR "share/games/pianobooster")
endif ()
add_compile_options("-DDATA_DIR=\"${DATA_DIR}\"")
set(CMAKE_INSTALL_DATAROOTDIR "${CMAKE_INSTALL_DATAROOTDIR}/games") # used by c++/qtutilities
# apply basic configuration
include(BasicConfig)
# find OpenGL
set(OpenGL_GL_PREFERENCE "GLVND")
@ -158,9 +159,11 @@ else (USE_FTGL)
add_compile_options("-DNO_USE_FTGL")
endif (USE_FTGL)
# configure internationalization support
# configure translations
if (NO_LANGS)
add_compile_options("-DNO_LANGS")
else ()
add_subdirectory(../translations ../build/translations)
endif ()
# find Qt libraries
@ -322,11 +325,6 @@ if (NOT USE_SYSTEM_FONT)
install(FILES fonts/DejaVuSans.ttf DESTINATION ${DATA_DIR}/fonts/)
endif (NOT USE_SYSTEM_FONT)
# make translations
if (NOT NO_LANGS)
add_subdirectory(../translations ../build/translations)
endif (NOT NO_LANGS)
# configure debugging flags
if (DEBUG_LOG_TRACE)
add_definitions(-DPB_LOG_TRACE)

View File

@ -25,23 +25,15 @@ endif ()
get_filename_component(full_path_blank_ts ${CMAKE_CURRENT_SOURCE_DIR}/pianobooster_blank.ts ABSOLUTE)
list(REMOVE_ITEM TRANSLATIONS_FILES ${full_path_blank_ts})
find_package("${QT_PACKAGE_PREFIX}LinguistTools" REQUIRED COMPONENTS LinguistTools)
foreach (TS_FILE ${TRANSLATIONS_FILES})
list(APPEND TS_FILES "../translations/${TS_FILE}")
endforeach ()
set(TS_FILES "${TS_FILES}" PARENT_SCOPE)
if (COMMAND QT_ADD_TRANSLATION)
qt_add_translation(QM_FILES ${TRANSLATIONS_FILES})
else ()
qt5_add_translation(QM_FILES ${TRANSLATIONS_FILES})
endif ()
add_custom_target(translations ALL DEPENDS ${QM_FILES})
if (UNIX AND NOT APPLE)
install(FILES ${QM_FILES} DESTINATION ${DATA_DIR}/translations)
if ((UNIX OR MINGW) AND NOT APPLE)
install(FILES langs.json DESTINATION ${DATA_DIR}/translations)
endif (UNIX AND NOT APPLE)
if (WIN32)
install(FILES ${QM_FILES} DESTINATION .)
elseif (WIN32)
install(FILES langs.json DESTINATION .)
endif (WIN32)
endif ()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/langs.json ${CMAKE_CURRENT_BINARY_DIR}/ COPYONLY)