Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 108:2004b41d4a59 | 109:79714c95a145 |
|---|---|
| 10 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") | 10 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") |
| 11 | 11 |
| 12 option(BUILD_SHARED_LIBS "Build using shared libraries" ON) | 12 option(BUILD_SHARED_LIBS "Build using shared libraries" ON) |
| 13 option(USE_QT6 "Force build with Qt 6" OFF) | 13 option(USE_QT6 "Force build with Qt 6" OFF) |
| 14 option(USE_QT5 "Force build with Qt 5" OFF) | 14 option(USE_QT5 "Force build with Qt 5" OFF) |
| 15 option(UPDATE_TRANSLATIONS "Update *.ts translation files" OFF) | |
| 15 | 16 |
| 16 add_subdirectory(dep/anitomy) | 17 add_subdirectory(dep/anitomy) |
| 17 add_subdirectory(dep/animia) | 18 add_subdirectory(dep/animia) |
| 18 add_subdirectory(dep/pugixml) | 19 add_subdirectory(dep/pugixml) |
| 19 | 20 |
| 20 # Fix for mingw64 | 21 # Fix for mingw64 |
| 21 list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") | 22 list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") |
| 22 | 23 |
| 23 if (USE_QT6) | 24 if (USE_QT6) |
| 24 set(QT_VERSION_MAJOR 6) | 25 set(QT_VERSION_MAJOR 6) |
| 25 elseif(USE_Qt5) | 26 elseif(USE_QT5) |
| 26 set(QT_VERSION_MAJOR 5) | 27 set(QT_VERSION_MAJOR 5) |
| 27 else() | 28 else() |
| 28 find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) | 29 find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) |
| 29 endif() | 30 endif() |
| 30 | 31 |
| 121 ) | 122 ) |
| 122 | 123 |
| 123 set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/rc/locale") | 124 set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/rc/locale") |
| 124 | 125 |
| 125 # dumb little hack to get this working on Qt5 and Qt6 | 126 # dumb little hack to get this working on Qt5 and Qt6 |
| 126 cmake_language(CALL qt${QT_VERSION_MAJOR}_create_translation ${SRC_FILES} ${TS_FILES} OPTIONS "-I${CMAKE_CURRENT_SOURCE_DIR}/include") | 127 if (UPDATE_TRANSLATIONS) |
| 128 cmake_language(CALL qt${QT_VERSION_MAJOR}_create_translation ${SRC_FILES} ${TS_FILES} OPTIONS "-I${CMAKE_CURRENT_SOURCE_DIR}/include") | |
| 129 endif() | |
| 127 cmake_language(CALL qt${QT_VERSION_MAJOR}_add_translation QM_FILES ${TS_FILES}) | 130 cmake_language(CALL qt${QT_VERSION_MAJOR}_add_translation QM_FILES ${TS_FILES}) |
| 128 list(APPEND SRC_FILES ${QM_FILES}) | 131 add_custom_target(translation ALL SOURCES ${QM_FILES} DEPENDS ${TS_FILES}) |
| 129 | 132 |
| 130 function(qt_create_resource_file outfile) | 133 function(qt_create_resource_file outfile) |
| 131 set(QRC "<!DOCTYPE rcc><RCC version=\"1.0\">\n\t<qresource>\n") | 134 set(QRC "<!DOCTYPE rcc><RCC version=\"1.0\">\n\t<qresource>\n") |
| 132 get_filename_component(DIR ${outfile} DIRECTORY) | 135 get_filename_component(DIR ${outfile} DIRECTORY) |
| 133 foreach (qm ${ARGN}) | 136 foreach (qm ${ARGN}) |
| 137 string(APPEND QRC "\t</qresource>\n</RCC>\n") | 140 string(APPEND QRC "\t</qresource>\n</RCC>\n") |
| 138 file(WRITE ${outfile} ${QRC}) | 141 file(WRITE ${outfile} ${QRC}) |
| 139 endfunction() | 142 endfunction() |
| 140 | 143 |
| 141 qt_create_resource_file("${CMAKE_CURRENT_BINARY_DIR}/rc/locale.qrc" ${QM_FILES}) | 144 qt_create_resource_file("${CMAKE_CURRENT_BINARY_DIR}/rc/locale.qrc" ${QM_FILES}) |
| 142 list(APPEND SRC_FILES "${CMAKE_CURRENT_BINARY_DIR}/rc/locale.qrc") | 145 add_custom_target(resources DEPENDS translation SOURCES "${CMAKE_CURRENT_BINARY_DIR}/rc/locale.qrc") |
| 143 | 146 |
| 144 # This is also used in the Win32 rc file | 147 # This is also used in the Win32 rc file |
| 145 set(RC_INFO_STRING "A lightweight anime tracker built with Qt.") | 148 set(RC_INFO_STRING "A lightweight anime tracker built with Qt.") |
| 146 | 149 |
| 147 if(APPLE) # Mac OS X (or OS X (or macOS)) | 150 if(APPLE) # Mac OS X (or OS X (or macOS)) |
| 171 ${CMAKE_CURRENT_BINARY_DIR}/rc/version.rc | 174 ${CMAKE_CURRENT_BINARY_DIR}/rc/version.rc |
| 172 ) | 175 ) |
| 173 endif() | 176 endif() |
| 174 | 177 |
| 175 add_executable(minori WIN32 MACOSX_BUNDLE ${SRC_FILES}) | 178 add_executable(minori WIN32 MACOSX_BUNDLE ${SRC_FILES}) |
| 179 add_dependencies(minori resources) | |
| 176 set_property(TARGET minori PROPERTY CXX_STANDARD 11) | 180 set_property(TARGET minori PROPERTY CXX_STANDARD 11) |
| 177 set_property(TARGET minori PROPERTY AUTOMOC ON) | 181 set_property(TARGET minori PROPERTY AUTOMOC ON) |
| 178 set_property(TARGET minori PROPERTY AUTORCC ON) | 182 set_property(TARGET minori PROPERTY AUTORCC ON) |
| 179 | 183 |
| 180 target_include_directories(minori PUBLIC ${CURL_INCLUDE_DIRS} PRIVATE ${INCLUDE}) | 184 target_include_directories(minori PUBLIC ${CURL_INCLUDE_DIRS} PRIVATE ${INCLUDE}) |
