2020-07-09 15:13:21 +00:00
|
|
|
find_package(Qt5Core REQUIRED)
|
|
|
|
|
|
|
|
find_package(Qt5LinguistTools QUIET)
|
|
|
|
if(NOT Qt5_LRELEASE_EXECUTABLE)
|
2020-09-10 11:02:37 +00:00
|
|
|
find_program(Qt5_LRELEASE_EXECUTABLE lrelease REQUIRED CMAKE_FIND_ROOT_PATH_BOTH)
|
2020-07-09 15:13:21 +00:00
|
|
|
endif()
|
|
|
|
|
2020-06-30 17:07:35 +00:00
|
|
|
file(GLOB TS_FILES *.ts)
|
|
|
|
|
2020-07-09 15:13:21 +00:00
|
|
|
set(QM_FILES)
|
|
|
|
set(QRC_CONTENTS "<RCC><qresource prefix=\"/\">")
|
2020-06-30 17:07:35 +00:00
|
|
|
foreach(TS_FILE ${TS_FILES})
|
|
|
|
get_filename_component(QM_FILE ${TS_FILE} NAME_WE)
|
|
|
|
set(QM_FILE ${CMAKE_CURRENT_BINARY_DIR}/${QM_FILE}.qm)
|
2020-07-09 15:13:21 +00:00
|
|
|
list(APPEND QM_FILES ${QM_FILE})
|
2020-06-30 17:07:35 +00:00
|
|
|
|
2020-07-09 15:13:21 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${QM_FILE}
|
|
|
|
COMMAND ${Qt5_LRELEASE_EXECUTABLE} -compress -nounfinished -removeidentical ${TS_FILE} -qm ${QM_FILE}
|
|
|
|
DEPENDS ${TS_FILE}
|
2020-06-30 17:07:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
get_filename_component(QM_FILE_NAME ${QM_FILE} NAME)
|
2020-07-09 15:13:21 +00:00
|
|
|
string(APPEND QRC_CONTENTS "<file>${QM_FILE_NAME}</file>")
|
2020-06-30 17:07:35 +00:00
|
|
|
endforeach()
|
2020-07-09 15:13:21 +00:00
|
|
|
string(APPEND QRC_CONTENTS "</qresource></RCC>")
|
2020-06-30 17:07:35 +00:00
|
|
|
|
|
|
|
set(TRANSLATIONS_QRC ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
2020-07-09 15:13:21 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${TRANSLATIONS_QRC}
|
|
|
|
COMMAND echo ${QRC_CONTENTS} > ${TRANSLATIONS_QRC}
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
set_source_files_properties(${TRANSLATIONS_QRC} PROPERTIES SKIP_AUTORCC ON)
|
|
|
|
|
|
|
|
set(TRANSLATIONS_CPP ${CMAKE_CURRENT_BINARY_DIR}/qrc_translations.cpp)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${TRANSLATIONS_CPP}
|
|
|
|
COMMAND ${Qt5Core_RCC_EXECUTABLE}
|
|
|
|
ARGS --name translations --output ${TRANSLATIONS_CPP} ${TRANSLATIONS_QRC}
|
|
|
|
MAIN_DEPENDENCY ${TRANSLATIONS_QRC}
|
|
|
|
DEPENDS ${QM_FILES}
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
set_source_files_properties(${TRANSLATIONS_CPP} PROPERTIES SKIP_AUTOMOC ON)
|
|
|
|
set_source_files_properties(${TRANSLATIONS_CPP} PROPERTIES SKIP_AUTOUIC ON)
|
|
|
|
|
|
|
|
add_library(translations ${TRANSLATIONS_CPP})
|