2023-01-01 19:49:48 +00:00
|
|
|
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
|
2021-11-03 05:13:44 +00:00
|
|
|
|
2022-04-12 06:56:09 +00:00
|
|
|
if(POLICY CMP0092)
|
|
|
|
cmake_policy(SET CMP0092 NEW)
|
|
|
|
endif()
|
2023-04-14 14:57:49 +00:00
|
|
|
if(POLICY CMP0114)
|
|
|
|
cmake_policy(SET CMP0114 NEW)
|
|
|
|
endif()
|
2022-04-12 06:56:09 +00:00
|
|
|
|
2022-12-14 16:11:32 +00:00
|
|
|
# Value should follow latest stable Xcode's RECOMMENDED_MACOSX_DEPLOYMENT_TARGET
|
2023-04-14 20:02:52 +00:00
|
|
|
set(MACOS_SUPPORT_MINIMUM 10.14.6)
|
2022-12-14 16:11:32 +00:00
|
|
|
|
2021-11-03 05:13:44 +00:00
|
|
|
# The value of this variable should be set prior to the first project() command invocation.
|
|
|
|
# See: https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html
|
2022-11-13 12:02:07 +00:00
|
|
|
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
|
2023-01-01 19:49:48 +00:00
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET ${MACOS_SUPPORT_MINIMUM}
|
|
|
|
CACHE STRING "Minimum macOS version to target for deployment"
|
|
|
|
FORCE)
|
2021-11-03 05:13:44 +00:00
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
project(transmission)
|
|
|
|
|
2023-10-30 17:44:34 +00:00
|
|
|
set(TR_THIRD_PARTY_DIR_NAME third-party)
|
|
|
|
set(TR_THIRD_PARTY_SOURCE_DIR ${PROJECT_SOURCE_DIR}/${TR_THIRD_PARTY_DIR_NAME})
|
|
|
|
set(TR_THIRD_PARTY_BINARY_DIR ${PROJECT_BINARY_DIR}/${TR_THIRD_PARTY_DIR_NAME})
|
|
|
|
|
|
|
|
list(APPEND CMAKE_MODULE_PATH
|
|
|
|
"${PROJECT_SOURCE_DIR}/cmake"
|
|
|
|
"${TR_THIRD_PARTY_SOURCE_DIR}/rpavlik-cmake-modules")
|
2014-12-01 19:55:22 +00:00
|
|
|
|
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)
|
|
|
|
|
2023-01-01 19:49:48 +00:00
|
|
|
set(CURL_MINIMUM 7.28.0)
|
|
|
|
set(WOLFSSL_MINIMUM 3.4)
|
2023-02-21 03:33:50 +00:00
|
|
|
set(DEFLATE_MINIMUM 1.7)
|
2023-01-01 19:49:48 +00:00
|
|
|
set(EVENT2_MINIMUM 2.1.0)
|
|
|
|
set(GIOMM_MINIMUM 2.26.0)
|
|
|
|
set(GLIBMM_MINIMUM 2.60.0)
|
2023-08-06 03:26:29 +00:00
|
|
|
set(GTKMM3_MINIMUM 3.24.0)
|
|
|
|
set(GTKMM4_MINIMUM 4.11.1)
|
2023-09-30 04:09:10 +00:00
|
|
|
set(OPENSSL_MINIMUM 1.1.0)
|
2023-01-01 19:49:48 +00:00
|
|
|
set(MBEDTLS_MINIMUM 1.3)
|
2023-01-26 04:17:24 +00:00
|
|
|
set(NPM_MINIMUM 8.1.307) # Node.js 14
|
2023-01-01 19:49:48 +00:00
|
|
|
set(PSL_MINIMUM 0.21.1)
|
|
|
|
set(QT_MINIMUM 5.6)
|
|
|
|
|
|
|
|
option(ENABLE_DAEMON "Build daemon" ON)
|
|
|
|
tr_auto_option(ENABLE_GTK "Build GTK client" AUTO)
|
|
|
|
tr_auto_option(ENABLE_QT "Build Qt client" AUTO)
|
|
|
|
tr_auto_option(ENABLE_MAC "Build Mac client" AUTO)
|
2023-02-08 23:47:07 +00:00
|
|
|
tr_auto_option(REBUILD_WEB "Rebuild the web client's generated assets. Requires Node.js and network access." OFF)
|
2023-02-22 12:25:50 +00:00
|
|
|
option(INSTALL_WEB "Install the web client's generated assets." ON)
|
2023-01-01 19:49:48 +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_UTP "Build µTP support" ON)
|
|
|
|
option(ENABLE_WERROR "Treat warnings as errors" OFF)
|
|
|
|
option(ENABLE_NLS "Enable native language support" ON)
|
|
|
|
option(INSTALL_DOC "Build/install documentation" ON)
|
|
|
|
option(INSTALL_LIB "Install the library" OFF)
|
2023-03-27 16:04:10 +00:00
|
|
|
tr_auto_option(ENABLE_DEPRECATED "Allow deprecated API use of upstream packages, e.g. GTK" AUTO)
|
2023-02-11 15:28:52 +00:00
|
|
|
tr_auto_option(RUN_CLANG_TIDY "Run clang-tidy on the code" OFF)
|
2023-01-01 19:49:48 +00:00
|
|
|
tr_auto_option(USE_SYSTEM_EVENT2 "Use system event2 library" AUTO)
|
|
|
|
tr_auto_option(USE_SYSTEM_DEFLATE "Use system deflate library" AUTO)
|
|
|
|
tr_auto_option(USE_SYSTEM_DHT "Use system dht library" AUTO)
|
2014-12-01 19:55:22 +00:00
|
|
|
tr_auto_option(USE_SYSTEM_MINIUPNPC "Use system miniupnpc library" AUTO)
|
2023-01-01 19:49:48 +00:00
|
|
|
tr_auto_option(USE_SYSTEM_NATPMP "Use system natpmp library" AUTO)
|
|
|
|
tr_auto_option(USE_SYSTEM_UTP "Use system utp library" AUTO)
|
|
|
|
tr_auto_option(USE_SYSTEM_B64 "Use system b64 library" AUTO)
|
|
|
|
tr_auto_option(USE_SYSTEM_PSL "Use system psl library" AUTO)
|
|
|
|
tr_list_option(USE_GTK_VERSION "Use specific GTK version" AUTO 3 4)
|
|
|
|
tr_list_option(USE_QT_VERSION "Use specific Qt version" AUTO 5 6)
|
|
|
|
tr_list_option(WITH_CRYPTO "Use specified crypto library" AUTO ccrypto mbedtls openssl wolfssl)
|
|
|
|
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)
|
|
|
|
tr_auto_option(WITH_APPINDICATOR "Use appindicator for system tray icon in GTK client (GTK+ 3 only)" AUTO)
|
|
|
|
tr_auto_option(WITH_SYSTEMD "Add support for systemd startup notification (on systems that support it)" AUTO)
|
2014-12-01 19:55:22 +00:00
|
|
|
|
|
|
|
set(TR_NAME ${PROJECT_NAME})
|
|
|
|
|
2022-10-05 21:53:10 +00:00
|
|
|
# major.minor.patch[-[beta.N.]dev]+commit_hash
|
|
|
|
# dev builds come between releases, e.g. autobuilds from CI
|
|
|
|
|
|
|
|
# these should be the only five lines you need to change
|
2022-10-07 01:46:36 +00:00
|
|
|
set(TR_VERSION_MAJOR "4")
|
2023-04-14 13:59:50 +00:00
|
|
|
set(TR_VERSION_MINOR "1")
|
|
|
|
set(TR_VERSION_PATCH "0")
|
2023-02-07 23:37:08 +00:00
|
|
|
set(TR_VERSION_BETA_NUMBER "") # empty string for not beta
|
2023-04-14 13:59:50 +00:00
|
|
|
set(TR_VERSION_DEV TRUE)
|
2022-10-05 21:53:10 +00:00
|
|
|
|
|
|
|
# derived from above: release type
|
2023-01-01 19:49:48 +00:00
|
|
|
if(TR_VERSION_DEV)
|
2014-12-01 19:55:22 +00:00
|
|
|
set(TR_NIGHTLY_RELEASE 1)
|
2023-01-01 19:49:48 +00:00
|
|
|
elseif(NOT "${TR_VERSION_BETA_NUMBER}" STREQUAL "")
|
2022-10-05 21:53:10 +00:00
|
|
|
set(TR_BETA_RELEASE 1)
|
2014-12-01 19:55:22 +00:00
|
|
|
else()
|
|
|
|
set(TR_STABLE_RELEASE 1)
|
|
|
|
endif()
|
|
|
|
|
2022-10-05 21:53:10 +00:00
|
|
|
# derived from above: semver version string. https://semver.org/
|
|
|
|
# '4.0.0-beta.1'
|
|
|
|
# '4.0.0-beta.1.dev' (a dev release between beta 1 and 2)
|
|
|
|
# '4.0.0-beta.2'
|
|
|
|
# '4.0.0'
|
|
|
|
set(TR_SEMVER "${TR_VERSION_MAJOR}.${TR_VERSION_MINOR}.${TR_VERSION_PATCH}")
|
2023-01-01 19:49:48 +00:00
|
|
|
if(TR_VERSION_DEV OR NOT "${TR_VERSION_BETA_NUMBER}" STREQUAL "")
|
2022-10-05 21:53:10 +00:00
|
|
|
string(APPEND TR_SEMVER "-")
|
2023-01-01 19:49:48 +00:00
|
|
|
if(NOT "${TR_VERSION_BETA_NUMBER}" STREQUAL "")
|
2022-10-05 21:53:10 +00:00
|
|
|
string(APPEND TR_SEMVER "beta.${TR_VERSION_BETA_NUMBER}")
|
|
|
|
endif()
|
2023-01-01 19:49:48 +00:00
|
|
|
if(TR_VERSION_DEV AND NOT "${TR_VERSION_BETA_NUMBER}" STREQUAL "")
|
2022-10-05 21:53:10 +00:00
|
|
|
string(APPEND TR_SEMVER ".")
|
|
|
|
endif()
|
2023-01-01 19:49:48 +00:00
|
|
|
if(TR_VERSION_DEV)
|
2022-10-05 21:53:10 +00:00
|
|
|
string(APPEND TR_SEMVER "dev")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
set(TR_USER_AGENT_PREFIX "${TR_SEMVER}")
|
|
|
|
|
|
|
|
# derived from above: peer-id prefix. https://www.bittorrent.org/beps/bep_0020.html
|
|
|
|
# chars 4, 5, 6 are major, minor, patch in https://en.wikipedia.org/wiki/Base62
|
|
|
|
# char 7 is '0' for a stable release, 'B' for a beta release, or 'Z' for a dev build
|
|
|
|
# '-TR400B-' (4.0.0 Beta)
|
|
|
|
# '-TR400Z-' (4.0.0 Dev)
|
|
|
|
# '-TR4000-' (4.0.0)
|
|
|
|
set(TR_PEER_ID_PREFIX "-TR")
|
|
|
|
set(BASE62 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
|
|
|
|
string(SUBSTRING "${BASE62}" "${TR_VERSION_MAJOR}" 1 TMPSTR)
|
|
|
|
string(APPEND TR_PEER_ID_PREFIX "${TMPSTR}")
|
|
|
|
string(SUBSTRING "${BASE62}" "${TR_VERSION_MINOR}" 1 TMPSTR)
|
|
|
|
string(APPEND TR_PEER_ID_PREFIX "${TMPSTR}")
|
|
|
|
string(SUBSTRING "${BASE62}" "${TR_VERSION_PATCH}" 1 TMPSTR)
|
|
|
|
string(APPEND TR_PEER_ID_PREFIX "${TMPSTR}")
|
2023-01-01 19:49:48 +00:00
|
|
|
if(TR_VERSION_DEV)
|
2022-10-05 21:53:10 +00:00
|
|
|
string(APPEND TR_PEER_ID_PREFIX "Z")
|
2023-01-01 19:49:48 +00:00
|
|
|
elseif(NOT "${TR_VERSION_BETA_NUMBER}" STREQUAL "")
|
2022-10-05 21:53:10 +00:00
|
|
|
string(APPEND TR_PEER_ID_PREFIX "B")
|
|
|
|
else()
|
|
|
|
string(APPEND TR_PEER_ID_PREFIX "0")
|
|
|
|
endif()
|
|
|
|
string(APPEND TR_PEER_ID_PREFIX "-")
|
|
|
|
|
2023-10-30 17:44:34 +00:00
|
|
|
set(TR_VCS_REVISION_FILE "${PROJECT_SOURCE_DIR}/REVISION")
|
2023-10-30 06:03:40 +00:00
|
|
|
|
2023-11-14 19:24:18 +00:00
|
|
|
## Compiler standard version
|
|
|
|
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
2023-10-30 17:44:34 +00:00
|
|
|
if(EXISTS ${PROJECT_SOURCE_DIR}/.git)
|
2020-09-14 02:41:32 +00:00
|
|
|
find_package(Git)
|
|
|
|
endif()
|
|
|
|
|
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}")
|
2020-09-14 02:41:32 +00:00
|
|
|
elseif(GIT_FOUND)
|
2023-10-30 06:03:40 +00:00
|
|
|
include(GetGitRevisionDescription)
|
|
|
|
get_git_head_revision(TR_REFSPEC TR_VCS_REVISION)
|
|
|
|
unset(TR_REFSPEC)
|
2014-12-01 19:55:22 +00:00
|
|
|
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
|
|
|
if(WIN32)
|
|
|
|
foreach(L C CXX)
|
2020-08-11 18:11:55 +00:00
|
|
|
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} -DWIN32")
|
2014-12-01 19:55:22 +00:00
|
|
|
# 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")
|
|
|
|
if(MSVC)
|
2023-02-22 12:00:07 +00:00
|
|
|
# Set source file encoding and execution charset to UTF-8
|
|
|
|
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} /utf-8")
|
2014-12-01 19:55:22 +00:00
|
|
|
# Reduce noise (at least for now)
|
|
|
|
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} /wd4244 /wd4267")
|
2023-02-11 13:56:08 +00:00
|
|
|
# Make caching-friendly (store debug info inside object files)
|
|
|
|
foreach(T IN ITEMS ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
|
|
|
|
string(TOUPPER "${T}" T)
|
|
|
|
string(REGEX REPLACE "[-/]Z[iI]" "-Z7" CMAKE_${L}_FLAGS_${T} "${CMAKE_${L}_FLAGS_${T}}")
|
|
|
|
endforeach()
|
2014-12-01 19:55:22 +00:00
|
|
|
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()
|
|
|
|
|
2023-10-30 17:44:34 +00:00
|
|
|
set(CMAKE_FOLDER "${TR_THIRD_PARTY_DIR_NAME}")
|
|
|
|
|
2022-05-16 05:06:17 +00:00
|
|
|
find_package(FastFloat)
|
2023-06-21 03:50:36 +00:00
|
|
|
find_package(Fmt)
|
2023-10-21 19:00:12 +00:00
|
|
|
find_package(RapidJSON)
|
2023-06-21 03:50:36 +00:00
|
|
|
find_package(Small)
|
2021-11-30 21:13:56 +00:00
|
|
|
find_package(UtfCpp)
|
2023-06-21 03:50:36 +00:00
|
|
|
find_package(WideInteger)
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
find_package(Threads)
|
|
|
|
find_package(PkgConfig QUIET)
|
|
|
|
|
|
|
|
find_package(CURL ${CURL_MINIMUM} REQUIRED)
|
|
|
|
|
2023-03-27 16:04:10 +00:00
|
|
|
if(ENABLE_DEPRECATED STREQUAL "AUTO")
|
|
|
|
if(DEFINED ENV{CI})
|
|
|
|
set(ENABLE_DEPRECATED OFF)
|
|
|
|
else()
|
|
|
|
set(ENABLE_DEPRECATED ON)
|
|
|
|
endif()
|
2023-03-24 18:34:30 +00:00
|
|
|
endif()
|
|
|
|
|
2017-02-23 20:18:45 +00:00
|
|
|
set(CRYPTO_PKG "")
|
2021-10-24 18:19:57 +00:00
|
|
|
if(WITH_CRYPTO STREQUAL "AUTO" OR WITH_CRYPTO STREQUAL "ccrypto")
|
|
|
|
tr_get_required_flag(WITH_CRYPTO CCRYPTO_IS_REQUIRED)
|
2023-01-01 19:49:48 +00:00
|
|
|
find_path(CCRYPTO_INCLUDE_DIR
|
|
|
|
NAMES CommonCrypto/CommonCrypto.h
|
|
|
|
${CCRYPTO_IS_REQUIRED})
|
2021-10-24 18:19:57 +00:00
|
|
|
mark_as_advanced(CCRYPTO_INCLUDE_DIR)
|
|
|
|
tr_fixup_list_option(WITH_CRYPTO "ccrypto" CCRYPTO_INCLUDE_DIR "AUTO" CCRYPTO_IS_REQUIRED)
|
|
|
|
if(WITH_CRYPTO STREQUAL "ccrypto")
|
|
|
|
set(CRYPTO_PKG "ccrypto")
|
|
|
|
set(CRYPTO_INCLUDE_DIRS)
|
|
|
|
set(CRYPTO_LIBRARIES)
|
|
|
|
endif()
|
|
|
|
endif()
|
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()
|
2022-12-29 22:38:04 +00:00
|
|
|
if(WITH_CRYPTO STREQUAL "AUTO" OR WITH_CRYPTO STREQUAL "wolfssl")
|
|
|
|
tr_get_required_flag(WITH_CRYPTO WOLFSSL_IS_REQUIRED)
|
|
|
|
find_package(WolfSSL ${WOLFSSL_MINIMUM} ${WOLFSSL_IS_REQUIRED})
|
|
|
|
tr_fixup_list_option(WITH_CRYPTO "wolfssl" WOLFSSL_FOUND "AUTO" WOLFSSL_IS_REQUIRED)
|
|
|
|
if(WITH_CRYPTO STREQUAL "wolfssl")
|
|
|
|
set(CRYPTO_PKG "wolfssl")
|
|
|
|
set(CRYPTO_INCLUDE_DIRS ${WOLFSSL_INCLUDE_DIRS})
|
|
|
|
set(CRYPTO_LIBRARIES ${WOLFSSL_LIBRARIES})
|
2015-01-07 02:04:08 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2022-12-29 22:38:04 +00:00
|
|
|
if(WITH_CRYPTO STREQUAL "AUTO" OR WITH_CRYPTO STREQUAL "mbedtls")
|
|
|
|
tr_get_required_flag(WITH_CRYPTO MBEDTLS_IS_REQUIRED)
|
|
|
|
find_package(MbedTLS ${MBEDTLS_MINIMUM} ${MBEDTLS_IS_REQUIRED})
|
|
|
|
tr_fixup_list_option(WITH_CRYPTO "mbedtls" MBEDTLS_FOUND "AUTO" MBEDTLS_IS_REQUIRED)
|
|
|
|
if(WITH_CRYPTO STREQUAL "mbedtls")
|
|
|
|
set(CRYPTO_PKG "mbedtls")
|
|
|
|
set(CRYPTO_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIRS})
|
|
|
|
set(CRYPTO_LIBRARIES ${MBEDTLS_LIBRARIES})
|
2015-01-07 13:19:00 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2023-01-02 16:23:51 +00:00
|
|
|
|
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()
|
2023-01-02 16:23:51 +00:00
|
|
|
else()
|
|
|
|
add_library(transmission::crypto_impl INTERFACE IMPORTED)
|
|
|
|
|
|
|
|
target_include_directories(transmission::crypto_impl
|
|
|
|
INTERFACE
|
|
|
|
${CRYPTO_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
target_link_libraries(transmission::crypto_impl
|
|
|
|
INTERFACE
|
|
|
|
${CRYPTO_LIBRARIES})
|
2015-01-07 02:04:08 +00:00
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
if(ENABLE_GTK)
|
|
|
|
tr_get_required_flag(ENABLE_GTK GTK_IS_REQUIRED)
|
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
if(USE_GTK_VERSION STREQUAL "AUTO" OR USE_GTK_VERSION EQUAL 4)
|
2022-10-09 07:29:47 +00:00
|
|
|
pkg_check_modules(GTK4
|
2023-08-06 03:26:29 +00:00
|
|
|
gtkmm-4.0>=${GTKMM4_MINIMUM}
|
2022-10-08 22:50:03 +00:00
|
|
|
glibmm-2.68>=${GLIBMM_MINIMUM}
|
|
|
|
giomm-2.68>=${GIOMM_MINIMUM})
|
|
|
|
set(GTK_VERSION 4)
|
2022-10-09 07:29:47 +00:00
|
|
|
set(GTK_FOUND ${GTK4_FOUND})
|
2022-10-08 22:50:03 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT GTK_FOUND AND (USE_GTK_VERSION STREQUAL "AUTO" OR USE_GTK_VERSION EQUAL 3))
|
2022-10-09 07:29:47 +00:00
|
|
|
pkg_check_modules(GTK3
|
2023-08-06 03:26:29 +00:00
|
|
|
gtkmm-3.0>=${GTKMM3_MINIMUM}
|
2022-10-08 22:50:03 +00:00
|
|
|
glibmm-2.4>=${GLIBMM_MINIMUM}
|
|
|
|
giomm-2.4>=${GIOMM_MINIMUM})
|
|
|
|
set(GTK_VERSION 3)
|
2022-10-09 07:29:47 +00:00
|
|
|
set(GTK_FOUND ${GTK3_FOUND})
|
2022-10-08 22:50:03 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(GTK_IS_REQUIRED AND NOT GTK_FOUND)
|
|
|
|
message(FATAL_ERROR "GTK is required but wasn't found")
|
|
|
|
endif()
|
2014-12-01 19:55:22 +00:00
|
|
|
|
|
|
|
tr_fixup_auto_option(ENABLE_GTK GTK_FOUND GTK_IS_REQUIRED)
|
|
|
|
|
2022-10-20 17:15:13 +00:00
|
|
|
if(ENABLE_GTK AND WITH_APPINDICATOR AND GTK_VERSION EQUAL 3)
|
|
|
|
tr_get_required_flag(WITH_APPINDICATOR APPINDICATOR_IS_REQUIRED)
|
|
|
|
find_package(APPINDICATOR ${APPINDICATOR_IS_REQUIRED})
|
|
|
|
tr_fixup_auto_option(WITH_APPINDICATOR APPINDICATOR_FOUND APPINDICATOR_IS_REQUIRED)
|
2022-10-08 22:50:03 +00:00
|
|
|
else()
|
2022-10-20 17:15:13 +00:00
|
|
|
set(WITH_APPINDICATOR OFF)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
2016-11-27 19:17:07 +00:00
|
|
|
else()
|
2022-10-20 17:15:13 +00:00
|
|
|
set(WITH_APPINDICATOR OFF)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
2023-01-02 16:23:51 +00:00
|
|
|
if(GTK_FOUND)
|
|
|
|
add_library(transmission::gtk_impl INTERFACE IMPORTED)
|
|
|
|
|
|
|
|
target_compile_options(transmission::gtk_impl
|
|
|
|
INTERFACE
|
|
|
|
${GTK${GTK_VERSION}_CFLAGS_OTHER})
|
|
|
|
|
|
|
|
target_include_directories(transmission::gtk_impl
|
|
|
|
INTERFACE
|
|
|
|
${GTK${GTK_VERSION}_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
target_link_directories(transmission::gtk_impl
|
|
|
|
INTERFACE
|
|
|
|
${GTK${GTK_VERSION}_LIBRARY_DIRS})
|
|
|
|
|
|
|
|
target_link_libraries(transmission::gtk_impl
|
|
|
|
INTERFACE
|
|
|
|
${GTK${GTK_VERSION}_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
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)
|
|
|
|
|
2023-01-01 19:49:48 +00:00
|
|
|
set(QT_REQUIRED_MODULES
|
|
|
|
Core
|
|
|
|
Gui
|
|
|
|
Widgets
|
|
|
|
Network
|
|
|
|
Svg
|
|
|
|
LinguistTools)
|
|
|
|
set(QT_OPTIONAL_MODULES
|
|
|
|
DBus
|
|
|
|
AxContainer
|
|
|
|
AxServer)
|
Qt 6 support (#2069)
* Bump minimum Qt version to 5.6
* Switch from QRegExp to QRegularExpression
While still available, QRegExp has been moved to Qt6::Core5Compat module
and is not part of Qt6::Core.
* Use qIsEffectiveTLD instead of QUrl::topLevelDomain
The latter is not part of Qt6::Core. The former is a private utility in
Qt6::Network; using it for now, until (and if) we switch to something
non-Qt-specific.
* Use QStyle::State_Horizontal state when drawing progress bars
Although available for a long time, this state either didn't apply to
progress bars before Qt 6, or was deduced based on bar size. With Qt 6,
failing to specify it results in bad rendering.
* Don't use QStringRef (and associated methods)
While still available, QStringRef has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core. Related method (e.g.
QString::midRef) have been removed in Qt 6.
* Use Qt::ItemIsAutoTristate instead of Qt::ItemIsTristate
The latter was deprecated and replaced with the former in Qt 5.6.
* Don't use QApplication::globalStrut
This property has been deprecated in Qt 5.15 and removed in Qt 6.
* Use QImage::fromHICON instead of QtWin::fromHICON
WinExtras module (providind the latter helper) has been removed in Qt 6.
* Use QStringDecoder instead of QTextCodec
While still available, QTextCodec has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core.
* Don't forward-declare QStringList
Instead of being a standalone class, its definition has changed to
QList<QString> template specialization in Qt 6.
* Use explicit (since Qt 6) QFileInfo constructor
* Use QDateTime's {to,from}SecsSinceEpoch instead of {to,from}Time_t
The latter was deprecated in Qt 5.8 and removed in Qt 6.
* Don't use QFuture<>'s operator==
It has been removed in Qt 6. Since the original issue this code was
solving was caused by future reuse, just don't reuse futures and create
new finished ones when necessary.
* Use std::vector<> instead of QVector<>
The latter has been changed to a typedef for QList<>, which might not be
what one wants, and which also changed behavior a bit leading to
compilation errors.
* Don't use + for flags, cast to int explicitly
Operator+ for enum values has been deleted in Qt 6, so using operator|
instead. Then, there's no conversion from QFlags<> to QVariant, so need
to cast to int.
* Support Qt 6 in CMake and for MSI packaging
* Remove extra (empty) CMake variable use when constructing Qt target names
* Simplify logic in tr_qt_add_translation CMake helper
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-11-03 21:20:11 +00:00
|
|
|
set(MISSING_QT_MODULE)
|
2017-02-11 10:24:42 +00:00
|
|
|
|
Qt 6 support (#2069)
* Bump minimum Qt version to 5.6
* Switch from QRegExp to QRegularExpression
While still available, QRegExp has been moved to Qt6::Core5Compat module
and is not part of Qt6::Core.
* Use qIsEffectiveTLD instead of QUrl::topLevelDomain
The latter is not part of Qt6::Core. The former is a private utility in
Qt6::Network; using it for now, until (and if) we switch to something
non-Qt-specific.
* Use QStyle::State_Horizontal state when drawing progress bars
Although available for a long time, this state either didn't apply to
progress bars before Qt 6, or was deduced based on bar size. With Qt 6,
failing to specify it results in bad rendering.
* Don't use QStringRef (and associated methods)
While still available, QStringRef has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core. Related method (e.g.
QString::midRef) have been removed in Qt 6.
* Use Qt::ItemIsAutoTristate instead of Qt::ItemIsTristate
The latter was deprecated and replaced with the former in Qt 5.6.
* Don't use QApplication::globalStrut
This property has been deprecated in Qt 5.15 and removed in Qt 6.
* Use QImage::fromHICON instead of QtWin::fromHICON
WinExtras module (providind the latter helper) has been removed in Qt 6.
* Use QStringDecoder instead of QTextCodec
While still available, QTextCodec has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core.
* Don't forward-declare QStringList
Instead of being a standalone class, its definition has changed to
QList<QString> template specialization in Qt 6.
* Use explicit (since Qt 6) QFileInfo constructor
* Use QDateTime's {to,from}SecsSinceEpoch instead of {to,from}Time_t
The latter was deprecated in Qt 5.8 and removed in Qt 6.
* Don't use QFuture<>'s operator==
It has been removed in Qt 6. Since the original issue this code was
solving was caused by future reuse, just don't reuse futures and create
new finished ones when necessary.
* Use std::vector<> instead of QVector<>
The latter has been changed to a typedef for QList<>, which might not be
what one wants, and which also changed behavior a bit leading to
compilation errors.
* Don't use + for flags, cast to int explicitly
Operator+ for enum values has been deleted in Qt 6, so using operator|
instead. Then, there's no conversion from QFlags<> to QVariant, so need
to cast to int.
* Support Qt 6 in CMake and for MSI packaging
* Remove extra (empty) CMake variable use when constructing Qt target names
* Simplify logic in tr_qt_add_translation CMake helper
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-11-03 21:20:11 +00:00
|
|
|
set(Qt_NAMES Qt6 Qt5)
|
|
|
|
if(NOT USE_QT_VERSION STREQUAL "AUTO")
|
|
|
|
set(Qt_NAMES Qt${USE_QT_VERSION})
|
2017-02-11 17:48:13 +00:00
|
|
|
endif()
|
|
|
|
|
Qt 6 support (#2069)
* Bump minimum Qt version to 5.6
* Switch from QRegExp to QRegularExpression
While still available, QRegExp has been moved to Qt6::Core5Compat module
and is not part of Qt6::Core.
* Use qIsEffectiveTLD instead of QUrl::topLevelDomain
The latter is not part of Qt6::Core. The former is a private utility in
Qt6::Network; using it for now, until (and if) we switch to something
non-Qt-specific.
* Use QStyle::State_Horizontal state when drawing progress bars
Although available for a long time, this state either didn't apply to
progress bars before Qt 6, or was deduced based on bar size. With Qt 6,
failing to specify it results in bad rendering.
* Don't use QStringRef (and associated methods)
While still available, QStringRef has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core. Related method (e.g.
QString::midRef) have been removed in Qt 6.
* Use Qt::ItemIsAutoTristate instead of Qt::ItemIsTristate
The latter was deprecated and replaced with the former in Qt 5.6.
* Don't use QApplication::globalStrut
This property has been deprecated in Qt 5.15 and removed in Qt 6.
* Use QImage::fromHICON instead of QtWin::fromHICON
WinExtras module (providind the latter helper) has been removed in Qt 6.
* Use QStringDecoder instead of QTextCodec
While still available, QTextCodec has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core.
* Don't forward-declare QStringList
Instead of being a standalone class, its definition has changed to
QList<QString> template specialization in Qt 6.
* Use explicit (since Qt 6) QFileInfo constructor
* Use QDateTime's {to,from}SecsSinceEpoch instead of {to,from}Time_t
The latter was deprecated in Qt 5.8 and removed in Qt 6.
* Don't use QFuture<>'s operator==
It has been removed in Qt 6. Since the original issue this code was
solving was caused by future reuse, just don't reuse futures and create
new finished ones when necessary.
* Use std::vector<> instead of QVector<>
The latter has been changed to a typedef for QList<>, which might not be
what one wants, and which also changed behavior a bit leading to
compilation errors.
* Don't use + for flags, cast to int explicitly
Operator+ for enum values has been deleted in Qt 6, so using operator|
instead. Then, there's no conversion from QFlags<> to QVariant, so need
to cast to int.
* Support Qt 6 in CMake and for MSI packaging
* Remove extra (empty) CMake variable use when constructing Qt target names
* Simplify logic in tr_qt_add_translation CMake helper
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-11-03 21:20:11 +00:00
|
|
|
find_package(Qt NAMES ${Qt_NAMES} ${QT_MINIMUM} QUIET)
|
|
|
|
if(Qt_FOUND)
|
|
|
|
if(WIN32 AND Qt_VERSION_MAJOR EQUAL 5)
|
|
|
|
list(APPEND QT_REQUIRED_MODULES WinExtras)
|
2015-12-16 20:01:03 +00:00
|
|
|
endif()
|
Qt 6 support (#2069)
* Bump minimum Qt version to 5.6
* Switch from QRegExp to QRegularExpression
While still available, QRegExp has been moved to Qt6::Core5Compat module
and is not part of Qt6::Core.
* Use qIsEffectiveTLD instead of QUrl::topLevelDomain
The latter is not part of Qt6::Core. The former is a private utility in
Qt6::Network; using it for now, until (and if) we switch to something
non-Qt-specific.
* Use QStyle::State_Horizontal state when drawing progress bars
Although available for a long time, this state either didn't apply to
progress bars before Qt 6, or was deduced based on bar size. With Qt 6,
failing to specify it results in bad rendering.
* Don't use QStringRef (and associated methods)
While still available, QStringRef has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core. Related method (e.g.
QString::midRef) have been removed in Qt 6.
* Use Qt::ItemIsAutoTristate instead of Qt::ItemIsTristate
The latter was deprecated and replaced with the former in Qt 5.6.
* Don't use QApplication::globalStrut
This property has been deprecated in Qt 5.15 and removed in Qt 6.
* Use QImage::fromHICON instead of QtWin::fromHICON
WinExtras module (providind the latter helper) has been removed in Qt 6.
* Use QStringDecoder instead of QTextCodec
While still available, QTextCodec has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core.
* Don't forward-declare QStringList
Instead of being a standalone class, its definition has changed to
QList<QString> template specialization in Qt 6.
* Use explicit (since Qt 6) QFileInfo constructor
* Use QDateTime's {to,from}SecsSinceEpoch instead of {to,from}Time_t
The latter was deprecated in Qt 5.8 and removed in Qt 6.
* Don't use QFuture<>'s operator==
It has been removed in Qt 6. Since the original issue this code was
solving was caused by future reuse, just don't reuse futures and create
new finished ones when necessary.
* Use std::vector<> instead of QVector<>
The latter has been changed to a typedef for QList<>, which might not be
what one wants, and which also changed behavior a bit leading to
compilation errors.
* Don't use + for flags, cast to int explicitly
Operator+ for enum values has been deleted in Qt 6, so using operator|
instead. Then, there's no conversion from QFlags<> to QVariant, so need
to cast to int.
* Support Qt 6 in CMake and for MSI packaging
* Remove extra (empty) CMake variable use when constructing Qt target names
* Simplify logic in tr_qt_add_translation CMake helper
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-11-03 21:20:11 +00:00
|
|
|
|
|
|
|
foreach(M ${QT_REQUIRED_MODULES})
|
|
|
|
find_package(Qt${Qt_VERSION_MAJOR}${M} ${QT_MINIMUM} QUIET)
|
|
|
|
if(Qt${Qt_VERSION_MAJOR}${M}_FOUND)
|
|
|
|
if(NOT M STREQUAL "LinguistTools")
|
|
|
|
list(APPEND QT_TARGETS Qt${Qt_VERSION_MAJOR}::${M})
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(QT_TARGETS)
|
|
|
|
set(MISSING_QT_MODULE "${M}")
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2017-02-11 10:24:42 +00:00
|
|
|
|
|
|
|
if(QT_TARGETS)
|
Qt 6 support (#2069)
* Bump minimum Qt version to 5.6
* Switch from QRegExp to QRegularExpression
While still available, QRegExp has been moved to Qt6::Core5Compat module
and is not part of Qt6::Core.
* Use qIsEffectiveTLD instead of QUrl::topLevelDomain
The latter is not part of Qt6::Core. The former is a private utility in
Qt6::Network; using it for now, until (and if) we switch to something
non-Qt-specific.
* Use QStyle::State_Horizontal state when drawing progress bars
Although available for a long time, this state either didn't apply to
progress bars before Qt 6, or was deduced based on bar size. With Qt 6,
failing to specify it results in bad rendering.
* Don't use QStringRef (and associated methods)
While still available, QStringRef has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core. Related method (e.g.
QString::midRef) have been removed in Qt 6.
* Use Qt::ItemIsAutoTristate instead of Qt::ItemIsTristate
The latter was deprecated and replaced with the former in Qt 5.6.
* Don't use QApplication::globalStrut
This property has been deprecated in Qt 5.15 and removed in Qt 6.
* Use QImage::fromHICON instead of QtWin::fromHICON
WinExtras module (providind the latter helper) has been removed in Qt 6.
* Use QStringDecoder instead of QTextCodec
While still available, QTextCodec has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core.
* Don't forward-declare QStringList
Instead of being a standalone class, its definition has changed to
QList<QString> template specialization in Qt 6.
* Use explicit (since Qt 6) QFileInfo constructor
* Use QDateTime's {to,from}SecsSinceEpoch instead of {to,from}Time_t
The latter was deprecated in Qt 5.8 and removed in Qt 6.
* Don't use QFuture<>'s operator==
It has been removed in Qt 6. Since the original issue this code was
solving was caused by future reuse, just don't reuse futures and create
new finished ones when necessary.
* Use std::vector<> instead of QVector<>
The latter has been changed to a typedef for QList<>, which might not be
what one wants, and which also changed behavior a bit leading to
compilation errors.
* Don't use + for flags, cast to int explicitly
Operator+ for enum values has been deleted in Qt 6, so using operator|
instead. Then, there's no conversion from QFlags<> to QVariant, so need
to cast to int.
* Support Qt 6 in CMake and for MSI packaging
* Remove extra (empty) CMake variable use when constructing Qt target names
* Simplify logic in tr_qt_add_translation CMake helper
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-11-03 21:20:11 +00:00
|
|
|
foreach(M ${QT_OPTIONAL_MODULES})
|
|
|
|
find_package(Qt${Qt_VERSION_MAJOR}${M} ${QT_MINIMUM} QUIET)
|
|
|
|
if(Qt${Qt_VERSION_MAJOR}${M}_FOUND)
|
|
|
|
list(APPEND QT_TARGETS Qt${Qt_VERSION_MAJOR}::${M})
|
2015-12-16 18:46:06 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2017-02-11 10:24:42 +00:00
|
|
|
|
Qt 6 support (#2069)
* Bump minimum Qt version to 5.6
* Switch from QRegExp to QRegularExpression
While still available, QRegExp has been moved to Qt6::Core5Compat module
and is not part of Qt6::Core.
* Use qIsEffectiveTLD instead of QUrl::topLevelDomain
The latter is not part of Qt6::Core. The former is a private utility in
Qt6::Network; using it for now, until (and if) we switch to something
non-Qt-specific.
* Use QStyle::State_Horizontal state when drawing progress bars
Although available for a long time, this state either didn't apply to
progress bars before Qt 6, or was deduced based on bar size. With Qt 6,
failing to specify it results in bad rendering.
* Don't use QStringRef (and associated methods)
While still available, QStringRef has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core. Related method (e.g.
QString::midRef) have been removed in Qt 6.
* Use Qt::ItemIsAutoTristate instead of Qt::ItemIsTristate
The latter was deprecated and replaced with the former in Qt 5.6.
* Don't use QApplication::globalStrut
This property has been deprecated in Qt 5.15 and removed in Qt 6.
* Use QImage::fromHICON instead of QtWin::fromHICON
WinExtras module (providind the latter helper) has been removed in Qt 6.
* Use QStringDecoder instead of QTextCodec
While still available, QTextCodec has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core.
* Don't forward-declare QStringList
Instead of being a standalone class, its definition has changed to
QList<QString> template specialization in Qt 6.
* Use explicit (since Qt 6) QFileInfo constructor
* Use QDateTime's {to,from}SecsSinceEpoch instead of {to,from}Time_t
The latter was deprecated in Qt 5.8 and removed in Qt 6.
* Don't use QFuture<>'s operator==
It has been removed in Qt 6. Since the original issue this code was
solving was caused by future reuse, just don't reuse futures and create
new finished ones when necessary.
* Use std::vector<> instead of QVector<>
The latter has been changed to a typedef for QList<>, which might not be
what one wants, and which also changed behavior a bit leading to
compilation errors.
* Don't use + for flags, cast to int explicitly
Operator+ for enum values has been deleted in Qt 6, so using operator|
instead. Then, there's no conversion from QFlags<> to QVariant, so need
to cast to int.
* Support Qt 6 in CMake and for MSI packaging
* Remove extra (empty) CMake variable use when constructing Qt target names
* Simplify logic in tr_qt_add_translation CMake helper
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-11-03 21:20:11 +00:00
|
|
|
if(Qt${Qt_VERSION_MAJOR}AxContainer_FOUND AND Qt${Qt_VERSION_MAJOR}AxServer_FOUND)
|
2017-02-11 10:24:42 +00:00
|
|
|
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()
|
|
|
|
|
Qt 6 support (#2069)
* Bump minimum Qt version to 5.6
* Switch from QRegExp to QRegularExpression
While still available, QRegExp has been moved to Qt6::Core5Compat module
and is not part of Qt6::Core.
* Use qIsEffectiveTLD instead of QUrl::topLevelDomain
The latter is not part of Qt6::Core. The former is a private utility in
Qt6::Network; using it for now, until (and if) we switch to something
non-Qt-specific.
* Use QStyle::State_Horizontal state when drawing progress bars
Although available for a long time, this state either didn't apply to
progress bars before Qt 6, or was deduced based on bar size. With Qt 6,
failing to specify it results in bad rendering.
* Don't use QStringRef (and associated methods)
While still available, QStringRef has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core. Related method (e.g.
QString::midRef) have been removed in Qt 6.
* Use Qt::ItemIsAutoTristate instead of Qt::ItemIsTristate
The latter was deprecated and replaced with the former in Qt 5.6.
* Don't use QApplication::globalStrut
This property has been deprecated in Qt 5.15 and removed in Qt 6.
* Use QImage::fromHICON instead of QtWin::fromHICON
WinExtras module (providind the latter helper) has been removed in Qt 6.
* Use QStringDecoder instead of QTextCodec
While still available, QTextCodec has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core.
* Don't forward-declare QStringList
Instead of being a standalone class, its definition has changed to
QList<QString> template specialization in Qt 6.
* Use explicit (since Qt 6) QFileInfo constructor
* Use QDateTime's {to,from}SecsSinceEpoch instead of {to,from}Time_t
The latter was deprecated in Qt 5.8 and removed in Qt 6.
* Don't use QFuture<>'s operator==
It has been removed in Qt 6. Since the original issue this code was
solving was caused by future reuse, just don't reuse futures and create
new finished ones when necessary.
* Use std::vector<> instead of QVector<>
The latter has been changed to a typedef for QList<>, which might not be
what one wants, and which also changed behavior a bit leading to
compilation errors.
* Don't use + for flags, cast to int explicitly
Operator+ for enum values has been deleted in Qt 6, so using operator|
instead. Then, there's no conversion from QFlags<> to QVariant, so need
to cast to int.
* Support Qt 6 in CMake and for MSI packaging
* Remove extra (empty) CMake variable use when constructing Qt target names
* Simplify logic in tr_qt_add_translation CMake helper
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-11-03 21:20:11 +00:00
|
|
|
if(Qt${Qt_VERSION_MAJOR}DBus_FOUND)
|
2017-02-11 10:24:42 +00:00
|
|
|
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)
|
Qt 6 support (#2069)
* Bump minimum Qt version to 5.6
* Switch from QRegExp to QRegularExpression
While still available, QRegExp has been moved to Qt6::Core5Compat module
and is not part of Qt6::Core.
* Use qIsEffectiveTLD instead of QUrl::topLevelDomain
The latter is not part of Qt6::Core. The former is a private utility in
Qt6::Network; using it for now, until (and if) we switch to something
non-Qt-specific.
* Use QStyle::State_Horizontal state when drawing progress bars
Although available for a long time, this state either didn't apply to
progress bars before Qt 6, or was deduced based on bar size. With Qt 6,
failing to specify it results in bad rendering.
* Don't use QStringRef (and associated methods)
While still available, QStringRef has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core. Related method (e.g.
QString::midRef) have been removed in Qt 6.
* Use Qt::ItemIsAutoTristate instead of Qt::ItemIsTristate
The latter was deprecated and replaced with the former in Qt 5.6.
* Don't use QApplication::globalStrut
This property has been deprecated in Qt 5.15 and removed in Qt 6.
* Use QImage::fromHICON instead of QtWin::fromHICON
WinExtras module (providind the latter helper) has been removed in Qt 6.
* Use QStringDecoder instead of QTextCodec
While still available, QTextCodec has been moved to Qt6::Core5Compat
module and is not part of Qt6::Core.
* Don't forward-declare QStringList
Instead of being a standalone class, its definition has changed to
QList<QString> template specialization in Qt 6.
* Use explicit (since Qt 6) QFileInfo constructor
* Use QDateTime's {to,from}SecsSinceEpoch instead of {to,from}Time_t
The latter was deprecated in Qt 5.8 and removed in Qt 6.
* Don't use QFuture<>'s operator==
It has been removed in Qt 6. Since the original issue this code was
solving was caused by future reuse, just don't reuse futures and create
new finished ones when necessary.
* Use std::vector<> instead of QVector<>
The latter has been changed to a typedef for QList<>, which might not be
what one wants, and which also changed behavior a bit leading to
compilation errors.
* Don't use + for flags, cast to int explicitly
Operator+ for enum values has been deleted in Qt 6, so using operator|
instead. Then, there's no conversion from QFlags<> to QVariant, so need
to cast to int.
* Support Qt 6 in CMake and for MSI packaging
* Remove extra (empty) CMake variable use when constructing Qt target names
* Simplify logic in tr_qt_add_translation CMake helper
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-11-03 21:20:11 +00:00
|
|
|
message(FATAL_ERROR "Unable to find required Qt libraries (Qt${Qt_VERSION_MAJOR}${MISSING_QT_MODULE})")
|
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()
|
|
|
|
|
2023-01-02 16:23:51 +00:00
|
|
|
if(QT_FOUND)
|
|
|
|
add_library(transmission::qt_impl INTERFACE IMPORTED)
|
|
|
|
|
|
|
|
target_link_libraries(transmission::qt_impl
|
|
|
|
INTERFACE
|
|
|
|
${QT_TARGETS})
|
|
|
|
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()
|
|
|
|
|
2023-01-15 15:55:16 +00:00
|
|
|
if(WIN32 AND NOT MINGW)
|
|
|
|
set(DEFLATE_LIB_NAME deflatestatic)
|
|
|
|
else()
|
|
|
|
set(DEFLATE_LIB_NAME deflate)
|
|
|
|
endif()
|
|
|
|
tr_add_external_auto_library(DEFLATE libdeflate ${DEFLATE_LIB_NAME}
|
|
|
|
TARGET deflate::deflate
|
|
|
|
CMAKE_ARGS
|
|
|
|
-DLIBDEFLATE_BUILD_SHARED_LIB=OFF
|
|
|
|
-DLIBDEFLATE_BUILD_GZIP=OFF)
|
2022-01-17 16:20:12 +00:00
|
|
|
|
2021-10-25 08:14:04 +00:00
|
|
|
tr_add_external_auto_library(EVENT2 libevent event
|
2023-01-02 16:23:51 +00:00
|
|
|
TARGET libevent::event
|
2021-10-25 08:14:04 +00:00
|
|
|
CMAKE_ARGS
|
|
|
|
-DEVENT__DISABLE_OPENSSL:BOOL=ON
|
|
|
|
-DEVENT__DISABLE_BENCHMARK:BOOL=ON
|
|
|
|
-DEVENT__DISABLE_TESTS:BOOL=ON
|
|
|
|
-DEVENT__DISABLE_REGRESS:BOOL=ON
|
|
|
|
-DEVENT__DISABLE_SAMPLES:BOOL=ON
|
|
|
|
-DEVENT__LIBRARY_TYPE:STRING=STATIC)
|
2014-12-01 19:55:22 +00:00
|
|
|
|
2023-01-02 16:23:51 +00:00
|
|
|
tr_add_external_auto_library(NATPMP libnatpmp natpmp
|
|
|
|
TARGET natpmp::natpmp)
|
2014-12-01 19:55:22 +00:00
|
|
|
if(NOT USE_SYSTEM_NATPMP)
|
2023-01-02 16:23:51 +00:00
|
|
|
target_compile_definitions(natpmp::natpmp
|
|
|
|
INTERFACE
|
|
|
|
NATPMP_STATICLIB)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
2017-01-01 18:40:11 +00:00
|
|
|
tr_add_external_auto_library(MINIUPNPC miniupnpc miniupnpc
|
2023-01-02 16:23:51 +00:00
|
|
|
TARGET miniupnpc::libminiupnpc
|
2014-12-01 19:55:22 +00:00
|
|
|
CMAKE_ARGS
|
|
|
|
-DUPNPC_BUILD_STATIC=ON
|
|
|
|
-DUPNPC_BUILD_SHARED=OFF
|
|
|
|
-DUPNPC_BUILD_TESTS=OFF)
|
|
|
|
if(NOT USE_SYSTEM_MINIUPNPC)
|
2023-01-02 16:23:51 +00:00
|
|
|
target_compile_definitions(miniupnpc::libminiupnpc
|
|
|
|
INTERFACE
|
|
|
|
MINIUPNP_STATICLIB)
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
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()
|
|
|
|
|
2023-01-02 16:23:51 +00:00
|
|
|
target_compile_definitions(miniupnpc::libminiupnpc
|
|
|
|
INTERFACE
|
|
|
|
SYSTEM_MINIUPNP
|
|
|
|
$<$<VERSION_LESS:${MINIUPNPC_VERSION},1.7>:MINIUPNPC_API_VERSION=${MINIUPNPC_API_VERSION}>) # API version macro was only added in 1.7
|
|
|
|
|
2023-10-30 17:44:34 +00:00
|
|
|
add_subdirectory(${TR_THIRD_PARTY_SOURCE_DIR}/wildmat)
|
2022-12-18 19:19:07 +00:00
|
|
|
|
2023-01-02 16:23:51 +00:00
|
|
|
tr_add_external_auto_library(DHT dht dht
|
|
|
|
TARGET dht::dht)
|
2014-12-01 19:55:22 +00:00
|
|
|
|
2023-01-02 16:23:51 +00:00
|
|
|
tr_add_external_auto_library(PSL libpsl psl
|
|
|
|
TARGET psl::psl)
|
2022-02-12 17:30:27 +00:00
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
if(ENABLE_UTP)
|
2022-07-08 15:13:22 +00:00
|
|
|
tr_add_external_auto_library(UTP libutp utp
|
2023-02-09 19:12:25 +00:00
|
|
|
SUBPROJECT
|
2023-02-11 00:08:55 +00:00
|
|
|
TARGET libutp::libutp
|
|
|
|
CMAKE_ARGS
|
|
|
|
-DLIBUTP_SHARED:BOOL=OFF)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
2023-01-02 16:23:51 +00:00
|
|
|
tr_add_external_auto_library(B64 libb64 b64
|
2023-02-09 19:12:25 +00:00
|
|
|
SUBPROJECT
|
2023-02-11 00:08:55 +00:00
|
|
|
TARGET libb64::libb64
|
|
|
|
CMAKE_ARGS
|
|
|
|
-DLIBB64_SHARED:BOOL=OFF)
|
2015-01-01 21:16:36 +00:00
|
|
|
|
2023-10-30 17:44:34 +00:00
|
|
|
set(TR_WEB_ASSETS ${PROJECT_SOURCE_DIR}/web/public_html)
|
2023-02-08 23:47:07 +00:00
|
|
|
if(NOT ${REBUILD_WEB} STREQUAL "OFF")
|
2023-01-26 04:17:24 +00:00
|
|
|
find_program(NPM npm)
|
|
|
|
if ("${NPM}" STREQUAL "NPM-NOTFOUND")
|
2023-02-08 23:47:07 +00:00
|
|
|
if ("${REBUILD_WEB}" STREQUAL "ON")
|
2023-01-26 04:17:24 +00:00
|
|
|
message(FATAL_ERROR "Could NOT find NPM, minimum required is \"${NPM_MINIMUM}\"")
|
|
|
|
else() # AUTO
|
2023-02-08 23:47:07 +00:00
|
|
|
set(REBUILD_WEB OFF)
|
2023-01-26 04:17:24 +00:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
execute_process(COMMAND "${NPM}" --version
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
OUTPUT_VARIABLE NPM_VERSION_STRING)
|
|
|
|
if ("${NPM_VERSION_STRING}" VERSION_GREATER_EQUAL "${NPM_MINIMUM}")
|
|
|
|
message(STATUS "Found NPM: ${NPM} (found suitable version \"${NPM_VERSION_STRING}\", minimum required is \"${NPM_MINIMUM}\")")
|
2023-02-08 23:47:07 +00:00
|
|
|
set(REBUILD_WEB ON)
|
|
|
|
elseif ("${REBUILD_WEB}" STREQUAL "ON")
|
2023-01-26 04:17:24 +00:00
|
|
|
message(FATAL_ERROR "Found NPM: ${NPM} Found unsuitable version \"${NPM_VERSION_STRING}\", but required is at least \"${NPM_MINIMUM}\"")
|
|
|
|
else() # AUTO
|
|
|
|
message(STATUS "Found NPM: ${NPM} Found unsuitable version \"${NPM_VERSION_STRING}\", but required is at least \"${NPM_MINIMUM}\"")
|
2023-02-08 23:47:07 +00:00
|
|
|
set(REBUILD_WEB OFF)
|
2023-01-26 04:17:24 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2023-02-08 23:47:07 +00:00
|
|
|
if(REBUILD_WEB)
|
|
|
|
add_subdirectory(web)
|
|
|
|
endif()
|
2023-01-26 04:17:24 +00:00
|
|
|
endif()
|
|
|
|
|
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()
|
|
|
|
|
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()
|
|
|
|
|
2023-01-01 19:49:48 +00:00
|
|
|
unset(CMAKE_FOLDER)
|
|
|
|
|
2020-08-11 18:11:55 +00:00
|
|
|
### Compiler Warnings
|
|
|
|
|
|
|
|
set(C_WARNING_FLAGS)
|
|
|
|
set(CXX_WARNING_FLAGS)
|
|
|
|
|
|
|
|
include(CheckCCompilerFlag)
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
|
2020-08-18 07:54:25 +00:00
|
|
|
if(MSVC)
|
2023-01-01 19:49:48 +00:00
|
|
|
set(WARNING_CANDIDATES /W4)
|
2020-08-11 18:11:55 +00:00
|
|
|
|
2020-08-18 07:54:25 +00:00
|
|
|
foreach(FLAG ${WARNING_CANDIDATES})
|
|
|
|
list(APPEND C_WARNING_FLAGS ${FLAG})
|
|
|
|
list(APPEND CXX_WARNING_FLAGS ${FLAG})
|
|
|
|
endforeach()
|
|
|
|
else()
|
|
|
|
set(WARNING_CANDIDATES
|
|
|
|
-W
|
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wcast-align
|
|
|
|
-Wduplicated-cond
|
|
|
|
-Wexit-time-destructors
|
|
|
|
-Wextra-semi
|
|
|
|
-Wextra-semi-stmt
|
|
|
|
-Wextra-tokens
|
|
|
|
-Wfloat-equal
|
|
|
|
-Wgnu
|
|
|
|
-Winit-self
|
|
|
|
-Wint-in-bool-context
|
|
|
|
-Wlogical-op
|
|
|
|
-Wmissing-format-attribute
|
|
|
|
-Wnull-dereference
|
|
|
|
-Wpointer-arith
|
|
|
|
-Wredundant-decls
|
|
|
|
-Wredundant-move
|
|
|
|
-Wreorder-ctor
|
|
|
|
-Wrestrict
|
|
|
|
-Wreturn-std-move
|
|
|
|
-Wself-assign
|
|
|
|
-Wself-move
|
|
|
|
-Wsemicolon-before-method-body
|
|
|
|
-Wsentinel
|
|
|
|
-Wshadow
|
|
|
|
-Wsign-compare
|
|
|
|
-Wsometimes-uninitialized
|
|
|
|
-Wstring-conversion
|
|
|
|
-Wsuggest-destructor-override
|
|
|
|
-Wsuggest-override
|
|
|
|
-Wuninitialized
|
|
|
|
-Wunreachable-code
|
|
|
|
-Wunused
|
|
|
|
-Wunused-const-variable
|
|
|
|
-Wunused-parameter
|
|
|
|
-Wunused-result
|
|
|
|
-Wwrite-strings)
|
|
|
|
|
|
|
|
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 WARNING_CANDIDATES -Wno-format)
|
|
|
|
else()
|
|
|
|
list(APPEND WARNING_CANDIDATES -Wformat-security)
|
2020-08-18 07:37:39 +00:00
|
|
|
endif()
|
|
|
|
|
2020-08-18 07:54:25 +00:00
|
|
|
set(CMAKE_REQUIRED_FLAGS)
|
2020-08-11 18:11:55 +00:00
|
|
|
|
2020-08-18 07:54:25 +00:00
|
|
|
foreach(FLAG -Werror /WX)
|
|
|
|
tr_make_id("${FLAG}" FLAG_ID)
|
|
|
|
set(CACHE_ID "${CMAKE_C_COMPILER_ID}_C_HAS${FLAG_ID}")
|
|
|
|
string(TOLOWER "${CACHE_ID}" CACHE_ID)
|
|
|
|
check_c_compiler_flag(${FLAG} ${CACHE_ID})
|
2023-01-01 19:49:48 +00:00
|
|
|
if(${CACHE_ID})
|
2020-08-18 07:54:25 +00:00
|
|
|
# Make sure the next loop only adds flags that are relevant for a particular language
|
|
|
|
set(CMAKE_REQUIRED_FLAGS ${FLAG})
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2014-12-11 05:11:02 +00:00
|
|
|
|
2020-08-18 07:54:25 +00:00
|
|
|
foreach(FLAG ${WARNING_CANDIDATES})
|
|
|
|
tr_make_id("${FLAG}" FLAG_ID)
|
2016-01-09 18:24:43 +00:00
|
|
|
|
2020-08-18 07:54:25 +00:00
|
|
|
# if available, add to C warnings
|
|
|
|
set(CACHE_ID "${CMAKE_C_COMPILER_ID}_C_HAS${FLAG_ID}")
|
|
|
|
string(TOLOWER "${CACHE_ID}" CACHE_ID)
|
|
|
|
check_c_compiler_flag(${FLAG} ${CACHE_ID})
|
2023-01-01 19:49:48 +00:00
|
|
|
if(${CACHE_ID})
|
2020-08-18 07:54:25 +00:00
|
|
|
list(APPEND C_WARNING_FLAGS ${FLAG})
|
|
|
|
endif()
|
2020-08-11 18:11:55 +00:00
|
|
|
|
2020-08-18 07:54:25 +00:00
|
|
|
# if available, add to CXX warnings
|
|
|
|
set(CACHE_ID "${CMAKE_CXX_COMPILER_ID}_CXX_HAS${FLAG_ID}")
|
|
|
|
string(TOLOWER "${CACHE_ID}" CACHE_ID)
|
|
|
|
check_cxx_compiler_flag(${FLAG} ${CACHE_ID})
|
2023-01-01 19:49:48 +00:00
|
|
|
if(${CACHE_ID})
|
2020-08-18 07:54:25 +00:00
|
|
|
list(APPEND CXX_WARNING_FLAGS ${FLAG})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
unset(CACHE_ID)
|
|
|
|
unset(FLAG_ID)
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
unset(CMAKE_REQUIRED_FLAGS)
|
|
|
|
endif()
|
2020-08-11 18:11:55 +00:00
|
|
|
|
2022-12-18 01:02:03 +00:00
|
|
|
string(REPLACE ";" "$<SEMICOLON>" C_WARNING_FLAGS_GENEX "${C_WARNING_FLAGS}")
|
|
|
|
string(REPLACE ";" "$<SEMICOLON>" CXX_WARNING_FLAGS_GENEX "${CXX_WARNING_FLAGS}")
|
|
|
|
add_compile_options(
|
|
|
|
$<$<COMPILE_LANGUAGE:C>:${C_WARNING_FLAGS_GENEX}>
|
|
|
|
$<$<COMPILE_LANGUAGE:CXX>:${CXX_WARNING_FLAGS_GENEX}>)
|
|
|
|
|
2020-08-11 18:11:55 +00:00
|
|
|
###
|
2014-12-01 19:55:22 +00:00
|
|
|
|
2015-03-10 22:31:09 +00:00
|
|
|
include(LargeFileSupport)
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
check_library_exists(m sqrt "" HAVE_LIBM)
|
|
|
|
if(HAVE_LIBM)
|
|
|
|
set(LIBM_LIBRARY m)
|
|
|
|
endif()
|
|
|
|
|
2023-02-13 18:04:14 +00:00
|
|
|
check_library_exists(quota quotacursor_skipidtype "" HAVE_LIBQUOTA)
|
|
|
|
if(HAVE_LIBQUOTA)
|
|
|
|
set(LIBQUOTA_LIBRARY quota)
|
|
|
|
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()
|
|
|
|
|
2021-09-12 19:36:51 +00:00
|
|
|
if(RUN_CLANG_TIDY STREQUAL "AUTO")
|
2023-01-01 19:49:48 +00:00
|
|
|
if(DEFINED ENV{LGTM_SRC} OR DEFINED ENV{APPVEYOR}) # skip clang-tidy on LGTM/appveyor
|
2021-09-12 19:36:51 +00:00
|
|
|
set(RUN_CLANG_TIDY OFF)
|
|
|
|
else()
|
|
|
|
set(RUN_CLANG_TIDY ON)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(RUN_CLANG_TIDY)
|
2020-08-11 18:11:55 +00:00
|
|
|
message(STATUS "Looking for clang-tidy")
|
2023-01-05 04:16:22 +00:00
|
|
|
find_program(CLANG_TIDY clang-tidy)
|
2023-01-01 19:49:48 +00:00
|
|
|
if(CLANG_TIDY STREQUAL "CLANG_TIDY-NOTFOUND")
|
2020-08-11 18:11:55 +00:00
|
|
|
message(STATUS "Looking for clang-tidy - not found")
|
|
|
|
else()
|
|
|
|
message(STATUS "Looking for clang-tidy - found")
|
|
|
|
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY}")
|
|
|
|
endif()
|
2020-05-20 01:32:51 +00:00
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
if(ENABLE_TESTS)
|
|
|
|
enable_testing()
|
2020-08-11 18:11:55 +00:00
|
|
|
add_subdirectory(tests)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
2016-09-10 17:08:58 +00:00
|
|
|
function(tr_install_web DST_DIR)
|
2023-02-22 12:25:50 +00:00
|
|
|
if(INSTALL_WEB)
|
|
|
|
install(
|
|
|
|
DIRECTORY ${TR_WEB_ASSETS}
|
|
|
|
DESTINATION ${DST_DIR})
|
|
|
|
endif()
|
2016-09-10 17:08:58 +00:00
|
|
|
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()
|
|
|
|
|
2023-02-08 23:47:07 +00:00
|
|
|
foreach(P cli daemon gtk mac qt utils)
|
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()
|
|
|
|
|
2023-02-22 12:25:50 +00:00
|
|
|
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)
|
2023-01-01 19:49:48 +00:00
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
AUTHORS
|
|
|
|
COPYING
|
|
|
|
README.md
|
|
|
|
docs/rpc-spec.md
|
|
|
|
extras/send-email-when-torrent-done.sh
|
|
|
|
DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
|
|
|
install(
|
|
|
|
DIRECTORY news
|
|
|
|
DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
2023-02-22 12:25:50 +00:00
|
|
|
if(MSVC AND ENABLE_DAEMON AND ENABLE_QT AND ENABLE_UTILS AND WITH_CRYPTO STREQUAL "openssl" AND INSTALL_WEB)
|
2016-04-02 18:01:01 +00:00
|
|
|
add_subdirectory(dist/msi)
|
|
|
|
endif()
|
|
|
|
|
2020-10-13 00:15:19 +00:00
|
|
|
set(CPACK_SOURCE_GENERATOR TXZ)
|
2022-10-05 21:53:10 +00:00
|
|
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${TR_NAME}-${TR_SEMVER}")
|
|
|
|
if(NOT TR_STABLE_RELEASE AND NOT "${TR_VCS_REVISION}" STREQUAL "")
|
|
|
|
# https://semver.org/#spec-item-11
|
|
|
|
# Build metadata MAY be denoted by appending a plus sign and a series of dot
|
|
|
|
# separated identifiers immediately following the patch or pre-release version.
|
|
|
|
# Identifiers MUST comprise only ASCII alphanumerics and hyphens [0-9A-Za-z-].
|
|
|
|
# Identifiers MUST NOT be empty.
|
|
|
|
string(APPEND CPACK_SOURCE_PACKAGE_FILE_NAME "+r${TR_VCS_REVISION}")
|
2020-10-13 00:15:19 +00:00
|
|
|
endif()
|
2020-10-24 01:04:25 +00:00
|
|
|
list(APPEND CPACK_SOURCE_IGNORE_FILES
|
2023-10-30 17:44:34 +00:00
|
|
|
"${PROJECT_BINARY_DIR}"
|
2020-10-24 01:04:25 +00:00
|
|
|
"[.]git"
|
2023-01-01 19:49:48 +00:00
|
|
|
"node_modules")
|
2014-12-01 19:55:22 +00:00
|
|
|
|
2020-09-14 02:41:32 +00:00
|
|
|
## Code Formatting
|
|
|
|
|
|
|
|
if(GIT_FOUND)
|
2023-01-01 19:49:48 +00:00
|
|
|
execute_process(
|
|
|
|
COMMAND "${GIT_EXECUTABLE}" rev-parse --show-toplevel
|
2023-10-30 17:44:34 +00:00
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
2020-09-14 02:41:32 +00:00
|
|
|
OUTPUT_VARIABLE TR_GIT_ROOT
|
2023-01-01 19:49:48 +00:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2020-10-13 00:15:19 +00:00
|
|
|
if(TR_GIT_ROOT AND IS_DIRECTORY "${TR_GIT_ROOT}/.git")
|
2023-10-30 17:44:34 +00:00
|
|
|
configure_file("${PROJECT_SOURCE_DIR}/extras/pre-commit" "${TR_GIT_ROOT}/.git/hooks/pre-commit" COPYONLY)
|
2020-09-14 02:41:32 +00:00
|
|
|
add_custom_target(check-format
|
2023-10-30 17:44:34 +00:00
|
|
|
COMMAND "${PROJECT_SOURCE_DIR}/code_style.sh" --check
|
|
|
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
|
2020-09-14 02:41:32 +00:00
|
|
|
add_custom_target(format
|
2023-10-30 17:44:34 +00:00
|
|
|
COMMAND "${PROJECT_SOURCE_DIR}/code_style.sh"
|
|
|
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
|
2023-01-01 19:49:48 +00:00
|
|
|
set_property(
|
|
|
|
TARGET check-format format
|
|
|
|
PROPERTY FOLDER "utility")
|
2020-10-13 00:15:19 +00:00
|
|
|
endif()
|
2020-09-14 02:41:32 +00:00
|
|
|
unset(TR_GIT_ROOT)
|
2020-10-13 00:15:19 +00:00
|
|
|
endif()
|
2020-09-14 02:41:32 +00:00
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
include(CPack)
|