Mercurial > minori
diff CMakeLists.txt @ 109:79714c95a145
*: add translation files and locale files
I forgot to add these in the last commit :p
also now you have to ask cmake to update the translations
because before the ts files were not tracked (obviously)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 06 Nov 2023 01:51:44 -0500 |
parents | 2004b41d4a59 |
children | 2f3ae79adb02 |
line wrap: on
line diff
--- a/CMakeLists.txt Sun Nov 05 23:31:49 2023 -0500 +++ b/CMakeLists.txt Mon Nov 06 01:51:44 2023 -0500 @@ -12,6 +12,7 @@ option(BUILD_SHARED_LIBS "Build using shared libraries" ON) option(USE_QT6 "Force build with Qt 6" OFF) option(USE_QT5 "Force build with Qt 5" OFF) +option(UPDATE_TRANSLATIONS "Update *.ts translation files" OFF) add_subdirectory(dep/anitomy) add_subdirectory(dep/animia) @@ -22,7 +23,7 @@ if (USE_QT6) set(QT_VERSION_MAJOR 6) -elseif(USE_Qt5) +elseif(USE_QT5) set(QT_VERSION_MAJOR 5) else() find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) @@ -123,9 +124,11 @@ set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/rc/locale") # dumb little hack to get this working on Qt5 and Qt6 -cmake_language(CALL qt${QT_VERSION_MAJOR}_create_translation ${SRC_FILES} ${TS_FILES} OPTIONS "-I${CMAKE_CURRENT_SOURCE_DIR}/include") +if (UPDATE_TRANSLATIONS) + cmake_language(CALL qt${QT_VERSION_MAJOR}_create_translation ${SRC_FILES} ${TS_FILES} OPTIONS "-I${CMAKE_CURRENT_SOURCE_DIR}/include") +endif() cmake_language(CALL qt${QT_VERSION_MAJOR}_add_translation QM_FILES ${TS_FILES}) -list(APPEND SRC_FILES ${QM_FILES}) +add_custom_target(translation ALL SOURCES ${QM_FILES} DEPENDS ${TS_FILES}) function(qt_create_resource_file outfile) set(QRC "<!DOCTYPE rcc><RCC version=\"1.0\">\n\t<qresource>\n") @@ -139,7 +142,7 @@ endfunction() qt_create_resource_file("${CMAKE_CURRENT_BINARY_DIR}/rc/locale.qrc" ${QM_FILES}) -list(APPEND SRC_FILES "${CMAKE_CURRENT_BINARY_DIR}/rc/locale.qrc") +add_custom_target(resources DEPENDS translation SOURCES "${CMAKE_CURRENT_BINARY_DIR}/rc/locale.qrc") # This is also used in the Win32 rc file set(RC_INFO_STRING "A lightweight anime tracker built with Qt.") @@ -173,6 +176,7 @@ endif() add_executable(minori WIN32 MACOSX_BUNDLE ${SRC_FILES}) +add_dependencies(minori resources) set_property(TARGET minori PROPERTY CXX_STANDARD 11) set_property(TARGET minori PROPERTY AUTOMOC ON) set_property(TARGET minori PROPERTY AUTORCC ON)