2020-05-03 21:28:07 +03:00
cmake_minimum_required(VERSION 3.16 FATAL_ERROR) # Policies <= CMP0097 default to NEW
2020-04-30 12:31:23 +03:00
2017-02-06 20:05:35 +03:00
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
2015-11-06 21:03:18 +03:00
2020-05-03 21:28:07 +03:00
project(qBittorrent
DESCRIPTION "The qBittorrent BitTorrent client"
HOMEPAGE_URL "https://www.qbittorrent.org/"
LANGUAGES CXX
)
2018-06-05 04:03:38 +03:00
2020-05-03 21:28:07 +03:00
# use CONFIG mode first in find_package
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
2020-12-04 15:16:04 +03:00
# version requirements - older vesions may work, but you are on your own
set(minBoostVersion 1.65)
2021-07-09 07:39:56 +03:00
set(minQtVersion 5.15.2)
2020-12-04 15:16:04 +03:00
set(minOpenSSLVersion 1.1.1)
2021-07-29 09:15:59 +03:00
set(minLibtorrent1Version 1.2.14)
set(minLibtorrentVersion 2.0.4)
2020-12-04 15:16:04 +03:00
set(minZlibVersion 1.2.11)
2015-11-06 21:03:18 +03:00
2020-05-03 21:28:07 +03:00
# features (some are platform-specific)
2020-12-06 22:17:58 +03:00
include(CheckCXXSourceCompiles) # TODO: migrate to CheckSourceCompiles in CMake >= 3.19
2020-05-03 21:28:07 +03:00
include(FeatureSummary)
include(FeatureOptionsSetup)
feature_option(STACKTRACE "Enable stacktraces" ON)
feature_option(GUI "Build GUI application" ON)
feature_option(WEBUI "Enables built-in HTTP server for headless use" ON)
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)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
feature_option_dependent(DBUS
"Enables support for notifications and power-management features on Linux via D-Bus"
ON "GUI" OFF
)
feature_option_dependent(SYSTEMD
"Install systemd service file to a directory manually overridable with Systemd_SERVICES_INSTALL_DIR"
OFF "NOT GUI" OFF
)
2020-12-06 22:17:58 +03:00
if (STACKTRACE)
check_cxx_source_compiles(
"#include <execinfo.h>
int main(){return 0;}"
QBITTORRENT_HAS_EXECINFO_H
)
if (NOT QBITTORRENT_HAS_EXECINFO_H)
message(FATAL_ERROR "execinfo.h header file not found.\n"
"Please either disable the STACKTRACE feature or use a libc that has this header file, such as glibc (GNU libc)."
)
endif()
endif()
2020-05-03 21:28:07 +03:00
elseif (MSVC)
2020-09-26 21:32:56 +03:00
feature_option(MSVC_RUNTIME_DYNAMIC "Use MSVC dynamic runtime library (-MD) instead of static (-MT)" ON)
2020-04-30 11:34:41 +03:00
endif()
2015-11-06 21:03:18 +03:00
2020-05-03 21:28:07 +03:00
include(GNUInstallDirs)
2015-11-06 21:03:18 +03:00
add_subdirectory(src)
add_subdirectory(dist)
2018-06-05 04:03:38 +03:00
2020-05-03 21:28:07 +03:00
if (VERBOSE_CONFIGURE)
feature_summary(WHAT ALL)
else()
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
endif()
2021-01-06 21:07:10 +03:00
# Generate version header
2021-02-05 05:14:52 +03:00
configure_file("src/base/version.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/base/version.h" @ONLY)