cmake_minimum_required ( VERSION 3.16 FATAL_ERROR ) # Policies <= CMP0097 default to NEW
list ( APPEND CMAKE_MODULE_PATH ${ CMAKE_CURRENT_SOURCE_DIR } /cmake/Modules )
project ( qBittorrent
D E S C R I P T I O N " T h e q B i t t o r r e n t B i t T o r r e n t c l i e n t "
H O M E P A G E _ U R L " h t t p s : / / w w w . q b i t t o r r e n t . o r g / "
L A N G U A G E S C X X
)
# use CONFIG mode first in find_package
set ( CMAKE_FIND_PACKAGE_PREFER_CONFIG ON )
# version requirements - older versions may work, but you are on your own
set ( minBoostVersion 1.65 )
set ( minQtVersion 5.15.2 )
set ( minOpenSSLVersion 1.1.1 )
set ( minLibtorrent1Version 1.2.14 )
set ( minLibtorrentVersion 2.0.4 )
set ( minZlibVersion 1.2.11 )
# features (some are platform-specific)
include ( CheckCXXSourceCompiles ) # TODO: migrate to CheckSourceCompiles in CMake >= 3.19
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
" E n a b l e s s u p p o r t f o r n o t i f i c a t i o n s a n d p o w e r - m a n a g e m e n t f e a t u r e s o n L i n u x v i a D - B u s "
O N " G U I " O F F
)
feature_option_dependent ( SYSTEMD
" I n s t a l l s y s t e m d s e r v i c e f i l e t o a d i r e c t o r y m a n u a l l y o v e r r i d a b l e w i t h S y s t e m d _ S E R V I C E S _ I N S T A L L _ D I R "
O F F " N O T G U I " O F F
)
if ( STACKTRACE )
check_cxx_source_compiles (
" #include <execinfo.h>
i n t main ( ) { r e t u r n 0 ; } "
Q B I T T O R R E N T _ H A S _ E X E C I N F O _ H
)
if ( NOT QBITTORRENT_HAS_EXECINFO_H )
message ( FATAL_ERROR "execinfo.h header file not found.\n"
" P l e a s e e i t h e r d i s a b l e t h e S T A C K T R A C E f e a t u r e o r u s e a l i b c t h a t h a s t h i s h e a d e r f i l e , s u c h a s glibc ( GNU libc ) . "
)
endif ( )
endif ( )
elseif ( MSVC )
feature_option ( MSVC_RUNTIME_DYNAMIC "Use MSVC dynamic runtime library (-MD) instead of static (-MT)" ON )
endif ( )
include ( GNUInstallDirs )
add_subdirectory ( src )
add_subdirectory ( dist )
if ( VERBOSE_CONFIGURE )
feature_summary ( WHAT ALL )
else ( )
feature_summary ( WHAT ENABLED_FEATURES DISABLED_FEATURES )
endif ( )
# Generate version header
configure_file ( "src/base/version.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/base/version.h" @ONLY )