1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-21 23:32:35 +00:00

Modernize CMake code (ongoing refactoring) (#4515)

* Use imported CMake target for CURL

* Use imported CMake target for fmtlib

* Use imported CMake target for WideInteger

* Use imported CMake target for FastFloat

* Use imported CMake target for UtfCpp

* Use imported CMake target for Threads

* Use imported CMake target for Iconv

* Use imported CMake target for crypto backend

* Use imported CMake target for GTK

* Use imported CMake target for Qt

* Use imported CMake target for deflate

* Use imported CMake target for libevent

* Use imported CMake target for natpmp

* Use imported CMake target for miniupnpc

* Use imported CMake target for dht

* Use imported CMake target for psl

* Use imported CMake target for libutp

* Use imported CMake target for libb64

* Use include directories from libtransmission target
This commit is contained in:
Mike Gelfand 2023-01-02 08:23:51 -08:00 committed by GitHub
parent 806491232b
commit 57e6b06921
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
68 changed files with 372 additions and 412 deletions

View file

@ -193,10 +193,6 @@ endif()
set(CMAKE_FOLDER "third-party")
find_package(Fmt)
add_definitions(
-DFMT_HEADER_ONLY
-DFMT_EXCEPTIONS=0)
find_package(WideInteger)
find_package(FastFloat)
find_package(UtfCpp)
@ -204,15 +200,16 @@ find_package(Threads)
find_package(PkgConfig QUIET)
find_package(CURL ${CURL_MINIMUM} REQUIRED)
if(TARGET CURL::libcurl)
set(CURL_LIBRARIES CURL::libcurl)
set(CURL_INCLUDE_DIRS)
if(NOT TARGET CURL::libcurl)
add_library(CURL::libcurl INTERFACE IMPORTED)
target_link_libraries(CURL::libcurl INTERFACE ${CURL_LIBRARIES})
target_include_directories(CURL::libcurl INTERFACE ${CURL_INCLUDE_DIRS})
endif()
if(NOT WIN32)
find_package(ICONV)
find_package(Iconv)
else()
set(ICONV_FOUND OFF)
set(Iconv_FOUND OFF)
endif()
set(CRYPTO_PKG "")
@ -259,6 +256,7 @@ if(WITH_CRYPTO STREQUAL "AUTO" OR WITH_CRYPTO STREQUAL "mbedtls")
set(CRYPTO_LIBRARIES ${MBEDTLS_LIBRARIES})
endif()
endif()
# We should have found the library by now
if(CRYPTO_PKG STREQUAL "")
if(WITH_CRYPTO STREQUAL "AUTO")
@ -266,6 +264,16 @@ if(CRYPTO_PKG STREQUAL "")
else()
message(FATAL_ERROR "Requested crypto library '${WITH_CRYPTO}' is not supported.")
endif()
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})
endif()
if(ENABLE_GTK)
@ -306,6 +314,26 @@ else()
set(WITH_APPINDICATOR OFF)
endif()
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()
if(ENABLE_QT)
tr_get_required_flag(ENABLE_QT QT_IS_REQUIRED)
@ -388,6 +416,14 @@ if(ENABLE_QT)
tr_fixup_auto_option(ENABLE_QT QT_FOUND QT_IS_REQUIRED)
endif()
if(QT_FOUND)
add_library(transmission::qt_impl INTERFACE IMPORTED)
target_link_libraries(transmission::qt_impl
INTERFACE
${QT_TARGETS})
endif()
if(ENABLE_MAC)
tr_get_required_flag(ENABLE_MAC MAC_IS_REQUIRED)
@ -405,12 +441,14 @@ endif()
set(THIRD_PARTY_DIR ${CMAKE_SOURCE_DIR}/third-party)
tr_add_external_auto_library(DEFLATE libdeflate deflate)
tr_add_external_auto_library(DEFLATE libdeflate deflate
TARGET deflate::deflate)
if(NOT USE_SYSTEM_DEFLATE)
set(DEFLATE_VERSION ${DEFLATE_MINIMUM})
endif()
tr_add_external_auto_library(EVENT2 libevent event
TARGET libevent::event
CMAKE_ARGS
-DEVENT__DISABLE_OPENSSL:BOOL=ON
-DEVENT__DISABLE_BENCHMARK:BOOL=ON
@ -419,49 +457,51 @@ tr_add_external_auto_library(EVENT2 libevent event
-DEVENT__DISABLE_SAMPLES:BOOL=ON
-DEVENT__LIBRARY_TYPE:STRING=STATIC)
tr_add_external_auto_library(NATPMP libnatpmp natpmp)
tr_add_external_auto_library(NATPMP libnatpmp natpmp
TARGET natpmp::natpmp)
if(NOT USE_SYSTEM_NATPMP)
set(NATPMP_DEFINITIONS NATPMP_STATICLIB)
target_compile_definitions(natpmp::natpmp
INTERFACE
NATPMP_STATICLIB)
endif()
tr_add_external_auto_library(MINIUPNPC miniupnpc miniupnpc
TARGET miniupnpc::libminiupnpc
CMAKE_ARGS
-DUPNPC_BUILD_STATIC=ON
-DUPNPC_BUILD_SHARED=OFF
-DUPNPC_BUILD_TESTS=OFF)
set(MINIUPNPC_DEFINITIONS SYSTEM_MINIUPNP)
if(NOT USE_SYSTEM_MINIUPNPC)
list(APPEND MINIUPNPC_DEFINITIONS MINIUPNP_STATICLIB)
target_compile_definitions(miniupnpc::libminiupnpc
INTERFACE
MINIUPNP_STATICLIB)
set(MINIUPNPC_VERSION 1.9)
set(MINIUPNPC_API_VERSION 12)
endif()
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
add_subdirectory(third-party/jsonsl)
add_subdirectory(third-party/wildmat)
tr_add_external_auto_library(DHT dht dht)
tr_add_external_auto_library(DHT dht dht
TARGET dht::dht)
tr_add_external_auto_library(PSL libpsl psl)
tr_add_external_auto_library(PSL libpsl psl
TARGET psl::psl)
if(ENABLE_UTP)
tr_add_external_auto_library(UTP libutp utp
TARGET libutp::libutp
CMAKE_ARGS -DLIBUTP_BUILD_PROGRAMS=OFF)
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()
endif()
tr_add_external_auto_library(B64 libb64 b64)
tr_add_external_auto_library(B64 libb64 b64
TARGET libb64::libb64)
if(WITH_INOTIFY)
tr_get_required_flag(WITH_INOTIFY INOTIFY_IS_REQUIRED)

View file

@ -4,18 +4,10 @@ target_sources(${TR_NAME}-cli
PRIVATE
cli.cc)
target_include_directories(${TR_NAME}-cli
PRIVATE
${CMAKE_SOURCE_DIR})
target_include_directories(${TR_NAME}-cli SYSTEM
PRIVATE
${LIBFMT_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS})
target_link_libraries(${TR_NAME}-cli
PRIVATE
${TR_NAME})
${TR_NAME}
fmt::fmt-header-only)
tr_win32_app_info(${TR_NAME}-cli
"Transmission Utility ('cli', obsolete)"

View file

@ -1 +1,5 @@
set(FAST_FLOAT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/third-party/fast_float/include)
add_library(FastFloat::fast_float INTERFACE IMPORTED)
target_include_directories(FastFloat::fast_float
INTERFACE
${CMAKE_CURRENT_LIST_DIR}/../third-party/fast_float/include)

View file

@ -1 +1,10 @@
set(LIBFMT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/third-party/fmt/include)
add_library(fmt::fmt-header-only INTERFACE IMPORTED)
target_include_directories(fmt::fmt-header-only
INTERFACE
${CMAKE_CURRENT_LIST_DIR}/../third-party/fmt/include)
target_compile_definitions(fmt::fmt-header-only
INTERFACE
FMT_EXCEPTIONS=0
FMT_HEADER_ONLY=1)

View file

@ -1,51 +0,0 @@
# Grabbed from http://public.kitware.com/Bug/view.php?id=13517 and slightly modified.
find_path(ICONV_INCLUDE_DIR
NAMES iconv.h)
find_library(ICONV_LIBRARY
NAMES
iconv
libiconv
libiconv-2
c)
set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR})
set(ICONV_LIBRARIES ${ICONV_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ICONV
REQUIRED_VARS
ICONV_LIBRARY
ICONV_INCLUDE_DIR
VERSION_VAR ICONV_VERSION)
if(ICONV_FOUND AND NOT DEFINED ICONV_SECOND_ARGUMENT_IS_CONST)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
check_cxx_source_compiles("
#include <iconv.h>
int main()
{
iconv_t conv = 0;
const char * in = 0;
size_t ilen = 0;
char * out = 0;
size_t olen = 0;
iconv(conv, &in, &ilen, &out, &olen);
return 0;
}"
ICONV_SECOND_ARGUMENT_IS_CONST
FAIL_REGEX "discards qualifiers in nested pointer types"
FAIL_REGEX "incompatible pointer type"
FAIL_REGEX "invalid conversion"
FAIL_REGEX "no matching function")
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
endif()
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARY ICONV_SECOND_ARGUMENT_IS_CONST)

View file

@ -1 +1,5 @@
set(UTFCPP_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/third-party/utfcpp/source)
add_library(utf8::cpp INTERFACE IMPORTED)
target_include_directories(utf8::cpp
INTERFACE
${CMAKE_CURRENT_LIST_DIR}/../third-party/utfcpp/source)

View file

@ -1 +1,5 @@
set(WIDE_INTEGER_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/third-party/wide-integer)
add_library(WideInteger::WideInteger INTERFACE IMPORTED)
target_include_directories(WideInteger::WideInteger
INTERFACE
${CMAKE_CURRENT_LIST_DIR}/../third-party/wide-integer)

View file

@ -129,6 +129,8 @@ function(tr_process_list_conditions VAR_PREFIX)
endfunction()
macro(tr_add_external_auto_library ID DIRNAME LIBNAME)
cmake_parse_arguments(_TAEAL_ARG "" "TARGET" "CMAKE_ARGS" ${ARGN})
if(USE_SYSTEM_${ID})
tr_get_required_flag(USE_SYSTEM_${ID} SYSTEM_${ID}_IS_REQUIRED)
find_package(${ID} ${${ID}_MINIMUM} ${SYSTEM_${ID}_IS_REQUIRED})
@ -161,7 +163,6 @@ macro(tr_add_external_auto_library ID DIRNAME LIBNAME)
ExternalProject_Add(
${${ID}_UPSTREAM_TARGET}
URL "${CMAKE_SOURCE_DIR}/third-party/${DIRNAME}"
${ARGN}
PREFIX "${${ID}_PREFIX}"
CMAKE_ARGS
-Wno-dev # We don't want to be warned over unused variables
@ -175,9 +176,29 @@ macro(tr_add_external_auto_library ID DIRNAME LIBNAME)
"-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>"
"-DCMAKE_INSTALL_LIBDIR:STRING=lib"
${${ID}_EXT_PROJ_CMAKE_ARGS}
${_TAEAL_ARG_CMAKE_ARGS}
BUILD_BYPRODUCTS "${${ID}_LIBRARY}")
set_property(TARGET ${${ID}_UPSTREAM_TARGET} PROPERTY FOLDER "third-party")
# Imported target (below) requires include directories to be present at configuration time
file(MAKE_DIRECTORY ${${ID}_INCLUDE_DIRS})
endif()
if(_TAEAL_ARG_TARGET)
add_library(${_TAEAL_ARG_TARGET} INTERFACE IMPORTED)
target_include_directories(${_TAEAL_ARG_TARGET}
INTERFACE
${${ID}_INCLUDE_DIRS})
target_link_libraries(${_TAEAL_ARG_TARGET}
INTERFACE
${${ID}_LIBRARIES})
if(${ID}_UPSTREAM_TARGET)
add_dependencies(${_TAEAL_ARG_TARGET} ${${ID}_UPSTREAM_TARGET})
endif()
endif()
endmacro()

View file

@ -26,21 +26,15 @@ tr_target_compile_definitions_for_functions(${TR_NAME}-daemon
daemon
syslog)
target_include_directories(${TR_NAME}-daemon
PRIVATE
${CMAKE_SOURCE_DIR})
target_include_directories(${TR_NAME}-daemon SYSTEM
PRIVATE
${LIBFMT_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${EVENT2_INCLUDE_DIRS}
$<$<BOOL:${WITH_SYSTEMD}>:${SYSTEMD_INCLUDE_DIRS}>)
target_link_libraries(${TR_NAME}-daemon
PRIVATE
${TR_NAME}
${EVENT2_LIBRARIES}
libevent::event
fmt::fmt-header-only
$<$<BOOL:${WITH_SYSTEMD}>:${SYSTEMD_LIBRARIES}>)
tr_win32_app_info(${TR_NAME}-daemon

View file

@ -101,10 +101,6 @@ target_sources(${TR_NAME}-gtk
source_group(Ui/GTK4
REGULAR_EXPRESSION [[ui/gtk4/.*\.ui$]])
target_link_directories(${TR_NAME}-gtk
PRIVATE
${GTK${GTK_VERSION}_LIBRARY_DIRS})
if(WITH_APPINDICATOR)
set_property(
SOURCE SystemTrayIcon.cc
@ -170,29 +166,22 @@ target_compile_definitions(${TR_NAME}-gtk
target_compile_options(${TR_NAME}-gtk
PRIVATE
${GTK${GTK_VERSION}_CFLAGS_OTHER}
$<$<BOOL:${ENABLE_WERROR}>:$<IF:$<CXX_COMPILER_ID:MSVC>,/WX,-Werror>>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-exit-time-destructors>)
target_include_directories(${TR_NAME}-gtk
PRIVATE
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(${TR_NAME}-gtk SYSTEM
PRIVATE
${LIBFMT_INCLUDE_DIRS}
${GTK${GTK_VERSION}_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${EVENT2_INCLUDE_DIRS}
$<$<BOOL:${WITH_APPINDICATOR}>:${APPINDICATOR_INCLUDE_DIRS}>)
target_link_libraries(${TR_NAME}-gtk
PRIVATE
${TR_NAME}
${GTK${GTK_VERSION}_LIBRARIES}
${CURL_LIBRARIES}
${EVENT2_LIBRARIES}
transmission::gtk_impl
fmt::fmt-header-only
$<$<BOOL:${WITH_APPINDICATOR}>:${APPINDICATOR_LIBRARIES}>)
if(MSVC)

View file

@ -207,18 +207,6 @@ tr_allow_compile_if(
file-posix.cc
subprocess-posix.cc)
foreach(UT
${EVENT2_UPSTREAM_TARGET}
${NATPMP_UPSTREAM_TARGET}
${MINIUPNPC_UPSTREAM_TARGET}
${DHT_UPSTREAM_TARGET}
${DEFLATE_UPSTREAM_TARGET}
${UTP_UPSTREAM_TARGET}
${PSL_UPSTREAM_TARGET}
${B64_UPSTREAM_TARGET})
add_dependencies(${TR_NAME} ${UT})
endforeach()
target_compile_definitions(${TR_NAME}
PRIVATE
__TRANSMISSION__
@ -231,10 +219,7 @@ target_compile_definitions(${TR_NAME}
$<$<VERSION_LESS:${MINIUPNPC_VERSION},1.7>:MINIUPNPC_API_VERSION=${MINIUPNPC_API_VERSION}> # API version macro was only added in 1.7
$<$<BOOL:${USE_SYSTEM_B64}>:USE_SYSTEM_B64>
$<$<BOOL:${HAVE_SO_REUSEPORT}>:HAVE_SO_REUSEPORT=1>
$<$<BOOL:${ICONV_FOUND}>:HAVE_ICONV>
$<$<BOOL:${ICONV_SECOND_ARGUMENT_IS_CONST}>:ICONV_SECOND_ARGUMENT_IS_CONST>
${NATPMP_DEFINITIONS}
${MINIUPNPC_DEFINITIONS}
$<$<BOOL:${Iconv_FOUND}>:HAVE_ICONV>
PUBLIC
$<$<NOT:$<BOOL:${ENABLE_NLS}>>:DISABLE_GETTEXT>)
@ -274,52 +259,38 @@ tr_target_compile_definitions_for_functions(${TR_NAME}
target_include_directories(${TR_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
INTERFACE
${CMAKE_BINARY_DIR})
target_include_directories(${TR_NAME} SYSTEM
PRIVATE
${WIDE_INTEGER_INCLUDE_DIRS}
${UTFCPP_INCLUDE_DIRS}
${DEFLATE_INCLUDE_DIRS}
${FAST_FLOAT_INCLUDE_DIRS}
${CRYPTO_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${PSL_INCLUDE_DIRS}
${NATPMP_INCLUDE_DIRS}
${MINIUPNPC_INCLUDE_DIRS}
${DHT_INCLUDE_DIRS}
${UTP_INCLUDE_DIRS}
${B64_INCLUDE_DIRS}
$<$<BOOL:${ICONV_FOUND}>:${ICONV_INCLUDE_DIRS}>
PUBLIC
${EVENT2_INCLUDE_DIRS}
${LIBFMT_INCLUDE_DIRS})
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_BINARY_DIR}/..)
target_link_libraries(${TR_NAME}
PRIVATE
${CMAKE_THREAD_LIBS_INIT}
${DEFLATE_LIBRARIES}
${CRYPTO_LIBRARIES}
${CURL_LIBRARIES}
${EVENT2_LIBRARIES}
${PSL_LIBRARIES}
${NATPMP_LIBRARIES}
${MINIUPNPC_LIBRARIES}
${DHT_LIBRARIES}
${UTP_LIBRARIES}
${B64_LIBRARIES}
Threads::Threads
deflate::deflate
transmission::crypto_impl
CURL::libcurl
FastFloat::fast_float
psl::psl
natpmp::natpmp
miniupnpc::libminiupnpc
dht::dht
libutp::libutp
libb64::libb64
${LIBINTL_LIBRARY}
${LIBM_LIBRARY}
${TR_NETWORK_LIBRARIES}
jsonsl
utf8::cpp
wildmat
$<$<BOOL:${ICONV_FOUND}>:${ICONV_LIBRARIES}>
WideInteger::WideInteger
$<$<BOOL:${ICONV_FOUND}>:Iconv::Iconv>
$<$<BOOL:${WIN32}>:crypt32>
$<$<BOOL:${WIN32}>:shlwapi>
"$<$<BOOL:${APPLE}>:-framework Foundation>")
"$<$<BOOL:${APPLE}>:-framework Foundation>"
PUBLIC
fmt::fmt-header-only
libevent::event)
if(INSTALL_LIB)
install(

View file

@ -307,6 +307,28 @@ namespace
namespace tr_strvUtf8Clean_impl
{
class SecondIconvArg
{
public:
explicit SecondIconvArg(char const* arg)
: arg_(arg)
{
}
operator char**() &&
{
return const_cast<char**>(&arg_);
}
operator char const**() &&
{
return &arg_;
}
private:
char const* arg_;
};
bool validateUtf8(std::string_view sv, char const** good_end)
{
auto const* begin = std::data(sv);
@ -359,15 +381,10 @@ std::string to_utf8(std::string_view sv)
continue;
}
#ifdef ICONV_SECOND_ARGUMENT_IS_CONST
auto const* inbuf = std::data(sv);
#else
auto* inbuf = const_cast<char*>(std::data(sv));
#endif
size_t inbytesleft = std::size(sv);
char* out = std::data(buf);
size_t outbytesleft = std::size(buf);
auto const rv = iconv(cd, &inbuf, &inbytesleft, &out, &outbytesleft);
auto const rv = iconv(cd, SecondIconvArg(std::data(sv)), &inbytesleft, &out, &outbytesleft);
iconv_close(cd);
if (rv != size_t(-1))
{

View file

@ -383,14 +383,6 @@ tr_target_xib_files(${TR_NAME}-mac
${XIB_FILES}
${BASE_XIB_FILES})
target_include_directories(${TR_NAME}-mac
PRIVATE
${CMAKE_SOURCE_DIR})
target_include_directories(${TR_NAME}-mac SYSTEM
PRIVATE
${LIBFMT_INCLUDE_DIRS})
find_library(SPARKLE_FRAMEWORK Sparkle
PATHS ${CMAKE_CURRENT_SOURCE_DIR}
NO_DEFAULT_PATHS)
@ -398,6 +390,7 @@ find_library(SPARKLE_FRAMEWORK Sparkle
target_link_libraries(${TR_NAME}-mac
PRIVATE
${TR_NAME}
fmt::fmt-header-only
vdkqueue
${SPARKLE_FRAMEWORK}
"-framework AppKit"

View file

@ -75,7 +75,6 @@ set_target_properties(
target_include_directories(${TR_NAME}-mac-ql
PRIVATE
${CMAKE_SOURCE_DIR}
..)
target_link_libraries(${TR_NAME}-mac-ql

View file

@ -202,20 +202,12 @@ endif()
target_include_directories(${TR_NAME}-qt
PRIVATE
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${TR_NAME}-qt SYSTEM
PRIVATE
${CURL_INCLUDE_DIRS}
${EVENT2_INCLUDE_DIRS})
target_link_libraries(${TR_NAME}-qt
PRIVATE
${TR_NAME}
${QT_TARGETS}
${CURL_LIBRARIES}
${EVENT2_LIBRARIES})
transmission::qt_impl)
target_compile_definitions(${TR_NAME}-qt
PRIVATE

View file

@ -11,7 +11,7 @@
#include <QCoreApplication> // Q_DECLARE_TR_FUNCTIONS
#include <QString>
#include "libtransmission/utils.h"
#include <libtransmission/utils.h>
#include "Speed.h"

View file

@ -63,27 +63,17 @@ target_compile_definitions(libtransmission-test
-DLIBTRANSMISSION_TEST_ASSETS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/assets"
__TRANSMISSION__)
target_include_directories(libtransmission-test
PRIVATE
${CMAKE_SOURCE_DIR}/libtransmission
${CMAKE_BINARY_DIR}/libtransmission)
target_include_directories(libtransmission-test SYSTEM
PRIVATE
${LIBFMT_INCLUDE_DIRS}
${WIDE_INTEGER_INCLUDE_DIRS}
${B64_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${DHT_INCLUDE_DIRS}
${EVENT2_INCLUDE_DIRS})
target_compile_options(libtransmission-test
PRIVATE $<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>:-Wno-sign-compare>) # patches welcomed
target_link_libraries(libtransmission-test
PRIVATE
${TR_NAME}
gtestall)
gtestall
dht::dht
fmt::fmt-header-only
libevent::event
WideInteger::WideInteger)
add_test(
NAME libtransmission-test

View file

@ -9,13 +9,13 @@
#include <string_view>
#include <vector>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "announce-list.h"
#include "error.h"
#include "torrent-metainfo.h"
#include "tr-strbuf.h"
#include "variant.h"
#include <libtransmission/announce-list.h>
#include <libtransmission/error.h>
#include <libtransmission/torrent-metainfo.h>
#include <libtransmission/tr-strbuf.h>
#include <libtransmission/variant.h>
#include "test-fixtures.h"

View file

@ -9,10 +9,10 @@
#define LIBTRANSMISSION_ANNOUNCER_MODULE
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "announcer-common.h"
#include "net.h"
#include <libtransmission/announcer-common.h>
#include <libtransmission/net.h>
#include "test-fixtures.h"

View file

@ -12,14 +12,14 @@
#define LIBTRANSMISSION_ANNOUNCER_MODULE
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "announcer.h"
#include "announcer-common.h"
#include "crypto-utils.h" // for tr_rand_obj()
#include "peer-mgr.h" // for tr_pex
#include "timer-ev.h"
#include "tr-buffer.h"
#include <libtransmission/announcer.h>
#include <libtransmission/announcer-common.h>
#include <libtransmission/crypto-utils.h> // for tr_rand_obj()
#include <libtransmission/peer-mgr.h> // for tr_pex
#include <libtransmission/timer-ev.h>
#include <libtransmission/tr-buffer.h>
#include "test-fixtures.h"

View file

@ -5,9 +5,9 @@
#include <fmt/format.h>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "benc.h"
#include <libtransmission/benc.h>
#include "gtest/gtest.h"

View file

@ -8,9 +8,9 @@
#include <limits>
#include <vector>
#include "transmission.h"
#include "crypto-utils.h"
#include "bitfield.h"
#include <libtransmission/transmission.h>
#include <libtransmission/crypto-utils.h>
#include <libtransmission/bitfield.h>
#include "gtest/gtest.h"

View file

@ -5,9 +5,9 @@
#include <cstdint>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "block-info.h"
#include <libtransmission/block-info.h>
#include "gtest/gtest.h"

View file

@ -6,14 +6,14 @@
#include <cstring> // strlen()
// #include <unistd.h> // sync()
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "blocklist.h"
#include "file.h"
#include "net.h"
#include "peer-socket.h"
#include "session.h" // tr_session.tr_session.addressIsBlocked()
#include "tr-strbuf.h"
#include <libtransmission/blocklist.h>
#include <libtransmission/file.h>
#include <libtransmission/net.h>
#include <libtransmission/peer-socket.h>
#include <libtransmission/session.h> // tr_session.tr_session.addressIsBlocked()
#include <libtransmission/tr-strbuf.h>
#include "test-fixtures.h"

View file

@ -3,9 +3,9 @@
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "tr-buffer.h"
#include <libtransmission/tr-buffer.h>
#include "test-fixtures.h"

View file

@ -7,10 +7,10 @@
#include <array>
#include <string_view>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "crypto-utils.h" // tr_rand_obj()
#include "clients.h"
#include <libtransmission/crypto-utils.h> // tr_rand_obj()
#include <libtransmission/clients.h>
#include "gtest/gtest.h"

View file

@ -8,11 +8,11 @@
#include <cstdint>
#include <set>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "block-info.h"
#include "crypto-utils.h" // for tr_rand_obj()
#include "completion.h"
#include <libtransmission/block-info.h>
#include <libtransmission/crypto-utils.h> // for tr_rand_obj()
#include <libtransmission/completion.h>
#include "gtest/gtest.h"

View file

@ -7,9 +7,9 @@
#include <cstring>
#include <vector>
#include "transmission.h"
#include "error.h"
#include "file.h"
#include <libtransmission/transmission.h>
#include <libtransmission/error.h>
#include <libtransmission/file.h>
#include "test-fixtures.h"

View file

@ -41,9 +41,9 @@
#undef TR_ENCRYPTION_H
#undef TR_CRYPTO_UTILS_H
#include "crypto-utils.h"
#include "crypto-utils.cc"
#include "crypto-utils-openssl.cc"
#include <libtransmission/crypto-utils.h>
#include <libtransmission/crypto-utils.cc>
#include <libtransmission/crypto-utils-openssl.cc>
#undef tr_base64_decode
#undef tr_base64_decode_impl

View file

@ -13,11 +13,11 @@
#include <string_view>
#include <unordered_set>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "peer-mse.h"
#include "crypto-utils.h"
#include "utils.h"
#include <libtransmission/peer-mse.h>
#include <libtransmission/crypto-utils.h>
#include <libtransmission/utils.h>
#include "crypto-test-ref.h"

View file

@ -11,11 +11,11 @@
#include <event2/event.h>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "file.h"
#include "timer-ev.h"
#include "session-thread.h" // for tr_evthread_init();
#include <libtransmission/file.h>
#include <libtransmission/timer-ev.h>
#include <libtransmission/session-thread.h> // for tr_evthread_init();
#include "gtest/gtest.h"
#include "test-fixtures.h"

View file

@ -3,8 +3,8 @@
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#include "transmission.h"
#include "error.h"
#include <libtransmission/transmission.h>
#include <libtransmission/error.h>
#include "test-fixtures.h"

View file

@ -7,10 +7,10 @@
#include <numeric>
#include <cstdint>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "block-info.h"
#include "file-piece-map.h"
#include <libtransmission/block-info.h>
#include <libtransmission/file-piece-map.h>
#include "gtest/gtest.h"

View file

@ -18,12 +18,12 @@
#include <windows.h>
#endif
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "error.h"
#include "file.h"
#include "tr-macros.h"
#include "tr-strbuf.h"
#include <libtransmission/error.h>
#include <libtransmission/file.h>
#include <libtransmission/tr-macros.h>
#include <libtransmission/tr-strbuf.h>
#include "test-fixtures.h"

View file

@ -3,8 +3,8 @@
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#include "transmission.h"
#include "tr-getopt.h"
#include <libtransmission/transmission.h>
#include <libtransmission/tr-getopt.h>
#include "gtest/gtest.h"

View file

@ -10,12 +10,12 @@
#include <event2/util.h>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "handshake.h"
#include "peer-io.h"
#include "session.h" // tr_peerIdInit()
#include "timer.h"
#include <libtransmission/handshake.h>
#include <libtransmission/peer-io.h>
#include <libtransmission/session.h> // tr_peerIdInit()
#include <libtransmission/timer.h>
#include "test-fixtures.h"

View file

@ -3,8 +3,8 @@
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#include "transmission.h"
#include "history.h"
#include <libtransmission/transmission.h>
#include <libtransmission/history.h>
#include "gtest/gtest.h"

View file

@ -9,9 +9,9 @@
#include <string>
#include <string_view>
#include "transmission.h"
#include "variant.h"
#include "variant-common.h"
#include <libtransmission/transmission.h>
#include <libtransmission/variant.h>
#include <libtransmission/variant-common.h>
#include "gtest/gtest.h"

View file

@ -9,11 +9,11 @@
#include <string_view>
#include <vector>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "crypto-utils.h" // tr_rand_obj()
#include "session.h"
#include "tr-lpd.h"
#include <libtransmission/crypto-utils.h> // tr_rand_obj()
#include <libtransmission/session.h>
#include <libtransmission/tr-lpd.h>
#include "test-fixtures.h"

View file

@ -8,10 +8,10 @@
#include "gtest/gtest.h"
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "magnet-metainfo.h"
#include "crypto-utils.h" // tr_rand_buffer()
#include <libtransmission/magnet-metainfo.h>
#include <libtransmission/crypto-utils.h> // tr_rand_buffer()
using namespace std::literals;

View file

@ -14,13 +14,13 @@
#include <fmt/format.h>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "crypto-utils.h"
#include "file.h"
#include "makemeta.h"
#include "session.h" // TR_NAME
#include "torrent-metainfo.h"
#include <libtransmission/crypto-utils.h>
#include <libtransmission/file.h>
#include <libtransmission/makemeta.h>
#include <libtransmission/session.h> // TR_NAME
#include <libtransmission/torrent-metainfo.h>
#include "test-fixtures.h"

View file

@ -11,12 +11,12 @@
#include <event2/buffer.h>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "cache.h" // tr_cacheWriteBlock()
#include "file.h" // tr_sys_path_*()
#include "tr-strbuf.h"
#include "variant.h"
#include <libtransmission/cache.h> // tr_cacheWriteBlock()
#include <libtransmission/file.h> // tr_sys_path_*()
#include <libtransmission/tr-strbuf.h>
#include <libtransmission/variant.h>
#include "test-fixtures.h"

View file

@ -7,10 +7,10 @@
#include <string_view>
#include <utility>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "net.h"
#include "peer-mgr.h"
#include <libtransmission/net.h>
#include <libtransmission/peer-mgr.h>
#include "test-fixtures.h"

View file

@ -6,11 +6,11 @@
#include <algorithm>
#include <string_view>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "error.h"
#include "file.h"
#include "tr-strbuf.h"
#include <libtransmission/error.h>
#include <libtransmission/file.h>
#include <libtransmission/tr-strbuf.h>
#include "test-fixtures.h"

View file

@ -8,9 +8,9 @@
#include <algorithm>
#include <type_traits>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "peer-mgr-active-requests.h"
#include <libtransmission/peer-mgr-active-requests.h>
#include "gtest/gtest.h"

View file

@ -9,9 +9,9 @@
#define LIBTRANSMISSION_PEER_MODULE
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "peer-mgr-wishlist.h"
#include <libtransmission/peer-mgr-wishlist.h>
#include "gtest/gtest.h"

View file

@ -5,8 +5,8 @@
#include <cstring>
#include "transmission.h"
#include "peer-msgs.h"
#include <libtransmission/transmission.h>
#include <libtransmission/peer-msgs.h>
#include "gtest/gtest.h"

View file

@ -6,11 +6,11 @@
#include <cstdlib>
#include <string_view>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "file.h"
#include "platform.h"
#include "tr-strbuf.h"
#include <libtransmission/file.h>
#include <libtransmission/platform.h>
#include <libtransmission/tr-strbuf.h>
#include "test-fixtures.h"

View file

@ -3,8 +3,8 @@
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#include "transmission.h"
#include "quark.h"
#include <libtransmission/transmission.h>
#include <libtransmission/quark.h>
#include "gtest/gtest.h"

View file

@ -9,11 +9,11 @@
#include <string_view>
#include <utility>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "file.h"
#include "torrent-files.h"
#include "tr-strbuf.h"
#include <libtransmission/file.h>
#include <libtransmission/torrent-files.h>
#include <libtransmission/tr-strbuf.h>
#include "test-fixtures.h"

View file

@ -3,14 +3,14 @@
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "file.h"
#include "resume.h"
#include "torrent.h" // tr_isTorrent()
#include "tr-assert.h"
#include "tr-strbuf.h"
#include "variant.h"
#include <libtransmission/file.h>
#include <libtransmission/resume.h>
#include <libtransmission/torrent.h> // tr_isTorrent()
#include <libtransmission/tr-assert.h>
#include <libtransmission/tr-strbuf.h>
#include <libtransmission/variant.h>
#include "test-fixtures.h"

View file

@ -3,9 +3,9 @@
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#include "transmission.h"
#include "rpcimpl.h"
#include "variant.h"
#include <libtransmission/transmission.h>
#include <libtransmission/rpcimpl.h>
#include <libtransmission/variant.h>
#include "test-fixtures.h"

View file

@ -8,10 +8,10 @@
#include <fmt/chrono.h>
#include "transmission.h"
#include "session.h"
#include "session-id.h"
#include "version.h"
#include <libtransmission/transmission.h>
#include <libtransmission/session.h>
#include <libtransmission/session-id.h>
#include <libtransmission/version.h>
#include "test-fixtures.h"

View file

@ -3,12 +3,12 @@
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "session-alt-speeds.h"
#include "session-id.h"
#include "session.h"
#include "version.h"
#include <libtransmission/session-alt-speeds.h>
#include <libtransmission/session-id.h>
#include <libtransmission/session.h>
#include <libtransmission/version.h>
#include "test-fixtures.h"

View file

@ -3,9 +3,9 @@
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "session-settings.h"
#include <libtransmission/session-settings.h>
#include "test-fixtures.h"

View file

@ -6,9 +6,9 @@
#include <cstring>
#include <string_view>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "tr-strbuf.h"
#include <libtransmission/tr-strbuf.h>
#include "test-fixtures.h"

View file

@ -3,11 +3,11 @@
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#include "transmission.h"
#include "error.h"
#include "file.h"
#include "platform.h"
#include "subprocess.h"
#include <libtransmission/transmission.h>
#include <libtransmission/error.h>
#include <libtransmission/file.h>
#include <libtransmission/platform.h>
#include <libtransmission/subprocess.h>
#include "gtest/internal/gtest-port.h" // GetArgvs()

View file

@ -18,14 +18,14 @@
#include <event2/event.h>
#include "crypto-utils.h" // tr_base64_decode()
#include "error.h"
#include "file.h" // tr_sys_file_*()
#include "platform.h" // TR_PATH_DELIMITER
#include "quark.h"
#include "torrent.h"
#include "utils.h"
#include "variant.h"
#include <libtransmission/crypto-utils.h> // tr_base64_decode()
#include <libtransmission/error.h>
#include <libtransmission/file.h> // tr_sys_file_*()
#include <libtransmission/platform.h> // TR_PATH_DELIMITER
#include <libtransmission/quark.h>
#include <libtransmission/torrent.h>
#include <libtransmission/utils.h>
#include <libtransmission/variant.h>
#include "gtest/gtest.h"

View file

@ -3,10 +3,10 @@
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "timer-ev.h"
#include "utils-ev.h"
#include <libtransmission/timer-ev.h>
#include <libtransmission/utils-ev.h>
#include "test-fixtures.h"

View file

@ -7,9 +7,9 @@
#include <string_view>
#include <utility>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "torrent-files.h"
#include <libtransmission/torrent-files.h>
#include "test-fixtures.h"

View file

@ -5,13 +5,13 @@
#include <string>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "crypto-utils.h"
#include "error.h"
#include "torrent-magnet.h"
#include "torrent-metainfo.h"
#include "torrent.h"
#include <libtransmission/crypto-utils.h>
#include <libtransmission/error.h>
#include <libtransmission/torrent-magnet.h>
#include <libtransmission/torrent-metainfo.h>
#include <libtransmission/torrent.h>
#include "test-fixtures.h"

View file

@ -6,14 +6,14 @@
#include <array>
#include <string_view>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "crypto-utils.h"
#include "error.h"
#include "torrent-metainfo.h"
#include "torrent.h"
#include "tr-strbuf.h"
#include "utils.h"
#include <libtransmission/crypto-utils.h>
#include <libtransmission/error.h>
#include <libtransmission/torrent-metainfo.h>
#include <libtransmission/torrent.h>
#include <libtransmission/tr-strbuf.h>
#include <libtransmission/utils.h>
#include "test-fixtures.h"

View file

@ -7,10 +7,10 @@
#include <string_view>
#include <vector>
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "torrent.h"
#include "torrents.h"
#include <libtransmission/torrent.h>
#include <libtransmission/torrents.h>
#include "gtest/gtest.h"

View file

@ -20,12 +20,12 @@
#define unsetenv(key) SetEnvironmentVariableA(key, nullptr)
#endif
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "crypto-utils.h" // tr_rand_int()
#include "platform.h"
#include "tr-strbuf.h"
#include "utils.h"
#include <libtransmission/crypto-utils.h> // tr_rand_int()
#include <libtransmission/platform.h>
#include <libtransmission/tr-strbuf.h>
#include <libtransmission/utils.h>
#include "test-fixtures.h"

View file

@ -5,13 +5,13 @@
#define LIBTRANSMISSION_VARIANT_MODULE
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "benc.h"
#include "crypto-utils.h" // tr_rand_buffer(), tr_rand_int()
#include "error.h"
#include "variant-common.h"
#include "variant.h"
#include <libtransmission/benc.h>
#include <libtransmission/crypto-utils.h> // tr_rand_buffer(), tr_rand_int()
#include <libtransmission/error.h>
#include <libtransmission/variant-common.h>
#include <libtransmission/variant.h>
#include <algorithm>
#include <array>

View file

@ -10,13 +10,13 @@
#define LIBTRANSMISSION_WATCHDIR_MODULE
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "file.h"
#include "net.h"
#include "watchdir.h"
#include "watchdir-base.h"
#include "timer-ev.h"
#include <libtransmission/file.h>
#include <libtransmission/net.h>
#include <libtransmission/watchdir.h>
#include <libtransmission/watchdir-base.h>
#include <libtransmission/timer-ev.h>
#include "test-fixtures.h"

View file

@ -11,11 +11,11 @@
#define unsetenv(key) SetEnvironmentVariableA(key, nullptr)
#endif
#include "transmission.h"
#include <libtransmission/transmission.h>
#include "crypto-utils.h"
#include "platform.h"
#include "web-utils.h"
#include <libtransmission/crypto-utils.h>
#include <libtransmission/platform.h>
#include <libtransmission/web-utils.h>
#include "test-fixtures.h"

View file

@ -5,20 +5,12 @@ foreach(P create edit remote show)
PRIVATE
${P}.cc)
target_include_directories(${TR_NAME}-${P}
PRIVATE
${CMAKE_SOURCE_DIR})
target_include_directories(${TR_NAME}-${P} SYSTEM
PRIVATE
${LIBFMT_INCLUDE_DIRS}
${EVENT2_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS})
target_link_libraries(${TR_NAME}-${P}
PRIVATE
${TR_NAME}
${CURL_LIBRARIES})
CURL::libcurl
fmt::fmt-header-only
libevent::event)
tr_win32_app_info(${TR_NAME}-${P}
"Transmission Utility ('${P}')"