rssguard/CMakeLists.txt

333 lines
11 KiB
CMake
Raw Permalink Normal View History

2022-01-31 10:41:17 +01:00
#################################################################
#
# For license of this file, see <project-root-folder>/LICENSE.md.
#
# This is RSS Guard compilation script for cmake.
#
# Usage (out of source build type, we have two side by side folders:
# empty "build-dir" and RSS Guard repository "rssguard-dir"):
# a) DEBUG build for testing.
# cd build-dir
# cmake -DCMAKE_BUILD_TYPE="Debug" ../rssguard-dir/
# cmake --build .
# cmake --install .
#
# b) RELEASE build for production use.
# cd build-dir
# cmake -DCMAKE_BUILD_TYPE="Release" ../rssguard-dir/
# cmake --build .
# cmake --install .
#
# Variables:
2022-02-14 09:16:39 +01:00
# BUILD_WITH_QT6 - Build either with Qt 6 or Qt 5.
2023-08-15 10:14:27 +02:00
# USE_SYSTEM_SQLITE - Use system-wide SQLite3 library and header file. Defaults to "ON".
2022-05-02 09:37:38 +02:00
# NO_UPDATE_CHECK - Disable automatic checking for new application updates.
2022-05-03 06:49:43 +02:00
# IS_FLATPAK_BUILD - Set to "ON" when building RSS Guard with Flatpak.
# FORCE_BUNDLE_ICONS - Forcibly bundles icons into executables.
# ENABLE_MEDIAPLAYER_QTMULTIMEDIA - Enable media player (QtMultimedia/ffmpeg implementation).
2023-11-27 13:24:55 +01:00
# ENABLE_MEDIAPLAYER_LIBMPV - Enable media player (libmpv implementation). Use "LibMPV_ROOT" variable to specify
# base libmpv directory.
2023-12-20 07:18:17 +01:00
# MEDIAPLAYER_FORCE_OPENGL - When libmpv media player is enabled, then this forces it to use
# its OpenGL renderer. This renderer is potentially faster, more modern
# and supports wider range of platforms. Legacy "window-based" renderer
# should be likely avoided in new codebases.
2023-10-13 14:00:54 +02:00
# ENABLE_COMPRESSED_SITEMAP - Set to "ON" if you want to enable support for "sitemap.xml.gz" format.
# This requires "zlib" library and if you want to use specific
# zlib location, then use "ZLIB_ROOT" variable, for example
# -DZLIB_ROOT="C:\\zlib"
# NO_LITE - if specified, then QtWebEngine module for internal web browser is used
# and also other more demanding parts of application are used.
2023-08-15 10:14:27 +02:00
# {FEEDLY,GMAIL,INOREADER}_CLIENT_ID - preconfigured OAuth client ID.
# {FEEDLY,GMAIL,INOREADER}_CLIENT_SECRET - preconfigured OAuth client SECRET.
2022-01-31 10:41:17 +01:00
#
# Other information:
# - supports Windows, Linux, *BSD, macOS, OS/2, Android,
2024-03-22 10:46:43 +01:00
# - Qt 5.14.0 or newer is required,
2022-04-09 09:55:11 +02:00
# - Qt 6.3.0 or newer is required,
# - cmake 3.14.0 or newer is required,
2022-02-05 09:29:32 +01:00
# - if you wish to make packages for Windows, then you must initialize all submodules
# within repository before compilation,
2022-02-14 09:16:39 +01:00
# - C++ 17 is required.
2022-01-31 10:41:17 +01:00
#
# Building on OS/2:
# RSS Guard can run on OS/2 and if you want to compile it by yourself, you need to make sure that
# your OS/2 distro is up-to-date and you have all dependencies installed: os2-base, all gcc-* packages,
# libc and libcx up-to-date, kbuild-make, ash, binutils, all relevant qt5-* packages.
#
# After your dependecies are installed, then you can compile via standard `cmake -> make -> make install` steps
2022-01-31 10:41:17 +01:00
# and package with: 7z.exe a -t7z -mmt -mx9 "rssguard.7z" "<build-folder\src\rssguard\app\*" command.
#
# Authors and contributors:
# - Martin Rotter (project leader),
# - Elbert Pol (OS/2-related contributions),
# - Anna Vyalkova (cmake-related contributions).
2022-01-31 10:41:17 +01:00
#
#################################################################
cmake_minimum_required(VERSION 3.14.0)
2022-01-31 09:11:48 +01:00
2022-01-31 10:41:17 +01:00
# Global variables describing the project.
2022-09-14 10:57:45 +02:00
string(TIMESTAMP YEAR "%Y")
string(TIMESTAMP DATE "%Y-%m-%d")
2022-09-14 10:57:45 +02:00
2022-01-31 10:41:17 +01:00
set(APP_NAME "RSS Guard")
2022-01-31 11:57:06 +01:00
set(APP_EMAIL "rotter.martinos@gmail.com")
2022-01-31 10:41:17 +01:00
set(APP_AUTHOR "Martin Rotter")
2022-09-14 10:57:45 +02:00
set(APP_COPYRIGHT "\\251 2011-${YEAR} ${APP_AUTHOR}")
set(APP_REVERSE_NAME "io.github.martinrotter.rssguard")
2022-01-31 11:57:06 +01:00
set(APP_DONATE_URL "https://github.com/sponsors/martinrotter")
2024-05-31 07:45:26 +02:00
set(APP_VERSION "4.7.2")
2022-01-31 11:57:06 +01:00
set(APP_URL "https://github.com/martinrotter/rssguard")
2023-09-29 07:35:42 +02:00
set(APP_URL_DOCUMENTATION "https://rssguard.readthedocs.io")
2022-02-08 10:42:50 +01:00
set(APP_URL_ISSUES_NEW "https://github.com/martinrotter/rssguard/issues/new/choose")
2022-01-31 11:57:06 +01:00
2022-01-31 10:41:17 +01:00
set(TYPEINFO "????")
2022-03-25 14:28:34 +01:00
project(rssguard VERSION ${APP_VERSION} LANGUAGES CXX C)
2022-01-31 09:11:48 +01:00
2022-01-31 13:11:53 +01:00
# Basic C++ related behavior of cmake.
2022-01-31 09:11:48 +01:00
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
2022-02-01 11:02:33 +01:00
set(CMAKE_AUTOUIC OFF)
2022-01-31 09:11:48 +01:00
set(CMAKE_INCLUDE_CURRENT_DIR ON)
2022-01-31 10:41:17 +01:00
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
2022-01-31 13:11:53 +01:00
if(UNIX)
add_compile_options(-fPIC)
endif()
if(APPLE)
add_compile_options(-stdlib=libc++)
add_link_options(-stdlib=libc++)
endif()
2023-11-01 07:30:44 +01:00
if(FORCE_COLORED_OUTPUT)
2022-01-31 13:11:53 +01:00
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()
endif()
# Global compilation switches.
option(BUILD_WITH_QT6 "Build application with Qt 6." ON)
2023-08-14 07:43:42 +02:00
option(USE_SYSTEM_SQLITE "Use system-wide SQLite3 library." ON)
option(NO_LITE "Enable QtWebEngine and other more demanding components." ON)
option(UPDATE_TRANSLATIONS "Call lupdate to update translation files from source (Qt 6 only)." OFF)
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GCC/Clang only)." OFF)
option(REVISION_FROM_GIT "Get revision using `git rev-parse`." ON)
option(NO_UPDATE_CHECK "Disable automatic checking for new application updates." OFF)
2022-05-03 06:49:43 +02:00
option(IS_FLATPAK_BUILD "Set to 'ON' when building RSS Guard with Flatpak." OFF)
option(FORCE_BUNDLE_ICONS "Forcibly bundle icon themes into RSS Guard." OFF)
option(ENABLE_COMPRESSED_SITEMAP "Enable support for gzip-compressed sitemap feeds. Requires zlib." OFF)
2023-11-27 13:24:55 +01:00
option(ENABLE_MEDIAPLAYER_QTMULTIMEDIA "Enable built-in media player. Requires QtMultimedia FFMPEG plugin." OFF)
option(ENABLE_MEDIAPLAYER_LIBMPV "Enable built-in media player. Requires libmpv library." ON)
option(MEDIAPLAYER_FORCE_OPENGL "Use opengl-based render API with libmpv." ON)
2022-01-31 09:11:48 +01:00
2022-01-31 13:11:53 +01:00
# Import Qt libraries.
2022-04-09 09:55:11 +02:00
set(QT6_MIN_VERSION 6.3.0)
2024-03-22 10:46:43 +01:00
set(QT5_MIN_VERSION 5.14.0)
2022-02-14 09:16:39 +01:00
set(QT_COMPONENTS
2022-01-31 10:41:17 +01:00
Core
Gui
LinguistTools
Network
Qml
Sql
Widgets
Xml
Concurrent
2022-01-31 09:11:48 +01:00
)
if(WIN32 AND NOT BUILD_WITH_QT6)
list(APPEND QT_COMPONENTS WinExtras)
endif()
2023-11-27 13:24:55 +01:00
if(NOT OS2)
list(APPEND QT_COMPONENTS Multimedia)
endif()
2023-12-07 13:55:29 +01:00
if(ENABLE_MEDIAPLAYER_QTMULTIMEDIA AND ENABLE_MEDIAPLAYER_LIBMPV)
message(FATAL_ERROR "You can only enable 1 media player backend.")
endif()
if(ENABLE_MEDIAPLAYER_QTMULTIMEDIA)
2023-11-28 08:05:44 +01:00
message(STATUS "Enabling QtMultimedia media player backend.")
list(APPEND QT_COMPONENTS OpenGL MultimediaWidgets)
add_compile_definitions(ENABLE_MEDIAPLAYER_QTMULTIMEDIA)
2022-01-31 09:11:48 +01:00
endif()
2023-11-27 13:24:55 +01:00
if(ENABLE_MEDIAPLAYER_LIBMPV)
2023-11-28 08:05:44 +01:00
message(STATUS "Enabling libmpv media player backend.")
2023-11-27 13:24:55 +01:00
if(WIN32 AND NOT LibMPV_ROOT)
set(LibMPV_ROOT "${CMAKE_SOURCE_DIR}/resources/scripts/libmpv")
endif()
if(MEDIAPLAYER_FORCE_OPENGL)
2023-12-19 13:05:38 +01:00
message(STATUS "Forcing OpenGL-based rendering for libmpv.")
list(APPEND QT_COMPONENTS OpenGL)
if(BUILD_WITH_QT6)
list(APPEND QT_COMPONENTS OpenGLWidgets)
endif()
add_compile_definitions(MEDIAPLAYER_LIBMPV_OPENGL)
endif()
2023-11-27 13:24:55 +01:00
add_compile_definitions(ENABLE_MEDIAPLAYER_LIBMPV)
endif()
if(ENABLE_MEDIAPLAYER_QTMULTIMEDIA OR ENABLE_MEDIAPLAYER_LIBMPV)
set(ENABLE_MEDIAPLAYER TRUE)
add_compile_definitions(ENABLE_MEDIAPLAYER)
2024-03-15 07:05:27 +01:00
else()
message(STATUS "Media player feature is disabled.")
endif()
if(NO_LITE)
list(APPEND QT_COMPONENTS WebEngineWidgets)
add_compile_definitions(NO_LITE)
2022-01-31 09:11:48 +01:00
endif()
if(UNIX AND NOT APPLE AND NOT ANDROID)
list(APPEND QT_COMPONENTS DBus)
endif()
if(BUILD_WITH_QT6)
find_package(QT NAMES Qt6)
2022-02-14 09:16:39 +01:00
find_package(Qt6 ${QT6_MIN_VERSION} COMPONENTS ${QT_COMPONENTS} Core5Compat REQUIRED)
else()
find_package(QT NAMES Qt5)
2022-02-14 09:16:39 +01:00
find_package(Qt5 ${QT5_MIN_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED)
if(Qt5Core_VERSION VERSION_LESS 5.15.0)
# Compatibility macros.
2022-02-01 11:02:33 +01:00
macro(qt_wrap_ui)
qt5_wrap_ui(${ARGN})
endmacro()
macro(qt_add_resources)
qt5_add_resources(${ARGN})
endmacro()
macro(qt_add_big_resources)
qt5_add_big_resources(${ARGN})
endmacro()
macro(qt_create_translation)
qt5_create_translation(${ARGN})
endmacro()
macro(qt_add_translation)
qt5_add_translation(${ARGN})
endmacro()
endif()
endif()
# Load git commit hash.
if(REVISION_FROM_GIT AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
execute_process(COMMAND "git" "rev-parse" "--short" "HEAD"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE APP_REVISION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Detected git revision: '${APP_REVISION}'.")
endif()
if(NOT NO_LITE)
set(APP_REVERSE_NAME "io.github.martinrotter.rssguardlite")
set(APP_REVISION "${APP_REVISION}-lite")
endif()
set(APP_LOW_NAME "${CMAKE_PROJECT_NAME}")
2022-02-08 10:42:50 +01:00
# Pass common defines.
2022-01-31 09:11:48 +01:00
add_compile_definitions(
2022-01-31 10:41:17 +01:00
APP_NAME="${APP_NAME}"
APP_VERSION="${CMAKE_PROJECT_VERSION}"
2022-02-08 10:42:50 +01:00
APP_URL="${APP_URL}"
APP_LONG_NAME="${APP_NAME} ${CMAKE_PROJECT_VERSION}"
APP_LOW_NAME="${APP_LOW_NAME}"
2022-05-06 13:39:09 +02:00
APP_REVERSE_NAME="${APP_REVERSE_NAME}"
2024-03-15 13:45:08 +01:00
APP_AUTHOR="${APP_AUTHOR}"
APP_DONATE_URL="${APP_DONATE_URL}"
APP_EMAIL="${APP_EMAIL}"
APP_LOW_H_NAME=".${CMAKE_PROJECT_NAME}"
APP_REVISION="${APP_REVISION}"
APP_SYSTEM_NAME="${CMAKE_SYSTEM_NAME}"
APP_SYSTEM_VERSION="${CMAKE_SYSTEM_PROCESSOR}"
APP_URL_DOCUMENTATION="${APP_URL_DOCUMENTATION}"
APP_URL_ISSUES_NEW="${APP_URL_ISSUES_NEW}"
APP_USERAGENT="${APP_NAME}/${CMAKE_PROJECT_VERSION}"
2022-01-31 10:41:17 +01:00
QT_USE_QSTRINGBUILDER
QT_USE_FAST_CONCATENATION
QT_USE_FAST_OPERATOR_PLUS
UNICODE
_UNICODE
2022-01-31 09:11:48 +01:00
)
2022-05-02 09:37:38 +02:00
if(NO_UPDATE_CHECK)
add_compile_definitions(NO_UPDATE_CHECK)
endif()
2022-05-03 06:49:43 +02:00
if(IS_FLATPAK_BUILD)
add_compile_definitions(IS_FLATPAK_BUILD)
endif()
2022-01-31 13:11:53 +01:00
# Configure and copy some needed files.
2022-01-31 09:11:48 +01:00
if(WIN32)
2022-01-31 10:41:17 +01:00
configure_file(
resources/rssguard.rc.in
${CMAKE_BINARY_DIR}/rssguard.rc
NEWLINE_STYLE WIN32
)
configure_file(
resources/nsis/NSIS.definitions.nsh.in
${CMAKE_BINARY_DIR}/NSIS.definitions.nsh
)
file(COPY resources/nsis/NSIS.template.in DESTINATION ${CMAKE_BINARY_DIR})
file(COPY resources/graphics/${CMAKE_PROJECT_NAME}.ico DESTINATION ${CMAKE_BINARY_DIR})
2022-01-31 09:11:48 +01:00
elseif(APPLE)
2022-01-31 10:41:17 +01:00
configure_file(
resources/macosx/Info.plist.in
${CMAKE_BINARY_DIR}/Info.plist
)
elseif(UNIX AND NOT ANDROID)
add_subdirectory(resources/desktop)
add_compile_definitions(
APPDATA_NAME="${APPDATA_NAME}"
APPDATA_SUMMARY="${APPDATA_SUMMARY}"
)
2022-01-31 09:11:48 +01:00
endif()
# Common libraries.
2022-01-31 09:11:48 +01:00
add_subdirectory(src/librssguard)
2022-03-21 11:13:43 +01:00
add_subdirectory(localization)
# Plugins.
add_subdirectory(src/librssguard-standard)
2024-03-19 10:53:44 +01:00
add_subdirectory(src/librssguard-feedly)
2024-03-19 14:15:38 +01:00
add_subdirectory(src/librssguard-gmail)
2024-03-20 08:06:58 +01:00
add_subdirectory(src/librssguard-greader)
2024-03-20 09:23:18 +01:00
add_subdirectory(src/librssguard-ttrss)
add_subdirectory(src/librssguard-nextcloud)
# GUI executable.
2022-01-31 09:11:48 +01:00
add_subdirectory(src/rssguard)