Mercurial > minori
diff CMakeLists.txt @ 108:2004b41d4a59
*: huge commit
1. WORKING LOCALIZATION + translation for Spanish and British English
2. idk like 2 changes for the dark theme :)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 05 Nov 2023 23:31:49 -0500 |
parents | 6d8da6e64d61 |
children | 79714c95a145 |
line wrap: on
line diff
--- a/CMakeLists.txt Sun Nov 05 17:44:49 2023 -0500 +++ b/CMakeLists.txt Sun Nov 05 23:31:49 2023 -0500 @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.18) project(minori LANGUAGES CXX VERSION 0.1.0) if(APPLE) @@ -10,7 +10,8 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") option(BUILD_SHARED_LIBS "Build using shared libraries" ON) -option(USE_QT6 "Build with Qt 6 instead of Qt 5" OFF) +option(USE_QT6 "Force build with Qt 6" OFF) +option(USE_QT5 "Force build with Qt 5" OFF) add_subdirectory(dep/anitomy) add_subdirectory(dep/animia) @@ -19,25 +20,25 @@ # Fix for mingw64 list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") -if(USE_QT6) - find_package(Qt6 COMPONENTS Widgets REQUIRED) +if (USE_QT6) + set(QT_VERSION_MAJOR 6) +elseif(USE_Qt5) + set(QT_VERSION_MAJOR 5) else() - find_package(Qt5 COMPONENTS Widgets REQUIRED) + find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) endif() + +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools) + find_package(CURL REQUIRED) set(LIBRARIES ${CURL_LIBRARIES} + ${Qt${QT_VERSION_MAJOR}Widgets_LIBRARIES} anitomy animia ) -if(USE_QT6) - list(APPEND LIBRARIES ${Qt6Widgets_LIBRARIES}) -else() - list(APPEND LIBRARIES ${Qt5Widgets_LIBRARIES}) -endif() - # We need Cocoa for some OS X stuff if(APPLE) find_library(COCOA_LIBRARY Cocoa) @@ -62,6 +63,7 @@ # Main window src/gui/window.cc src/gui/theme.cc + src/gui/locale.cc # Main window pages src/gui/pages/anime_list.cc @@ -105,6 +107,41 @@ rc/dark.qrc ) +set(INCLUDE + include + dep/pugixml/src + dep/animia/include + dep/anitomy + dep +) + +set(TS_FILES + rc/locale/en_GB.ts + rc/locale/es.ts +) + +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") +cmake_language(CALL qt${QT_VERSION_MAJOR}_add_translation QM_FILES ${TS_FILES}) +list(APPEND SRC_FILES ${QM_FILES}) + +function(qt_create_resource_file outfile) + set(QRC "<!DOCTYPE rcc><RCC version=\"1.0\">\n\t<qresource>\n") + get_filename_component(DIR ${outfile} DIRECTORY) + foreach (qm ${ARGN}) + file(RELATIVE_PATH name ${DIR} ${qm}) + string(APPEND QRC "\t\t<file>${name}</file>\n") + endforeach() + string(APPEND QRC "\t</qresource>\n</RCC>\n") + file(WRITE ${outfile} ${QRC}) +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") + +# This is also used in the Win32 rc file set(RC_INFO_STRING "A lightweight anime tracker built with Qt.") if(APPLE) # Mac OS X (or OS X (or macOS)) @@ -140,12 +177,8 @@ set_property(TARGET minori PROPERTY AUTOMOC ON) set_property(TARGET minori PROPERTY AUTORCC ON) -target_include_directories(minori PUBLIC ${CURL_INCLUDE_DIRS} PRIVATE include dep/pugixml/src dep/animia/include dep/anitomy dep) -if(USE_QT6) - target_include_directories(minori PUBLIC ${Qt6Widgets_INCLUDE_DIRS}) -else() - target_include_directories(minori PUBLIC ${Qt5Widgets_INCLUDE_DIRS}) -endif() +target_include_directories(minori PUBLIC ${CURL_INCLUDE_DIRS} PRIVATE ${INCLUDE}) +target_include_directories(minori PUBLIC ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS}) target_compile_options(minori PRIVATE -Wall -Wpedantic -Wextra -Wsuggest-override -Wold-style-cast) if(APPLE) target_compile_definitions(minori PUBLIC MACOSX)