2015-12-16 18:46:06 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
|
2014-12-01 19:55:22 +00:00
|
|
|
project(transmission)
|
|
|
|
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
|
|
|
|
2016-09-10 17:08:58 +00:00
|
|
|
set(CMAKE_MACOSX_RPATH ON)
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
include(CheckIncludeFile)
|
|
|
|
include(CheckIncludeFiles)
|
|
|
|
include(CheckFunctionExists)
|
|
|
|
include(CheckLibraryExists)
|
|
|
|
include(ExternalProject)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
include(TrMacros)
|
|
|
|
|
|
|
|
option(ENABLE_DAEMON "Build daemon" ON)
|
|
|
|
tr_auto_option(ENABLE_GTK "Build GTK+ client" AUTO)
|
|
|
|
tr_auto_option(ENABLE_QT "Build Qt client" AUTO)
|
2016-09-10 17:08:58 +00:00
|
|
|
tr_auto_option(ENABLE_MAC "Build Mac client" AUTO)
|
2014-12-01 19:55:22 +00:00
|
|
|
option(ENABLE_UTILS "Build utils (create, edit, show)" ON)
|
|
|
|
option(ENABLE_CLI "Build command-line client" OFF)
|
|
|
|
option(ENABLE_TESTS "Build unit tests" ON)
|
|
|
|
option(ENABLE_LIGHTWEIGHT "Optimize libtransmission for low-resource systems: smaller cache size, prefer unencrypted peer connections, etc." OFF)
|
|
|
|
option(ENABLE_UTP "Build µTP support" ON)
|
|
|
|
option(ENABLE_NLS "Enable native language support" ON)
|
|
|
|
option(INSTALL_DOC "Build/install documentation" ON)
|
|
|
|
option(INSTALL_LIB "Install the library" OFF)
|
|
|
|
tr_auto_option(USE_SYSTEM_EVENT2 "Use system event2 library" AUTO)
|
|
|
|
tr_auto_option(USE_SYSTEM_DHT "Use system dht library" AUTO)
|
|
|
|
tr_auto_option(USE_SYSTEM_MINIUPNPC "Use system miniupnpc library" AUTO)
|
|
|
|
tr_auto_option(USE_SYSTEM_NATPMP "Use system natpmp library" AUTO)
|
|
|
|
tr_auto_option(USE_SYSTEM_UTP "Use system utp library" AUTO)
|
2015-01-01 21:16:36 +00:00
|
|
|
tr_auto_option(USE_SYSTEM_B64 "Use system b64 library" AUTO)
|
2015-01-07 13:19:00 +00:00
|
|
|
tr_list_option(WITH_CRYPTO "Use specified crypto library" AUTO openssl cyassl polarssl)
|
2014-12-01 19:55:22 +00:00
|
|
|
tr_auto_option(WITH_INOTIFY "Enable inotify support (on systems that support it)" AUTO)
|
|
|
|
tr_auto_option(WITH_KQUEUE "Enable kqueue support (on systems that support it)" AUTO)
|
2016-11-27 19:17:07 +00:00
|
|
|
tr_auto_option(WITH_LIBAPPINDICATOR "Use libappindicator in GTK+ client" AUTO)
|
2014-12-01 19:55:22 +00:00
|
|
|
tr_auto_option(WITH_SYSTEMD "Add support for systemd startup notification (on systems that support it)" AUTO)
|
|
|
|
|
|
|
|
set(TR_NAME ${PROJECT_NAME})
|
|
|
|
|
|
|
|
# convention: -TR MAJOR MINOR MAINT STATUS - (each a single char)
|
|
|
|
# STATUS: "X" for prerelease beta builds,
|
|
|
|
# "Z" for unsupported trunk builds,
|
|
|
|
# "0" for stable, supported releases
|
|
|
|
# these should be the only two lines you need to change
|
2020-05-16 00:38:43 +00:00
|
|
|
set(TR_USER_AGENT_PREFIX "3.00+")
|
|
|
|
set(TR_PEER_ID_PREFIX "-TR300Z-")
|
2014-12-01 19:55:22 +00:00
|
|
|
|
|
|
|
string(REGEX MATCH "^([0-9]+)\\.([0-9]+).*" TR_VERSION "${TR_USER_AGENT_PREFIX}")
|
|
|
|
set(TR_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
|
|
|
set(TR_VERSION_MINOR "${CMAKE_MATCH_2}")
|
|
|
|
|
|
|
|
if(TR_PEER_ID_PREFIX MATCHES "X-$")
|
|
|
|
set(TR_BETA_RELEASE 1)
|
|
|
|
elseif(TR_PEER_ID_PREFIX MATCHES "Z-$")
|
|
|
|
set(TR_NIGHTLY_RELEASE 1)
|
|
|
|
else()
|
|
|
|
set(TR_STABLE_RELEASE 1)
|
|
|
|
endif()
|
|
|
|
|
2016-09-02 19:02:51 +00:00
|
|
|
set(TR_VCS_REVISION_FILE "${CMAKE_SOURCE_DIR}/REVISION")
|
2015-04-24 19:14:56 +00:00
|
|
|
|
2017-01-14 21:54:56 +00:00
|
|
|
if(NOT "$ENV{JENKINS_URL}" STREQUAL "" AND NOT "$ENV{GIT_COMMIT}" STREQUAL "")
|
|
|
|
set(TR_VCS_REVISION "$ENV{GIT_COMMIT}")
|
|
|
|
elseif(NOT "$ENV{TEAMCITY_PROJECT_NAME}" STREQUAL "" AND NOT "$ENV{BUILD_VCS_NUMBER}" STREQUAL "")
|
|
|
|
set(TR_VCS_REVISION "$ENV{BUILD_VCS_NUMBER}")
|
2014-12-01 19:55:22 +00:00
|
|
|
elseif(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
|
|
|
|
find_package(Git)
|
|
|
|
if(GIT_FOUND)
|
|
|
|
execute_process(
|
|
|
|
COMMAND
|
2017-01-14 21:54:56 +00:00
|
|
|
${GIT_EXECUTABLE} rev-list --max-count=1 HEAD
|
2014-12-01 19:55:22 +00:00
|
|
|
WORKING_DIRECTORY
|
|
|
|
${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE
|
2016-09-02 19:02:51 +00:00
|
|
|
TR_VCS_REVISION
|
2014-12-01 19:55:22 +00:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-09-02 19:02:51 +00:00
|
|
|
if("${TR_VCS_REVISION}" STREQUAL "" AND EXISTS "${TR_VCS_REVISION_FILE}")
|
|
|
|
file(READ "${TR_VCS_REVISION_FILE}" TR_VCS_REVISION)
|
2015-04-24 19:14:56 +00:00
|
|
|
endif()
|
|
|
|
|
2017-01-14 21:54:56 +00:00
|
|
|
string(STRIP "${TR_VCS_REVISION}" TR_VCS_REVISION)
|
|
|
|
|
2016-09-02 19:45:03 +00:00
|
|
|
if(NOT "${TR_VCS_REVISION}" STREQUAL "")
|
2017-01-14 21:54:56 +00:00
|
|
|
file(WRITE "${TR_VCS_REVISION_FILE}" "${TR_VCS_REVISION}\n")
|
2015-04-24 19:14:56 +00:00
|
|
|
else()
|
2016-09-02 19:45:03 +00:00
|
|
|
set(TR_VCS_REVISION 0)
|
|
|
|
file(REMOVE "${TR_VCS_REVISION_FILE}")
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
2017-01-14 21:54:56 +00:00
|
|
|
string(SUBSTRING "${TR_VCS_REVISION}" 0 10 TR_VCS_REVISION)
|
|
|
|
|
2015-04-14 22:46:40 +00:00
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
set(CURL_MINIMUM 7.15.4)
|
|
|
|
set(EVENT2_MINIMUM 2.0.10)
|
2015-10-13 21:24:31 +00:00
|
|
|
set(OPENSSL_MINIMUM 0.9.7)
|
2015-01-07 02:04:08 +00:00
|
|
|
set(CYASSL_MINIMUM 3.0)
|
2015-01-07 13:41:22 +00:00
|
|
|
set(POLARSSL_MINIMUM 1.2)
|
2014-12-01 19:55:22 +00:00
|
|
|
set(ZLIB_MINIMUM 1.2.3)
|
|
|
|
set(GTK_MINIMUM 3.4.0)
|
|
|
|
set(GLIB_MINIMUM 2.32.0)
|
|
|
|
set(GIO_MINIMUM 2.26.0)
|
|
|
|
set(LIBAPPINDICATOR_MINIMUM 0.4.90)
|
2017-02-11 10:24:42 +00:00
|
|
|
set(QT5_MINIMUM 5.2)
|
2014-12-01 19:55:22 +00:00
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
foreach(L C CXX)
|
|
|
|
# Target version (Vista and up)
|
|
|
|
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} -DWINVER=0x0600 -D_WIN32_WINNT=0x0600")
|
|
|
|
# Use Unicode API (although we always use W or A names explicitly)
|
|
|
|
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} -DUNICODE -D_UNICODE")
|
|
|
|
# Ignore various deprecation and security warnings (at least for now)
|
|
|
|
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS")
|
|
|
|
# Increase maximum FD_SET size
|
|
|
|
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} -DFD_SETSIZE=1024")
|
|
|
|
if(MSVC)
|
|
|
|
# Reduce noise (at least for now)
|
|
|
|
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} /wd4244 /wd4267")
|
|
|
|
endif()
|
2015-12-31 12:41:17 +00:00
|
|
|
|
|
|
|
if(MINGW)
|
|
|
|
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} -D__USE_MINGW_ANSI_STDIO=1")
|
|
|
|
endif()
|
2014-12-01 19:55:22 +00:00
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(Threads)
|
|
|
|
find_package(PkgConfig QUIET)
|
|
|
|
|
|
|
|
find_package(CURL ${CURL_MINIMUM} REQUIRED)
|
|
|
|
|
2016-02-07 11:54:01 +00:00
|
|
|
find_package(ICONV)
|
2014-12-01 19:55:22 +00:00
|
|
|
|
2017-02-23 20:18:45 +00:00
|
|
|
set(CRYPTO_PKG "")
|
2015-01-07 02:04:08 +00:00
|
|
|
if(WITH_CRYPTO STREQUAL "AUTO" OR WITH_CRYPTO STREQUAL "openssl")
|
|
|
|
tr_get_required_flag(WITH_CRYPTO OPENSSL_IS_REQUIRED)
|
|
|
|
find_package(OpenSSL ${OPENSSL_MINIMUM} ${OPENSSL_IS_REQUIRED})
|
|
|
|
tr_fixup_list_option(WITH_CRYPTO "openssl" OPENSSL_FOUND "AUTO" OPENSSL_IS_REQUIRED)
|
|
|
|
if(WITH_CRYPTO STREQUAL "openssl")
|
|
|
|
set(CRYPTO_PKG "openssl")
|
|
|
|
set(CRYPTO_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
|
|
|
|
set(CRYPTO_LIBRARIES ${OPENSSL_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(WITH_CRYPTO STREQUAL "AUTO" OR WITH_CRYPTO STREQUAL "cyassl")
|
|
|
|
tr_get_required_flag(WITH_CRYPTO CYASSL_IS_REQUIRED)
|
|
|
|
find_package(CyaSSL ${CYASSL_MINIMUM} ${CYASSL_IS_REQUIRED})
|
|
|
|
tr_fixup_list_option(WITH_CRYPTO "cyassl" CYASSL_FOUND "AUTO" CYASSL_IS_REQUIRED)
|
|
|
|
if(WITH_CRYPTO STREQUAL "cyassl")
|
|
|
|
set(CRYPTO_PKG "cyassl")
|
|
|
|
set(CRYPTO_INCLUDE_DIRS ${CYASSL_INCLUDE_DIRS})
|
|
|
|
set(CRYPTO_LIBRARIES ${CYASSL_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-01-07 13:19:00 +00:00
|
|
|
if(WITH_CRYPTO STREQUAL "AUTO" OR WITH_CRYPTO STREQUAL "polarssl")
|
|
|
|
tr_get_required_flag(WITH_CRYPTO POLARSSL_IS_REQUIRED)
|
|
|
|
find_package(PolarSSL ${POLARSSL_MINIMUM} ${POLARSSL_IS_REQUIRED})
|
|
|
|
tr_fixup_list_option(WITH_CRYPTO "polarssl" POLARSSL_FOUND "AUTO" POLARSSL_IS_REQUIRED)
|
|
|
|
if(WITH_CRYPTO STREQUAL "polarssl")
|
|
|
|
set(CRYPTO_PKG "polarssl")
|
|
|
|
set(CRYPTO_INCLUDE_DIRS ${POLARSSL_INCLUDE_DIRS})
|
|
|
|
set(CRYPTO_LIBRARIES ${POLARSSL_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-01-07 02:04:08 +00:00
|
|
|
# We should have found the library by now
|
|
|
|
if(CRYPTO_PKG STREQUAL "")
|
|
|
|
if(WITH_CRYPTO STREQUAL "AUTO")
|
|
|
|
message(FATAL_ERROR "Unable to find any supported crypto library.")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Requested crypto library '${WITH_CRYPTO}' is not supported.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
if(ENABLE_GTK)
|
|
|
|
tr_get_required_flag(ENABLE_GTK GTK_IS_REQUIRED)
|
|
|
|
|
|
|
|
pkg_check_modules(GTK ${GTK_IS_REQUIRED}
|
|
|
|
gtk+-3.0>=${GTK_MINIMUM}
|
|
|
|
glib-2.0>=${GLIB_MINIMUM}
|
|
|
|
gio-2.0>=${GIO_MINIMUM}
|
|
|
|
gmodule-2.0>=${GLIB_MINIMUM}
|
|
|
|
gthread-2.0>=${GLIB_MINIMUM})
|
|
|
|
|
|
|
|
tr_fixup_auto_option(ENABLE_GTK GTK_FOUND GTK_IS_REQUIRED)
|
|
|
|
|
2016-11-27 19:17:07 +00:00
|
|
|
if(ENABLE_GTK AND WITH_LIBAPPINDICATOR)
|
|
|
|
tr_get_required_flag(WITH_LIBAPPINDICATOR LIBAPPINDICATOR_IS_REQUIRED)
|
2014-12-01 19:55:22 +00:00
|
|
|
pkg_check_modules(LIBAPPINDICATOR appindicator3-0.1>=${LIBAPPINDICATOR_MINIMUM})
|
2016-11-27 19:17:07 +00:00
|
|
|
tr_fixup_auto_option(WITH_LIBAPPINDICATOR LIBAPPINDICATOR_FOUND LIBAPPINDICATOR_IS_REQUIRED)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
2016-11-27 19:17:07 +00:00
|
|
|
else()
|
|
|
|
set(WITH_LIBAPPINDICATOR OFF)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_QT)
|
|
|
|
tr_get_required_flag(ENABLE_QT QT_IS_REQUIRED)
|
|
|
|
|
|
|
|
if(POLICY CMP0020)
|
|
|
|
cmake_policy(SET CMP0020 NEW)
|
|
|
|
endif()
|
|
|
|
|
2015-12-16 18:46:06 +00:00
|
|
|
set(QT_TARGETS)
|
2015-12-17 18:10:43 +00:00
|
|
|
set(ENABLE_QT_COM_INTEROP OFF)
|
|
|
|
set(ENABLE_QT_DBUS_INTEROP OFF)
|
|
|
|
|
2017-02-11 10:24:42 +00:00
|
|
|
set(QT5_REQUIRED_MODULES Core Gui Widgets Network LinguistTools)
|
|
|
|
set(QT5_OPTIONAL_MODULES DBus AxContainer AxServer)
|
|
|
|
|
2017-02-11 17:48:13 +00:00
|
|
|
if(WIN32)
|
|
|
|
list(APPEND QT5_REQUIRED_MODULES WinExtras)
|
|
|
|
endif()
|
|
|
|
|
2017-02-11 10:24:42 +00:00
|
|
|
foreach(M ${QT5_REQUIRED_MODULES})
|
|
|
|
find_package(Qt5${M} ${QT5_MINIMUM} QUIET)
|
|
|
|
if(Qt5${M}_FOUND)
|
|
|
|
if(NOT M STREQUAL "LinguistTools")
|
|
|
|
list(APPEND QT_TARGETS Qt5::${M})
|
2015-12-17 18:10:43 +00:00
|
|
|
endif()
|
2017-02-11 10:24:42 +00:00
|
|
|
else()
|
|
|
|
set(QT_TARGETS)
|
|
|
|
break()
|
2015-12-16 20:01:03 +00:00
|
|
|
endif()
|
2017-02-11 10:24:42 +00:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(QT_TARGETS)
|
|
|
|
foreach(M ${QT5_OPTIONAL_MODULES})
|
|
|
|
find_package(Qt5${M} ${QT5_MINIMUM} QUIET)
|
|
|
|
if(Qt5${M}_FOUND)
|
|
|
|
list(APPEND QT_TARGETS Qt5::${M})
|
2015-12-16 18:46:06 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2017-02-11 10:24:42 +00:00
|
|
|
|
|
|
|
if(Qt5AxContainer_FOUND AND Qt5AxServer_FOUND)
|
|
|
|
set(ENABLE_QT_COM_INTEROP ON)
|
|
|
|
|
|
|
|
find_program(MIDL_EXECUTABLE midl)
|
|
|
|
if(NOT MIDL_EXECUTABLE)
|
|
|
|
set(ENABLE_QT_COM_INTEROP OFF)
|
2015-12-17 18:10:43 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2017-02-11 10:24:42 +00:00
|
|
|
if(Qt5DBus_FOUND)
|
|
|
|
set(ENABLE_QT_DBUS_INTEROP ON)
|
2015-12-16 20:01:03 +00:00
|
|
|
endif()
|
2015-12-16 18:46:06 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(QT_FOUND ON)
|
2015-12-17 18:10:43 +00:00
|
|
|
if(NOT QT_TARGETS OR NOT (ENABLE_QT_COM_INTEROP OR ENABLE_QT_DBUS_INTEROP))
|
2015-12-16 18:46:06 +00:00
|
|
|
if(QT_IS_REQUIRED)
|
2015-12-17 18:10:43 +00:00
|
|
|
message(FATAL_ERROR "Unable to find required Qt libraries.")
|
2015-12-16 18:46:06 +00:00
|
|
|
endif()
|
|
|
|
set(QT_FOUND OFF)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
tr_fixup_auto_option(ENABLE_QT QT_FOUND QT_IS_REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2016-09-10 17:08:58 +00:00
|
|
|
if(ENABLE_MAC)
|
|
|
|
tr_get_required_flag(ENABLE_MAC MAC_IS_REQUIRED)
|
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
set(MAC_FOUND ON)
|
|
|
|
else()
|
|
|
|
set(MAC_FOUND OFF)
|
|
|
|
if(MAC_IS_REQUIRED)
|
|
|
|
message(SEND_ERROR "Mac build is impossible on non-Mac system.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
tr_fixup_auto_option(ENABLE_MAC MAC_FOUND MAC_IS_REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
find_package(ZLIB ${ZLIB_MINIMUM})
|
|
|
|
if(ZLIB_FOUND)
|
|
|
|
add_definitions(-DHAVE_ZLIB)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(THIRD_PARTY_DIR ${CMAKE_SOURCE_DIR}/third-party)
|
|
|
|
|
|
|
|
if(WIN32)
|
2017-01-01 18:40:11 +00:00
|
|
|
tr_add_external_auto_library(EVENT2 libevent event)
|
2014-12-01 19:55:22 +00:00
|
|
|
else()
|
2016-09-10 17:08:58 +00:00
|
|
|
set(EVENT2_CONFIGURE_FLAGS)
|
|
|
|
if(APPLE)
|
|
|
|
if(CRYPTO_PKG STREQUAL "openssl")
|
|
|
|
list(APPEND EVENT2_CONFIGURE_FLAGS "CPPFLAGS=-I${CRYPTO_INCLUDE_DIRS}")
|
|
|
|
else()
|
|
|
|
list(APPEND EVENT2_CONFIGURE_FLAGS "CPPFLAGS=-I${THIRD_PARTY_DIR}/openssl/include")
|
|
|
|
endif()
|
|
|
|
endif()
|
2017-01-01 18:40:11 +00:00
|
|
|
tr_add_external_auto_library(EVENT2 libevent event
|
2014-12-01 19:55:22 +00:00
|
|
|
BUILD_IN_SOURCE 1
|
|
|
|
CONFIGURE_COMMAND "<SOURCE_DIR>/autogen.sh"
|
2016-09-10 17:08:58 +00:00
|
|
|
COMMAND "<SOURCE_DIR>/configure" "--prefix=<INSTALL_DIR>" "--disable-shared" ${EVENT2_CONFIGURE_FLAGS})
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
2017-01-01 18:40:11 +00:00
|
|
|
tr_add_external_auto_library(NATPMP libnatpmp natpmp)
|
2014-12-01 19:55:22 +00:00
|
|
|
if(NOT USE_SYSTEM_NATPMP)
|
|
|
|
set(NATPMP_DEFINITIONS -DNATPMP_STATICLIB)
|
|
|
|
endif()
|
|
|
|
|
2017-01-01 18:40:11 +00:00
|
|
|
tr_add_external_auto_library(MINIUPNPC miniupnpc miniupnpc
|
2014-12-01 19:55:22 +00:00
|
|
|
CMAKE_ARGS
|
|
|
|
-DUPNPC_BUILD_STATIC=ON
|
|
|
|
-DUPNPC_BUILD_SHARED=OFF
|
|
|
|
-DUPNPC_BUILD_TESTS=OFF)
|
|
|
|
set(MINIUPNPC_DEFINITIONS -DSYSTEM_MINIUPNP)
|
|
|
|
if(NOT USE_SYSTEM_MINIUPNPC)
|
|
|
|
list(APPEND MINIUPNPC_DEFINITIONS -DMINIUPNP_STATICLIB)
|
|
|
|
set(MINIUPNPC_VERSION 1.9)
|
2015-04-21 13:56:17 +00:00
|
|
|
set(MINIUPNPC_API_VERSION 12)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
2017-01-01 18:40:11 +00:00
|
|
|
tr_add_external_auto_library(DHT dht dht)
|
2014-12-01 19:55:22 +00:00
|
|
|
|
|
|
|
if(ENABLE_UTP)
|
2017-01-01 18:40:11 +00:00
|
|
|
tr_add_external_auto_library(UTP libutp utp)
|
2017-05-20 10:04:49 +00:00
|
|
|
|
|
|
|
if(UTP_UPSTREAM_TARGET)
|
|
|
|
# Use C++ linker for anything that depends on static libutp
|
|
|
|
# TODO: switch to imported targets for all the dependencies
|
|
|
|
add_library(UTP::UTP STATIC IMPORTED)
|
|
|
|
set_property(TARGET UTP::UTP PROPERTY IMPORTED_LOCATION "${UTP_LIBRARIES}")
|
|
|
|
set_property(TARGET UTP::UTP PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
|
|
|
|
set(UTP_LIBRARIES UTP::UTP)
|
|
|
|
endif()
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
2017-01-01 18:40:11 +00:00
|
|
|
tr_add_external_auto_library(B64 libb64 b64)
|
2015-01-01 21:16:36 +00:00
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
if(WITH_INOTIFY)
|
|
|
|
tr_get_required_flag(WITH_INOTIFY INOTIFY_IS_REQUIRED)
|
|
|
|
|
|
|
|
set(INOTIFY_FOUND OFF)
|
|
|
|
check_include_file(sys/inotify.h HAVE_SYS_INOTIFY_H)
|
|
|
|
check_function_exists(inotify_init HAVE_INOTIFY_INIT)
|
|
|
|
if(HAVE_SYS_INOTIFY_H AND HAVE_INOTIFY_INIT)
|
|
|
|
set(INOTIFY_FOUND ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
tr_fixup_auto_option(WITH_INOTIFY INOTIFY_FOUND INOTIFY_IS_REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_KQUEUE)
|
|
|
|
tr_get_required_flag(WITH_KQUEUE KQUEUE_IS_REQUIRED)
|
|
|
|
|
|
|
|
set(KQUEUE_FOUND OFF)
|
|
|
|
check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
|
|
|
|
check_function_exists(kqueue HAVE_KQUEUE)
|
|
|
|
if(HAVE_SYS_EVENT_H AND HAVE_KQUEUE)
|
|
|
|
set(KQUEUE_FOUND ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
tr_fixup_auto_option(WITH_KQUEUE KQUEUE_FOUND KQUEUE_IS_REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_SYSTEMD)
|
|
|
|
tr_get_required_flag(WITH_SYSTEMD SYSTEMD_IS_REQUIRED)
|
2016-12-19 02:53:19 +00:00
|
|
|
find_package(SYSTEMD)
|
2016-04-23 16:13:25 +00:00
|
|
|
tr_fixup_auto_option(WITH_SYSTEMD SYSTEMD_FOUND SYSTEMD_IS_REQUIRED)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
include_directories(${CMAKE_BINARY_DIR})
|
|
|
|
|
2015-04-23 21:32:00 +00:00
|
|
|
if(WIN32)
|
|
|
|
foreach(L C CXX)
|
|
|
|
# Filter out needless definitions
|
|
|
|
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} -DWIN32_LEAN_AND_MEAN -DNOMINMAX")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2015-08-01 16:05:02 +00:00
|
|
|
if(CMAKE_VERSION VERSION_LESS "3.1")
|
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
|
2019-11-07 00:17:48 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17")
|
2015-08-01 16:05:02 +00:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
2019-11-07 00:17:48 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2015-08-01 16:05:02 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
endif()
|
2014-12-01 19:55:22 +00:00
|
|
|
|
2015-08-01 16:05:02 +00:00
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
2014-12-01 19:55:22 +00:00
|
|
|
set(NEEDED_COMPILER_FLAGS
|
2014-12-11 05:11:02 +00:00
|
|
|
-Wall
|
|
|
|
-W
|
2014-12-06 16:28:53 +00:00
|
|
|
-Wcast-align
|
|
|
|
-Wfloat-equal
|
2014-12-01 19:55:22 +00:00
|
|
|
-Wmissing-format-attribute
|
2014-12-06 16:28:53 +00:00
|
|
|
-Wpointer-arith
|
2014-12-01 19:55:22 +00:00
|
|
|
-Wredundant-decls
|
2014-12-06 16:28:53 +00:00
|
|
|
-Wundef
|
2014-12-01 19:55:22 +00:00
|
|
|
-Wunused-parameter
|
2014-12-06 16:28:53 +00:00
|
|
|
-Wwrite-strings)
|
2014-12-01 19:55:22 +00:00
|
|
|
|
2014-12-11 05:11:02 +00:00
|
|
|
if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_VERSION VERSION_GREATER "3.3")
|
|
|
|
list(APPEND NEEDED_COMPILER_FLAGS
|
|
|
|
-Wextra
|
|
|
|
-Winit-self)
|
|
|
|
endif()
|
|
|
|
|
2016-01-09 18:24:43 +00:00
|
|
|
if(MINGW)
|
|
|
|
# Disable excessive warnings since we're using __USE_MINGW_ANSI_STDIO
|
|
|
|
# Hopefully, any potential issues will be spotted on other platforms
|
|
|
|
list(APPEND NEEDED_COMPILER_FLAGS -Wno-format)
|
|
|
|
else()
|
|
|
|
list(APPEND NEEDED_COMPILER_FLAGS -Wformat-security)
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
set(NEEDED_C_COMPILER_FLAGS
|
|
|
|
${NEEDED_COMPILER_FLAGS}
|
2014-12-11 05:25:26 +00:00
|
|
|
-Winline
|
2014-12-11 05:11:02 +00:00
|
|
|
-Wmissing-declarations
|
2014-12-01 19:55:22 +00:00
|
|
|
-Wnested-externs
|
2014-12-06 16:28:53 +00:00
|
|
|
-Wstrict-prototypes)
|
2014-12-01 19:55:22 +00:00
|
|
|
string(REPLACE ";" " " NEEDED_C_COMPILER_FLAGS_STRING "${NEEDED_C_COMPILER_FLAGS}")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NEEDED_C_COMPILER_FLAGS_STRING}")
|
|
|
|
|
|
|
|
set(NEEDED_CXX_COMPILER_FLAGS
|
|
|
|
${NEEDED_COMPILER_FLAGS})
|
|
|
|
string(REPLACE ";" " " NEEDED_CXX_COMPILER_FLAGS_STRING "${NEEDED_CXX_COMPILER_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NEEDED_CXX_COMPILER_FLAGS_STRING}")
|
|
|
|
endif()
|
|
|
|
|
2015-03-10 22:31:09 +00:00
|
|
|
include(LargeFileSupport)
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
set(NEEDED_HEADERS
|
|
|
|
sys/statvfs.h
|
2015-06-01 05:25:14 +00:00
|
|
|
xfs/xfs.h
|
|
|
|
xlocale.h)
|
2014-12-01 19:55:22 +00:00
|
|
|
|
2014-12-20 22:28:43 +00:00
|
|
|
if(ENABLE_NLS)
|
|
|
|
list(APPEND NEEDED_HEADERS libintl.h)
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
foreach(H ${NEEDED_HEADERS})
|
|
|
|
tr_make_id("${H}" H_ID)
|
|
|
|
check_include_file(${H} HAVE_${H_ID})
|
|
|
|
if(HAVE_${H_ID})
|
|
|
|
add_definitions(-DHAVE_${H_ID})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(NEEDED_FUNCTIONS
|
2015-06-01 18:52:14 +00:00
|
|
|
_configthreadlocale
|
2014-12-06 16:28:53 +00:00
|
|
|
canonicalize_file_name
|
2014-12-01 19:55:22 +00:00
|
|
|
daemon
|
|
|
|
fallocate64
|
2019-07-13 19:53:04 +00:00
|
|
|
flock
|
2014-12-01 19:55:22 +00:00
|
|
|
getmntent
|
|
|
|
getpagesize
|
|
|
|
htonll
|
|
|
|
localtime_r
|
|
|
|
memmem
|
|
|
|
mkdtemp
|
|
|
|
ntohll
|
|
|
|
posix_fadvise
|
|
|
|
posix_fallocate
|
|
|
|
posix_memalign
|
|
|
|
pread
|
|
|
|
pwrite
|
|
|
|
statvfs
|
2019-03-17 14:37:52 +00:00
|
|
|
strcasestr
|
2014-12-01 19:55:22 +00:00
|
|
|
strlcpy
|
|
|
|
strsep
|
|
|
|
syslog
|
2015-06-01 05:25:14 +00:00
|
|
|
uselocale
|
2014-12-01 19:55:22 +00:00
|
|
|
valloc)
|
|
|
|
|
|
|
|
foreach(F ${NEEDED_FUNCTIONS})
|
|
|
|
tr_make_id("${F}" F_ID)
|
|
|
|
check_function_exists(${F} HAVE_${F_ID})
|
|
|
|
if(HAVE_${F_ID})
|
|
|
|
add_definitions(-DHAVE_${F_ID})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2016-02-07 11:54:01 +00:00
|
|
|
if(ICONV_FOUND)
|
2016-02-23 03:00:12 +00:00
|
|
|
add_definitions(-DHAVE_ICONV)
|
2016-02-23 05:07:43 +00:00
|
|
|
if(ICONV_SECOND_ARGUMENT_IS_CONST)
|
|
|
|
add_definitions(-DICONV_SECOND_ARGUMENT_IS_CONST)
|
|
|
|
endif()
|
2016-02-07 11:54:01 +00:00
|
|
|
endif()
|
|
|
|
|
2014-12-13 16:00:14 +00:00
|
|
|
# if(MINGW)
|
|
|
|
# check_function_exists(__mingw_printf HAVE_MINGW_PRINTF)
|
|
|
|
# if(HAVE_MINGW_PRINTF)
|
|
|
|
# add_definitions(-D__USE_MINGW_ANSI_STDIO=1 -D__STDC_FORMAT_MACROS=1)
|
|
|
|
# endif()
|
|
|
|
# endif()
|
2014-12-01 19:55:22 +00:00
|
|
|
|
2014-12-20 22:28:43 +00:00
|
|
|
if(ENABLE_NLS)
|
|
|
|
check_library_exists(intl libintl_gettext "" HAVE_LIBINTL)
|
|
|
|
if(HAVE_LIBINTL)
|
|
|
|
set(LIBINTL_LIBRARY intl)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
check_library_exists(m sqrt "" HAVE_LIBM)
|
|
|
|
if(HAVE_LIBM)
|
|
|
|
set(LIBM_LIBRARY m)
|
|
|
|
endif()
|
|
|
|
|
2016-12-24 17:11:27 +00:00
|
|
|
set(TR_NETWORK_LIBRARIES)
|
|
|
|
if(WIN32)
|
|
|
|
list(APPEND TR_NETWORK_LIBRARIES iphlpapi ws2_32)
|
|
|
|
else()
|
|
|
|
tr_select_library("c;socket;net" socket "" LIB)
|
|
|
|
if(NOT LIB MATCHES "^(|c)$")
|
|
|
|
list(APPEND TR_NETWORK_LIBRARIES ${LIB})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
tr_select_library("c;nsl;bind" gethostbyname "" LIB)
|
|
|
|
if(NOT LIB MATCHES "^(|c)$")
|
|
|
|
list(APPEND TR_NETWORK_LIBRARIES ${LIB})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-05-20 01:32:51 +00:00
|
|
|
if(NOT CMAKE_VERSION VERSION_LESS "3.7.2")
|
|
|
|
message(STATUS "Looking for clang-tidy")
|
|
|
|
find_program(CLANG_TIDY clang-tidy)
|
|
|
|
if (CLANG_TIDY STREQUAL "CLANG_TIDY-NOTFOUND")
|
|
|
|
message(STATUS "Looking for clang-tidy - not found")
|
|
|
|
else()
|
|
|
|
message(STATUS "Looking for clang-tidy - found")
|
|
|
|
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
if(ENABLE_TESTS)
|
|
|
|
enable_testing()
|
|
|
|
endif()
|
|
|
|
|
2016-09-10 17:08:58 +00:00
|
|
|
function(tr_install_web DST_DIR)
|
|
|
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/web DESTINATION ${DST_DIR}
|
|
|
|
PATTERN *.am EXCLUDE
|
|
|
|
PATTERN *.in EXCLUDE
|
|
|
|
PATTERN *.scss EXCLUDE)
|
|
|
|
endfunction()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
add_subdirectory(libtransmission)
|
|
|
|
|
2016-09-10 17:08:58 +00:00
|
|
|
set(MAC_PROJECT_DIR macosx)
|
|
|
|
|
2018-04-18 09:25:13 +00:00
|
|
|
if(ENABLE_GTK AND ENABLE_NLS)
|
|
|
|
find_package(Gettext 0.19.7 REQUIRED)
|
|
|
|
add_subdirectory(po)
|
|
|
|
endif()
|
|
|
|
|
2016-09-10 17:08:58 +00:00
|
|
|
foreach(P daemon cli utils gtk qt mac)
|
2014-12-01 19:55:22 +00:00
|
|
|
string(TOUPPER "${P}" P_ID)
|
|
|
|
if(ENABLE_${P_ID})
|
2016-09-10 17:08:58 +00:00
|
|
|
if(DEFINED ${P_ID}_PROJECT_DIR)
|
|
|
|
set(P ${${P_ID}_PROJECT_DIR})
|
|
|
|
endif()
|
2014-12-01 19:55:22 +00:00
|
|
|
add_subdirectory(${P})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(ENABLE_DAEMON OR ENABLE_GTK OR ENABLE_QT)
|
2016-09-10 17:08:58 +00:00
|
|
|
tr_install_web(${CMAKE_INSTALL_DATAROOTDIR}/${TR_NAME})
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(INSTALL_DOC)
|
2020-05-03 23:33:57 +00:00
|
|
|
install(FILES AUTHORS COPYING NEWS.md README.md extras/rpc-spec.txt extras/send-email-when-torrent-done.sh DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
2017-02-11 10:24:42 +00:00
|
|
|
if(MSVC AND ENABLE_DAEMON AND ENABLE_QT AND ENABLE_UTILS AND WITH_CRYPTO STREQUAL "openssl")
|
2016-04-02 18:01:01 +00:00
|
|
|
add_subdirectory(dist/msi)
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
set(CPACK_SOURCE_GENERATOR TBZ2)
|
|
|
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${TR_NAME}-${TR_USER_AGENT_PREFIX}")
|
|
|
|
set(CPACK_SOURCE_IGNORE_FILES
|
2017-01-03 02:06:54 +00:00
|
|
|
\\\\.git
|
2014-12-01 19:55:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
include(CPack)
|