Create hash string of Digest on demand
[qBittorrent.git] / CMakeLists.txt
blob063c169f2f26cd40a6449dd1c5b519a4f5784f7f
1 cmake_minimum_required(VERSION 3.16 FATAL_ERROR) # Policies <= CMP0097 default to NEW
3 list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
5 project(qBittorrent
6     DESCRIPTION "The qBittorrent BitTorrent client"
7     HOMEPAGE_URL "https://www.qbittorrent.org/"
8     LANGUAGES CXX
11 # use CONFIG mode first in find_package
12 set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
13 # version requirements - older versions may work, but you are on your own
14 set(minBoostVersion 1.65)
15 set(minQt5Version 5.15.2)
16 set(minQt6Version 6.2)
17 set(minOpenSSLVersion 1.1.1)
18 set(minLibtorrent1Version 1.2.14)
19 set(minLibtorrentVersion 2.0.4)
20 set(minZlibVersion 1.2.11)
22 # features (some are platform-specific)
23 include(CheckCXXSourceCompiles) # TODO: migrate to CheckSourceCompiles in CMake >= 3.19
24 include(FeatureSummary)
25 include(FeatureOptionsSetup)
26 feature_option(QT6 "Use Qt6" OFF)
27 feature_option(STACKTRACE "Enable stacktraces" ON)
28 feature_option(GUI "Build GUI application" ON)
29 feature_option(WEBUI "Enables built-in HTTP server for headless use" ON)
30 feature_option(VERBOSE_CONFIGURE "Show information about PACKAGES_FOUND and PACKAGES_NOT_FOUND in the configure output (only useful for debugging the CMake build scripts)" OFF)
31 if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
32     feature_option_dependent(DBUS
33         "Enables support for notifications and power-management features on Linux via D-Bus"
34         ON "GUI" OFF
35     )
36     feature_option_dependent(SYSTEMD
37         "Install systemd service file to a directory manually overridable with Systemd_SERVICES_INSTALL_DIR"
38         OFF "NOT GUI" OFF
39     )
40     if (STACKTRACE)
41         check_cxx_source_compiles(
42             "#include <execinfo.h>
43             int main(){return 0;}"
44             QBITTORRENT_HAS_EXECINFO_H
45         )
46         if (NOT QBITTORRENT_HAS_EXECINFO_H)
47             message(FATAL_ERROR "execinfo.h header file not found.\n"
48                 "Please either disable the STACKTRACE feature or use a libc that has this header file, such as glibc (GNU libc)."
49             )
50         endif()
51     endif()
52 elseif (MSVC)
53     feature_option(MSVC_RUNTIME_DYNAMIC "Use MSVC dynamic runtime library (-MD) instead of static (-MT)" ON)
54 endif()
56 include(GNUInstallDirs)
57 add_subdirectory(src)
58 add_subdirectory(dist)
60 if (VERBOSE_CONFIGURE)
61     feature_summary(WHAT ALL)
62 else()
63     feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
64 endif()
66 # Generate version header
67 configure_file("src/base/version.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/base/version.h" @ONLY)