Debian Codegraph @

CMakeLists.txt

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #################################################################
2 #
3 # For license of this file, see <project-root-folder>/LICENSE.md.
4 #
5 # This is RSS Guard compilation script for cmake.
6 #
7 # Usage (out of source build type, we have two side by side folders:
8 # empty "build-dir" and RSS Guard repository "rssguard-dir"):
9 # a) DEBUG build for testing.
10 # cd build-dir
11 # cmake -DCMAKE_BUILD_TYPE="Debug" ../rssguard-dir/
12 # cmake --build .
13 # cmake --install .
14 #
15 # b) RELEASE build for production use.
16 # cd build-dir
17 # cmake -DCMAKE_BUILD_TYPE="Release" ../rssguard-dir/
18 # cmake --build .
19 # cmake --install .
20 #
21 # Variables:
22 # BUILD_WITH_QT6 - Build either with Qt 6 or Qt 5.
23 # BUILD_MSYS2 - Build RSS Guard for MSYS2 distribution, this particularly
24 # enables relevant MSYS2 FHS tweaks.
25 # USE_SYSTEM_SQLITE - Use system-wide SQLite3 library and header file. Defaults to "ON".
26 # NO_UPDATE_CHECK - Disable automatic checking for new application updates.
27 # IS_FLATPAK_BUILD - Set to "ON" when building RSS Guard with Flatpak.
28 # FORCE_BUNDLE_ICONS - Forcibly bundles icons into executables.
29 # ENABLE_MEDIAPLAYER_QTMULTIMEDIA - Enable media player (QtMultimedia/ffmpeg implementation).
30 # ENABLE_MEDIAPLAYER_LIBMPV - Enable media player (libmpv implementation). Use "LibMPV_ROOT" variable to specify
31 # base libmpv directory.
32 # MEDIAPLAYER_FORCE_OPENGL - When libmpv media player is enabled, then this forces it to use
33 # its OpenGL renderer. This renderer is potentially faster, more modern
34 # and supports wider range of platforms. Legacy "window-based" renderer
35 # should be likely avoided in new codebases.
36 # ENABLE_COMPRESSED_SITEMAP - Set to "ON" if you want to enable support for "sitemap.xml.gz" format.
37 # This requires "zlib" library and if you want to use specific
38 # zlib location, then use "ZLIB_ROOT" variable, for example
39 # -DZLIB_ROOT="C:\\zlib"
40 # NO_LITE - if specified, then QtWebEngine module for internal web browser is used
41 # and also other more demanding parts of application are used.
42 # {FEEDLY,GMAIL,INOREADER}_CLIENT_ID - preconfigured OAuth client ID.
43 # {FEEDLY,GMAIL,INOREADER}_CLIENT_SECRET - preconfigured OAuth client SECRET.
44 #
45 # Other information:
46 # - supports Windows, Linux, *BSD, macOS, OS/2, Android,
47 # - Qt 5.14.0 or newer is required,
48 # - Qt 6.3.0 or newer is required,
49 # - cmake 3.14.0 or newer is required,
50 # - if you wish to make packages for Windows, then you must initialize all submodules
51 # within repository before compilation,
52 # - C++ 17 is required.
53 #
54 # Building on OS/2:
55 # RSS Guard can run on OS/2 and if you want to compile it by yourself, you need to make sure that
56 # your OS/2 distro is up-to-date and you have all dependencies installed: os2-base, all gcc-* packages,
57 # libc and libcx up-to-date, kbuild-make, ash, binutils, all relevant qt5-* packages.
58 #
59 # After your dependecies are installed, then you can compile via standard `cmake -> make -> make install` steps
60 # and package with: 7z.exe a -t7z -mmt -mx9 "rssguard.7z" "<build-folder\src\rssguard\app\*" command.
61 #
62 # Authors and contributors:
63 # - Martin Rotter (project leader),
64 # - Elbert Pol (OS/2-related contributions),
65 # - Anna Vyalkova (cmake-related contributions).
66 #
67 #################################################################
68
69 cmake_minimum_required(VERSION 3.14.0)
70
71 # Global variables describing the project.
72 string(TIMESTAMP YEAR "%Y")
73 string(TIMESTAMP DATE "%Y-%m-%d")
74
75 set(APP_NAME "RSS Guard")
76 set(APP_EMAIL "[email protected]")
77 set(APP_AUTHOR "Martin Rotter")
78 set(APP_COPYRIGHT "\\251 2011-${YEAR} ${APP_AUTHOR}")
79 set(APP_REVERSE_NAME "io.github.martinrotter.rssguard")
80 set(APP_DONATE_URL "https://github.com/sponsors/martinrotter")
81 set(APP_VERSION "4.8.6")
82
83 set(APP_URL "https://github.com/martinrotter/rssguard")
84 set(APP_URL_DOCUMENTATION "https://rssguard.readthedocs.io")
85 set(APP_URL_ISSUES_NEW "https://github.com/martinrotter/rssguard/issues/new/choose")
86
87 set(TYPEINFO "????")
88
89 project(rssguard VERSION ${APP_VERSION} LANGUAGES CXX C)
90
91 # Basic C++ related behavior of cmake.
92 set(CMAKE_CXX_STANDARD 17)
93 set(CMAKE_CXX_STANDARD_REQUIRED ON)
94
95 set(CMAKE_AUTOMOC ON)
96 set(CMAKE_AUTORCC ON)
97 set(CMAKE_AUTOUIC OFF)
98 set(CMAKE_INCLUDE_CURRENT_DIR ON)
99
100 if(NOT CMAKE_BUILD_TYPE)
101 set(CMAKE_BUILD_TYPE "Release")
102 endif()
103
104 if(UNIX)
105 add_compile_options(-fPIC)
106 endif()
107
108 if(APPLE)
109 add_compile_options(-stdlib=libc++)
110 add_link_options(-stdlib=libc++)
111 endif()
112
113 # Global compilation switches.
114 option(BUILD_WITH_QT6 "Build application with Qt 6." ON)
115 option(BUILD_MSYS2 "Build application for MSYS2 ecosystem." OFF)
116 option(USE_SYSTEM_SQLITE "Use system-wide SQLite3 library." ON)
117 option(NO_LITE "Enable QtWebEngine and other more demanding components." ON)
118 option(UPDATE_TRANSLATIONS "Call lupdate to update translation files from source (Qt 6 only)." OFF)
119 option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GCC/Clang only)." OFF)
120 option(LOAD_PLUGINS_FROM_PARENT "Force loading of plugin libraries from parent folder." OFF)
121 option(REVISION_FROM_GIT "Get revision using `git rev-parse`." ON)
122 option(NO_UPDATE_CHECK "Disable automatic checking for new application updates." OFF)
123 option(IS_FLATPAK_BUILD "Set to 'ON' when building RSS Guard with Flatpak." OFF)
124 option(FORCE_BUNDLE_ICONS "Forcibly bundle icon themes into RSS Guard." OFF)
125 option(ENABLE_COMPRESSED_SITEMAP "Enable support for gzip-compressed sitemap feeds. Requires zlib." OFF)
126 option(ENABLE_MEDIAPLAYER_QTMULTIMEDIA "Enable built-in media player. Requires QtMultimedia FFMPEG plugin." OFF)
127 option(ENABLE_MEDIAPLAYER_LIBMPV "Enable built-in media player. Requires libmpv library." ON)
128 option(MEDIAPLAYER_FORCE_OPENGL "Use opengl-based render API with libmpv." ON)
129
130 # Import Qt libraries.
131 set(QT6_MIN_VERSION 6.3.0)
132 set(QT5_MIN_VERSION 5.14.0)
133
134 set(QT_COMPONENTS
135 Core
136 Gui
137 LinguistTools
138 Network
139 Qml
140 Sql
141 Widgets
142 Xml
143 Concurrent
144 )
145
146 if(WIN32 AND NOT BUILD_WITH_QT6)
147 list(APPEND QT_COMPONENTS WinExtras)
148 endif()
149
150 if(NOT OS2)
151 list(APPEND QT_COMPONENTS Multimedia)
152 endif()
153
154 if(MINGW AND NO_LITE)
155 message(WARNING "MinGW can only compile lite version of RSS Guard. Switching to it.")
156 set(NO_LITE OFF)
157 endif()
158
159 if(FORCE_COLORED_OUTPUT)
160 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
161 add_compile_options(-fdiagnostics-color=always)
162 elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
163 add_compile_options(-fcolor-diagnostics)
164 endif()
165 endif()
166
167 if(ENABLE_MEDIAPLAYER_QTMULTIMEDIA AND ENABLE_MEDIAPLAYER_LIBMPV)
168 message(FATAL_ERROR "You can only enable 1 media player backend.")
169 endif()
170
171 if(ENABLE_MEDIAPLAYER_QTMULTIMEDIA)
172 message(STATUS "Enabling QtMultimedia media player backend.")
173
174 list(APPEND QT_COMPONENTS OpenGL MultimediaWidgets)
175 add_compile_definitions(ENABLE_MEDIAPLAYER_QTMULTIMEDIA)
176 endif()
177
178 if(ENABLE_MEDIAPLAYER_LIBMPV)
179 message(STATUS "Enabling libmpv media player backend.")
180
181 if(WIN32 AND NOT LibMPV_ROOT)
182 set(LibMPV_ROOT "${CMAKE_SOURCE_DIR}/resources/scripts/libmpv")
183 endif()
184
185 if(MEDIAPLAYER_FORCE_OPENGL)
186 message(STATUS "Forcing OpenGL-based rendering for libmpv.")
187
188 list(APPEND QT_COMPONENTS OpenGL)
189
190 if(BUILD_WITH_QT6)
191 list(APPEND QT_COMPONENTS OpenGLWidgets)
192 endif()
193
194 add_compile_definitions(MEDIAPLAYER_LIBMPV_OPENGL)
195 endif()
196
197 add_compile_definitions(ENABLE_MEDIAPLAYER_LIBMPV)
198 endif()
199
200 if(ENABLE_MEDIAPLAYER_QTMULTIMEDIA OR ENABLE_MEDIAPLAYER_LIBMPV)
201 set(ENABLE_MEDIAPLAYER TRUE)
202 add_compile_definitions(ENABLE_MEDIAPLAYER)
203 else()
204 message(STATUS "Media player feature is disabled.")
205 endif()
206
207 if(NO_LITE)
208 list(APPEND QT_COMPONENTS WebEngineWidgets)
209 add_compile_definitions(NO_LITE)
210 endif()
211
212 if(UNIX AND NOT APPLE AND NOT ANDROID)
213 list(APPEND QT_COMPONENTS DBus)
214 endif()
215
216 if(BUILD_WITH_QT6)
217 find_package(QT NAMES Qt6)
218 find_package(Qt6 ${QT6_MIN_VERSION} COMPONENTS ${QT_COMPONENTS} Core5Compat REQUIRED)
219 else()
220 find_package(QT NAMES Qt5)
221 find_package(Qt5 ${QT5_MIN_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED)
222
223 if(Qt5Core_VERSION VERSION_LESS 5.15.0)
224 # Compatibility macros.
225 macro(qt_wrap_ui)
226 qt5_wrap_ui(${ARGN})
227 endmacro()
228
229 macro(qt_add_resources)
230 qt5_add_resources(${ARGN})
231 endmacro()
232
233 macro(qt_add_big_resources)
234 qt5_add_big_resources(${ARGN})
235 endmacro()
236
237 macro(qt_create_translation)
238 qt5_create_translation(${ARGN})
239 endmacro()
240
241 macro(qt_add_translation)
242 qt5_add_translation(${ARGN})
243 endmacro()
244 endif()
245 endif()
246
247 # Load git commit hash.
248 if(REVISION_FROM_GIT AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
249 execute_process(COMMAND "git" "rev-parse" "--short" "HEAD"
250 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
251 OUTPUT_VARIABLE APP_REVISION
252 ERROR_QUIET
253 OUTPUT_STRIP_TRAILING_WHITESPACE
254 )
255
256 message(STATUS "Detected git revision: '${APP_REVISION}'.")
257 endif()
258
259 if(NOT NO_LITE)
260 set(APP_REVERSE_NAME "io.github.martinrotter.rssguardlite")
261 set(APP_REVISION "${APP_REVISION}-lite")
262 endif()
263
264 set(APP_LOW_NAME "${CMAKE_PROJECT_NAME}")
265
266 # Pass common defines.
267 add_compile_definitions(
268 APP_NAME="${APP_NAME}"
269 APP_VERSION="${CMAKE_PROJECT_VERSION}"
270 APP_URL="${APP_URL}"
271 APP_LONG_NAME="${APP_NAME} ${CMAKE_PROJECT_VERSION}"
272 APP_LOW_NAME="${APP_LOW_NAME}"
273 APP_REVERSE_NAME="${APP_REVERSE_NAME}"
274 APP_AUTHOR="${APP_AUTHOR}"
275 APP_DONATE_URL="${APP_DONATE_URL}"
276 APP_EMAIL="${APP_EMAIL}"
277 APP_LOW_H_NAME=".${CMAKE_PROJECT_NAME}"
278 APP_REVISION="${APP_REVISION}"
279 APP_SYSTEM_NAME="${CMAKE_SYSTEM_NAME}"
280 APP_SYSTEM_VERSION="${CMAKE_SYSTEM_PROCESSOR}"
281 APP_URL_DOCUMENTATION="${APP_URL_DOCUMENTATION}"
282 APP_URL_ISSUES_NEW="${APP_URL_ISSUES_NEW}"
283 APP_USERAGENT="${APP_NAME}/${CMAKE_PROJECT_VERSION}"
284
285 QT_USE_QSTRINGBUILDER
286 QT_USE_FAST_CONCATENATION
287 QT_USE_FAST_OPERATOR_PLUS
288 UNICODE
289 _UNICODE
290 )
291
292 if(NO_UPDATE_CHECK)
293 add_compile_definitions(NO_UPDATE_CHECK)
294 endif()
295
296 if(IS_FLATPAK_BUILD)
297 add_compile_definitions(IS_FLATPAK_BUILD)
298 endif()
299
300 if(BUILD_MSYS2)
301 add_compile_definitions(BUILD_MSYS2)
302 endif()
303
304 # Configure and copy some needed files.
305 if(WIN32)
306 configure_file(
307 resources/rssguard.rc.in
308 ${CMAKE_BINARY_DIR}/rssguard.rc
309 NEWLINE_STYLE WIN32
310 )
311
312 configure_file(
313 resources/nsis/NSIS.definitions.nsh.in
314 ${CMAKE_BINARY_DIR}/NSIS.definitions.nsh
315 )
316
317 file(COPY resources/nsis/NSIS.template.in DESTINATION ${CMAKE_BINARY_DIR})
318 file(COPY resources/graphics/${CMAKE_PROJECT_NAME}.ico DESTINATION ${CMAKE_BINARY_DIR})
319 elseif(APPLE)
320 configure_file(
321 resources/macosx/Info.plist.in
322 ${CMAKE_BINARY_DIR}/Info.plist
323 )
324 elseif(UNIX AND NOT ANDROID)
325 add_subdirectory(resources/desktop)
326 add_compile_definitions(
327 APPDATA_NAME="${APPDATA_NAME}"
328 APPDATA_SUMMARY="${APPDATA_SUMMARY}"
329 )
330 endif()
331
332 # Common libraries.
333 add_subdirectory(src/librssguard)
334 add_subdirectory(localization)
335
336 # Plugins.
337 add_subdirectory(src/librssguard-standard)
338 add_subdirectory(src/librssguard-feedly)
339 add_subdirectory(src/librssguard-gmail)
340 add_subdirectory(src/librssguard-greader)
341 add_subdirectory(src/librssguard-ttrss)
342 add_subdirectory(src/librssguard-reddit)
343 add_subdirectory(src/librssguard-nextcloud)
344
345 # GUI executable.
346 add_subdirectory(src/rssguard)