Mercurial > minori
comparison CMakeLists.txt @ 343:1faa72660932
*: transfer back to cmake from autotools
autotools just made lots of things more complicated than
they should have and many things broke (i.e. translations)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 20 Jun 2024 05:56:06 -0400 |
parents | |
children | d085c05247bd |
comparison
equal
deleted
inserted
replaced
342:adb79bdde329 | 343:1faa72660932 |
---|---|
1 cmake_minimum_required(VERSION 3.18) | |
2 project(minori LANGUAGES CXX VERSION 0.1.0) | |
3 | |
4 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") | |
5 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") | |
6 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") | |
7 | |
8 option(BUILD_SHARED_LIBS "Build using shared libraries" ON) | |
9 option(USE_QT6 "Force build with Qt 6" OFF) | |
10 option(USE_QT5 "Force build with Qt 5" OFF) | |
11 option(UPDATE_TRANSLATIONS "Update *.ts translation files" OFF) | |
12 | |
13 add_subdirectory(dep/animone) | |
14 add_subdirectory(dep/anitomy) | |
15 add_subdirectory(dep/pugixml) | |
16 add_subdirectory(dep/utf8proc) | |
17 add_subdirectory(dep/fmt) | |
18 | |
19 # Fix for mingw64 | |
20 list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") | |
21 | |
22 if(USE_QT6 AND USE_QT5) | |
23 message(FATAL_ERROR "Can't build with Qt 5 and Qt 6 at the same time...") | |
24 elseif(USE_QT6) | |
25 set(QT_VERSION_MAJOR 6) | |
26 elseif(USE_QT5) | |
27 set(QT_VERSION_MAJOR 5) | |
28 else() | |
29 find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) | |
30 endif() | |
31 | |
32 find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools) | |
33 | |
34 find_package(CURL REQUIRED) | |
35 | |
36 set(LIBRARIES | |
37 ${CURL_LIBRARIES} | |
38 ${Qt${QT_VERSION_MAJOR}Widgets_LIBRARIES} | |
39 anitomy | |
40 animia | |
41 pugixml | |
42 utf8proc | |
43 fmt | |
44 ) | |
45 | |
46 set(QT_MOC_FILES | |
47 include/core/http.h | |
48 include/core/session.h | |
49 include/gui/dialog/about.h | |
50 include/gui/dialog/licenses.h | |
51 include/gui/dialog/information.h | |
52 include/gui/dialog/settings.h | |
53 include/gui/pages/anime_list.h | |
54 include/gui/pages/history.h | |
55 include/gui/pages/now_playing.h | |
56 include/gui/pages/search.h | |
57 include/gui/pages/seasons.h | |
58 include/gui/pages/statistics.h | |
59 include/gui/pages/torrents.h | |
60 include/gui/translate/anilist.h | |
61 include/gui/translate/anime.h | |
62 include/gui/translate/config.h | |
63 include/gui/widgets/anime_button.h | |
64 include/gui/widgets/anime_info.h | |
65 include/gui/widgets/clickable_label.h | |
66 include/gui/widgets/drop_list_widget.h | |
67 include/gui/widgets/graph.h | |
68 include/gui/widgets/optional_date.h | |
69 include/gui/widgets/poster.h | |
70 include/gui/widgets/sidebar.h | |
71 include/gui/widgets/text.h | |
72 include/gui/widgets/elided_label.h | |
73 include/gui/locale.h | |
74 include/gui/theme.h | |
75 include/gui/window.h | |
76 ) | |
77 | |
78 set(SRC_FILES | |
79 # Main entrypoint | |
80 src/main.cc | |
81 | |
82 # Core files and datatype declarations... | |
83 src/core/anime.cc | |
84 src/core/anime_db.cc | |
85 src/core/anime_season.cc | |
86 src/core/config.cc | |
87 src/core/date.cc | |
88 src/core/filesystem.cc | |
89 src/core/http.cc | |
90 src/core/json.cc | |
91 src/core/session.cc | |
92 src/core/strings.cc | |
93 src/core/time.cc | |
94 | |
95 # Main window | |
96 src/gui/window.cc | |
97 src/gui/theme.cc | |
98 src/gui/locale.cc | |
99 | |
100 # Main window pages | |
101 src/gui/pages/anime_list.cc | |
102 src/gui/pages/now_playing.cc | |
103 src/gui/pages/statistics.cc | |
104 src/gui/pages/search.cc | |
105 src/gui/pages/seasons.cc | |
106 src/gui/pages/torrents.cc | |
107 src/gui/pages/history.cc | |
108 | |
109 # Custom widgets | |
110 src/gui/widgets/anime_button.cc | |
111 src/gui/widgets/anime_info.cc | |
112 src/gui/widgets/clickable_label.cc | |
113 src/gui/widgets/drop_list_widget.cc | |
114 src/gui/widgets/elided_label.cc | |
115 src/gui/widgets/poster.cc | |
116 src/gui/widgets/sidebar.cc | |
117 src/gui/widgets/text.cc | |
118 src/gui/widgets/optional_date.cc | |
119 | |
120 # Dialogs | |
121 src/gui/dialog/about.cc | |
122 src/gui/dialog/licenses.cc | |
123 src/gui/dialog/information.cc | |
124 src/gui/dialog/settings.cc | |
125 src/gui/dialog/settings/application.cc | |
126 src/gui/dialog/settings/services.cc | |
127 src/gui/dialog/settings/torrents.cc | |
128 src/gui/dialog/settings/recognition.cc | |
129 src/gui/dialog/settings/library.cc | |
130 | |
131 # Translate | |
132 src/gui/translate/anime.cc | |
133 src/gui/translate/anilist.cc | |
134 src/gui/translate/config.cc | |
135 | |
136 # Services | |
137 src/services/services.cc | |
138 src/services/anilist.cc | |
139 src/services/kitsu.cc | |
140 | |
141 # Library | |
142 src/library/library.cc | |
143 | |
144 # Tracking | |
145 src/track/media.cc | |
146 | |
147 # Qt resources | |
148 rc/icons/icons.qrc | |
149 rc/sys/win32/dark/dark.qrc | |
150 rc/animone.qrc | |
151 rc/licenses.qrc | |
152 ) | |
153 | |
154 set(INCLUDE | |
155 include | |
156 dep/pugixml/src | |
157 dep/animia/include | |
158 dep/fmt/include | |
159 dep/utf8proc | |
160 dep/anitomy | |
161 dep | |
162 ) | |
163 | |
164 set(TS_FILES | |
165 rc/locale/en_GB.ts | |
166 ) | |
167 | |
168 set(DEFINES) | |
169 | |
170 list(APPEND DEFINES MINORI_VERSION_MAJOR=${minori_VERSION_MAJOR}) | |
171 list(APPEND DEFINES MINORI_VERSION_MINOR=${minori_VERSION_MINOR}) | |
172 list(APPEND DEFINES MINORI_VERSION_PATCH=${minori_VERSION_PATCH}) | |
173 | |
174 ########################################################################### | |
175 # moc | |
176 | |
177 cmake_language(CALL qt${QT_VERSION_MAJOR}_wrap_cpp SRC_FILES ${QT_MOC_FILES}) | |
178 | |
179 ########################################################################### | |
180 # Translations | |
181 | |
182 set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/rc/locale") | |
183 | |
184 if(UPDATE_TRANSLATIONS) | |
185 cmake_language(CALL qt${QT_VERSION_MAJOR}_create_translation ${SRC_FILES} ${TS_FILES} OPTIONS "-tr-function-alias tr+=Translate -I${CMAKE_CURRENT_SOURCE_DIR}/include") | |
186 endif() | |
187 cmake_language(CALL qt${QT_VERSION_MAJOR}_add_translation QM_FILES ${TS_FILES}) | |
188 list(APPEND SRC_FILES ${QM_FILES}) | |
189 | |
190 set(LOCALE_QRC_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/rc/locale.qrc") | |
191 set(QRC "<!DOCTYPE rcc><RCC version=\"1.0\">\n\t<qresource>\n") | |
192 get_filename_component(DIR "${LOCALE_QRC_LOCATION}" DIRECTORY) | |
193 foreach (qm ${QM_FILES}) | |
194 file(RELATIVE_PATH name ${DIR} ${qm}) | |
195 string(APPEND QRC "\t\t<file>${name}</file>\n") | |
196 endforeach() | |
197 string(APPEND QRC "\t</qresource>\n</RCC>\n") | |
198 file(WRITE "${LOCALE_QRC_LOCATION}" ${QRC}) | |
199 | |
200 list(APPEND SRC_FILES "${LOCALE_QRC_LOCATION}") | |
201 | |
202 ########################################################################### | |
203 # Platform specific stuff | |
204 | |
205 # This is also used in the Win32 rc file | |
206 set(RC_INFO_STRING "A lightweight anime tracker built with Qt.") | |
207 | |
208 if(APPLE) # Mac OS X (or OS X (or macOS)) | |
209 set(MACOSX_BUNDLE_BUNDLE_NAME "Minori") | |
210 set(MACOSX_BUNDLE_BUNDLE_VERSION ${minori_VERSION}) | |
211 set(MACOSX_BUNDLE_COPYRIGHT "Copyright (C) Paper 2023-2024") | |
212 set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.eu.us.paper.minori") | |
213 set(MACOSX_BUNDLE_INFO_STRING ${RC_INFO_STRING}) | |
214 | |
215 find_library(FOUNDATION_LIBRARY Foundation) | |
216 find_library(APPKIT_LIBRARY AppKit) | |
217 list(APPEND SRC_FILES src/sys/osx/dark_theme.cc src/sys/osx/permissions.cc) | |
218 list(APPEND LIBRARIES ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY}) | |
219 list(APPEND DEFINES MACOSX) | |
220 elseif(WIN32) # Windows | |
221 configure_file( | |
222 ${CMAKE_CURRENT_SOURCE_DIR}/rc/sys/win32/version.rc.in | |
223 ${CMAKE_CURRENT_BINARY_DIR}/rc/version.rc | |
224 @ONLY | |
225 ) | |
226 list(APPEND SRC_FILES | |
227 src/sys/win32/dark_theme.cc | |
228 ${CMAKE_CURRENT_BINARY_DIR}/rc/version.rc | |
229 ) | |
230 list(APPEND DEFINES WIN32) | |
231 else() | |
232 find_package(PkgConfig) | |
233 if (PKG_CONFIG_FOUND) | |
234 pkg_check_modules(GLIB gio-2.0 glib-2.0) | |
235 if (GLIB_FOUND) | |
236 list(APPEND SRC_FILES src/sys/glib/dark_theme.cc) | |
237 list(APPEND INCLUDE ${GLIB_INCLUDE_DIRS}) | |
238 list(APPEND LIBRARIES ${GLIB_LINK_LIBRARIES}) | |
239 list(APPEND DEFINES GLIB) | |
240 endif() | |
241 endif() | |
242 endif() | |
243 | |
244 ########################################################################### | |
245 | |
246 add_executable(minori WIN32 MACOSX_BUNDLE ${SRC_FILES}) | |
247 set_property(TARGET minori PROPERTY CXX_STANDARD 17) | |
248 set_property(TARGET minori PROPERTY AUTORCC ON) | |
249 | |
250 target_include_directories(minori PRIVATE ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} PUBLIC ${INCLUDE}) | |
251 target_link_libraries(minori PRIVATE ${LIBRARIES}) | |
252 target_compile_options(minori PRIVATE -Wall -Wpedantic -Wextra -Wsuggest-override -Wold-style-cast) | |
253 target_compile_definitions(minori PRIVATE ${DEFINES}) | |
254 | |
255 if(APPLE) | |
256 set_target_properties(minori PROPERTIES MACOSX_BUNDLE TRUE) | |
257 elseif(WIN32) | |
258 install(FILES $<TARGET_RUNTIME_DLLS:minori> TYPE BIN) | |
259 endif() |