Mercurial > minori
annotate CMakeLists.txt @ 112:80f49f623d30
locale: allow switching locales without restarting
| author | Paper <mrpapersonic@gmail.com> | 
|---|---|
| date | Mon, 06 Nov 2023 13:41:30 -0500 | 
| parents | 2f3ae79adb02 | 
| children | ab191e28e69d | 
| rev | line source | 
|---|---|
| 108 | 1 cmake_minimum_required(VERSION 3.18) | 
| 103 | 2 project(minori LANGUAGES CXX VERSION 0.1.0) | 
| 
17
 
db445ce42057
cmake: only enable OBJCXX on OS X
 
Paper <mrpapersonic@gmail.com> 
parents: 
15 
diff
changeset
 | 
3 | 
| 
 
db445ce42057
cmake: only enable OBJCXX on OS X
 
Paper <mrpapersonic@gmail.com> 
parents: 
15 
diff
changeset
 | 
4 if(APPLE) | 
| 
 
db445ce42057
cmake: only enable OBJCXX on OS X
 
Paper <mrpapersonic@gmail.com> 
parents: 
15 
diff
changeset
 | 
5 enable_language(OBJCXX) | 
| 
 
db445ce42057
cmake: only enable OBJCXX on OS X
 
Paper <mrpapersonic@gmail.com> 
parents: 
15 
diff
changeset
 | 
6 endif() | 
| 2 | 7 | 
| 64 | 8 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") | 
| 9 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") | |
| 10 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") | |
| 11 | |
| 12 option(BUILD_SHARED_LIBS "Build using shared libraries" ON) | |
| 108 | 13 option(USE_QT6 "Force build with Qt 6" OFF) | 
| 14 option(USE_QT5 "Force build with Qt 5" OFF) | |
| 
110
 
2f3ae79adb02
cmake: fix what I tried to do in the last commit
 
Paper <mrpapersonic@gmail.com> 
parents: 
109 
diff
changeset
 | 
15 # The reason I'm not specifying this an an option() is that | 
| 
 
2f3ae79adb02
cmake: fix what I tried to do in the last commit
 
Paper <mrpapersonic@gmail.com> 
parents: 
109 
diff
changeset
 | 
16 # that will *save the value*, which causes the *.qm translation | 
| 
 
2f3ae79adb02
cmake: fix what I tried to do in the last commit
 
Paper <mrpapersonic@gmail.com> 
parents: 
109 
diff
changeset
 | 
17 # files to not automatically be generated, screwing up the whole | 
| 
 
2f3ae79adb02
cmake: fix what I tried to do in the last commit
 
Paper <mrpapersonic@gmail.com> 
parents: 
109 
diff
changeset
 | 
18 # "automation" part of it. | 
| 
 
2f3ae79adb02
cmake: fix what I tried to do in the last commit
 
Paper <mrpapersonic@gmail.com> 
parents: 
109 
diff
changeset
 | 
19 # | 
| 
 
2f3ae79adb02
cmake: fix what I tried to do in the last commit
 
Paper <mrpapersonic@gmail.com> 
parents: 
109 
diff
changeset
 | 
20 # Ugh. | 
| 
 
2f3ae79adb02
cmake: fix what I tried to do in the last commit
 
Paper <mrpapersonic@gmail.com> 
parents: 
109 
diff
changeset
 | 
21 # | 
| 
 
2f3ae79adb02
cmake: fix what I tried to do in the last commit
 
Paper <mrpapersonic@gmail.com> 
parents: 
109 
diff
changeset
 | 
22 # option(UPDATE_TRANSLATIONS "Update *.ts translation files" OFF) | 
| 64 | 23 | 
| 9 | 24 add_subdirectory(dep/anitomy) | 
| 64 | 25 add_subdirectory(dep/animia) | 
| 
55
 
d10b6c6b432e
add xml lib, we will need to use it eventually
 
Paper <mrpapersonic@gmail.com> 
parents: 
54 
diff
changeset
 | 
26 add_subdirectory(dep/pugixml) | 
| 9 | 27 | 
| 12 | 28 # Fix for mingw64 | 
| 29 list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") | |
| 30 | |
| 
110
 
2f3ae79adb02
cmake: fix what I tried to do in the last commit
 
Paper <mrpapersonic@gmail.com> 
parents: 
109 
diff
changeset
 | 
31 if(USE_QT6) | 
| 108 | 32 set(QT_VERSION_MAJOR 6) | 
| 
109
 
79714c95a145
*: add translation files and locale files
 
Paper <mrpapersonic@gmail.com> 
parents: 
108 
diff
changeset
 | 
33 elseif(USE_QT5) | 
| 108 | 34 set(QT_VERSION_MAJOR 5) | 
| 62 | 35 else() | 
| 108 | 36 find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) | 
| 62 | 37 endif() | 
| 108 | 38 | 
| 39 find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools) | |
| 40 | |
| 12 | 41 find_package(CURL REQUIRED) | 
| 42 | |
| 43 set(LIBRARIES | |
| 44 ${CURL_LIBRARIES} | |
| 108 | 45 ${Qt${QT_VERSION_MAJOR}Widgets_LIBRARIES} | 
| 12 | 46 anitomy | 
| 64 | 47 animia | 
| 12 | 48 ) | 
| 49 | |
| 50 # We need Cocoa for some OS X stuff | |
| 51 if(APPLE) | |
| 52 find_library(COCOA_LIBRARY Cocoa) | |
| 53 list(APPEND LIBRARIES ${COCOA_LIBRARY}) | |
| 54 endif() | |
| 55 | |
| 2 | 56 set(SRC_FILES | 
| 9 | 57 # Main entrypoint | 
| 81 | 58 src/main.cc | 
| 9 | 59 | 
| 60 # Core files and datatype declarations... | |
| 81 | 61 src/core/anime.cc | 
| 62 src/core/anime_db.cc | |
| 63 src/core/config.cc | |
| 64 src/core/date.cc | |
| 65 src/core/filesystem.cc | |
| 66 src/core/http.cc | |
| 67 src/core/json.cc | |
| 68 src/core/strings.cc | |
| 69 src/core/time.cc | |
| 9 | 70 | 
| 46 | 71 # Main window | 
| 81 | 72 src/gui/window.cc | 
| 102 | 73 src/gui/theme.cc | 
| 108 | 74 src/gui/locale.cc | 
| 46 | 75 | 
| 76 # Main window pages | |
| 81 | 77 src/gui/pages/anime_list.cc | 
| 78 src/gui/pages/now_playing.cc | |
| 79 src/gui/pages/statistics.cc | |
| 80 src/gui/pages/search.cc | |
| 81 src/gui/pages/seasons.cc | |
| 82 src/gui/pages/torrents.cc | |
| 83 src/gui/pages/history.cc | |
| 
54
 
466ac9870df9
add stub pages (to be implemented)
 
Paper <mrpapersonic@gmail.com> 
parents: 
51 
diff
changeset
 | 
84 | 
| 46 | 85 # Custom widgets | 
| 81 | 86 src/gui/widgets/anime_info.cc | 
| 87 src/gui/widgets/poster.cc | |
| 88 src/gui/widgets/clickable_label.cc | |
| 89 src/gui/widgets/sidebar.cc | |
| 90 src/gui/widgets/text.cc | |
| 91 src/gui/widgets/optional_date.cc | |
| 9 | 92 | 
| 93 # Dialogs | |
| 81 | 94 src/gui/dialog/about.cc | 
| 95 src/gui/dialog/information.cc | |
| 96 src/gui/dialog/settings.cc | |
| 97 src/gui/dialog/settings/application.cc | |
| 98 src/gui/dialog/settings/services.cc | |
| 9 | 99 | 
| 10 | 100 # Translate | 
| 81 | 101 src/gui/translate/anime.cc | 
| 102 src/gui/translate/anilist.cc | |
| 
90
 
c4bb49c2f6eb
config: improve handling of vars
 
Paper <mrpapersonic@gmail.com> 
parents: 
82 
diff
changeset
 | 
103 src/gui/translate/config.cc | 
| 10 | 104 | 
| 9 | 105 # Services (only AniList for now) | 
| 81 | 106 src/services/services.cc | 
| 107 src/services/anilist.cc | |
| 9 | 108 | 
| 64 | 109 # Tracking | 
| 
82
 
8b65c417c225
*: fix old stuff, make video players and extensions constants
 
Paper <mrpapersonic@gmail.com> 
parents: 
81 
diff
changeset
 | 
110 src/track/constants.cc | 
| 81 | 111 src/track/media.cc | 
| 64 | 112 | 
| 9 | 113 # Qt resources | 
| 2 | 114 rc/icons.qrc | 
| 
105
 
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
 
Paper <mrpapersonic@gmail.com> 
parents: 
103 
diff
changeset
 | 
115 rc/dark.qrc | 
| 2 | 116 ) | 
| 117 | |
| 108 | 118 set(INCLUDE | 
| 119 include | |
| 120 dep/pugixml/src | |
| 121 dep/animia/include | |
| 122 dep/anitomy | |
| 123 dep | |
| 124 ) | |
| 125 | |
| 126 set(TS_FILES | |
| 127 rc/locale/en_GB.ts | |
| 128 rc/locale/es.ts | |
| 129 ) | |
| 130 | |
| 131 set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/rc/locale") | |
| 132 | |
| 133 # dumb little hack to get this working on Qt5 and Qt6 | |
| 
110
 
2f3ae79adb02
cmake: fix what I tried to do in the last commit
 
Paper <mrpapersonic@gmail.com> 
parents: 
109 
diff
changeset
 | 
134 if(UPDATE_TRANSLATIONS) | 
| 
109
 
79714c95a145
*: add translation files and locale files
 
Paper <mrpapersonic@gmail.com> 
parents: 
108 
diff
changeset
 | 
135 cmake_language(CALL qt${QT_VERSION_MAJOR}_create_translation ${SRC_FILES} ${TS_FILES} OPTIONS "-I${CMAKE_CURRENT_SOURCE_DIR}/include") | 
| 
 
79714c95a145
*: add translation files and locale files
 
Paper <mrpapersonic@gmail.com> 
parents: 
108 
diff
changeset
 | 
136 endif() | 
| 108 | 137 cmake_language(CALL qt${QT_VERSION_MAJOR}_add_translation QM_FILES ${TS_FILES}) | 
| 
112
 
80f49f623d30
locale: allow switching locales without restarting
 
Paper <mrpapersonic@gmail.com> 
parents: 
110 
diff
changeset
 | 
138 list(APPEND SRC_FILES ${QM_FILES}) | 
| 108 | 139 | 
| 140 function(qt_create_resource_file outfile) | |
| 141 set(QRC "<!DOCTYPE rcc><RCC version=\"1.0\">\n\t<qresource>\n") | |
| 142 get_filename_component(DIR ${outfile} DIRECTORY) | |
| 143 foreach (qm ${ARGN}) | |
| 144 file(RELATIVE_PATH name ${DIR} ${qm}) | |
| 145 string(APPEND QRC "\t\t<file>${name}</file>\n") | |
| 146 endforeach() | |
| 147 string(APPEND QRC "\t</qresource>\n</RCC>\n") | |
| 148 file(WRITE ${outfile} ${QRC}) | |
| 149 endfunction() | |
| 150 | |
| 151 qt_create_resource_file("${CMAKE_CURRENT_BINARY_DIR}/rc/locale.qrc" ${QM_FILES}) | |
| 
112
 
80f49f623d30
locale: allow switching locales without restarting
 
Paper <mrpapersonic@gmail.com> 
parents: 
110 
diff
changeset
 | 
152 list(APPEND SRC_FILES "${CMAKE_CURRENT_BINARY_DIR}/rc/locale.qrc") | 
| 108 | 153 | 
| 154 # This is also used in the Win32 rc file | |
| 103 | 155 set(RC_INFO_STRING "A lightweight anime tracker built with Qt.") | 
| 156 | |
| 9 | 157 if(APPLE) # Mac OS X (or OS X (or macOS)) | 
| 103 | 158 set(MACOSX_BUNDLE_BUNDLE_NAME "Minori") | 
| 159 set(MACOSX_BUNDLE_BUNDLE_VERSION ${minori_VERSION}) | |
| 160 set(MACOSX_BUNDLE_COPYRIGHT "Copyright (C) Paper 2023") | |
| 161 set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.eu.us.paper.minori") | |
| 162 set(MACOSX_BUNDLE_INFO_STRING ${RC_INFO_STRING}) | |
| 163 set(MACOSX_BUNDLE_ICON_FILE rc/osx/favicon.icns) | |
| 164 set(app_icon_osx "${CMAKE_CURRENT_SOURCE_DIR}/rc/osx/favicon.icns") | |
| 165 set_source_files_properties(${app_icon_osx} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") | |
| 166 | |
| 5 | 167 list(APPEND SRC_FILES | 
| 168 src/sys/osx/dark_theme.mm | |
| 169 src/sys/osx/filesystem.mm | |
| 103 | 170 ${app_icon_osx} | 
| 5 | 171 ) | 
| 9 | 172 elseif(WIN32) # Windows | 
| 103 | 173 configure_file( | 
| 174 ${CMAKE_CURRENT_SOURCE_DIR}/rc/win32/version.rc.in | |
| 175 ${CMAKE_CURRENT_BINARY_DIR}/rc/version.rc | |
| 176 @ONLY | |
| 177 ) | |
| 178 list(APPEND SRC_FILES | |
| 179 src/sys/win32/dark_theme.cc | |
| 180 rc/win32/resource.rc | |
| 181 ${CMAKE_CURRENT_BINARY_DIR}/rc/version.rc | |
| 182 ) | |
| 2 | 183 endif() | 
| 184 | |
| 103 | 185 add_executable(minori WIN32 MACOSX_BUNDLE ${SRC_FILES}) | 
| 63 | 186 set_property(TARGET minori PROPERTY CXX_STANDARD 11) | 
| 11 | 187 set_property(TARGET minori PROPERTY AUTOMOC ON) | 
| 188 set_property(TARGET minori PROPERTY AUTORCC ON) | |
| 2 | 189 | 
| 108 | 190 target_include_directories(minori PUBLIC ${CURL_INCLUDE_DIRS} PRIVATE ${INCLUDE}) | 
| 191 target_include_directories(minori PUBLIC ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS}) | |
| 64 | 192 target_compile_options(minori PRIVATE -Wall -Wpedantic -Wextra -Wsuggest-override -Wold-style-cast) | 
| 5 | 193 if(APPLE) | 
| 11 | 194 target_compile_definitions(minori PUBLIC MACOSX) | 
| 9 | 195 elseif(WIN32) | 
| 11 | 196 target_compile_definitions(minori PUBLIC WIN32) | 
| 5 | 197 endif() | 
| 11 | 198 target_link_libraries(minori ${LIBRARIES}) | 
