monero-gui/translations/CMakeLists.txt

50 lines
1.6 KiB
Text
Raw Permalink Normal View History

find_package(Qt5Core REQUIRED)
find_package(Qt5LinguistTools QUIET)
if(NOT Qt5_LRELEASE_EXECUTABLE)
find_program(Qt5_LRELEASE_EXECUTABLE lrelease REQUIRED CMAKE_FIND_ROOT_PATH_BOTH)
endif()
2020-06-30 17:07:35 +00:00
file(GLOB TS_FILES *.ts)
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)
list(APPEND QM_FILES ${QM_FILE})
2020-06-30 17:07:35 +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)
string(APPEND QRC_CONTENTS "<file>${QM_FILE_NAME}</file>")
2020-06-30 17:07:35 +00:00
endforeach()
string(APPEND QRC_CONTENTS "</qresource></RCC>")
2020-06-30 17:07:35 +00:00
set(TRANSLATIONS_QRC ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
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})
target_link_libraries(translations PUBLIC Qt5::Core)