Files
transmission/tests/libtransmission/CMakeLists.txt
Yat Ho a89ca4f2c9 build(cmake): support building with (almost) all system 3rd-party libraries (#7554)
* build: overhaul tr_add_external_auto_library

* build: use package-provided CMake config file libevent

* build: use package-provided CMake config file miniupnpc

* build: update libutp find module

* build: make LIBNAME an optional parameter

* build: use package-provided CMake config file libdeflate

* build: update libb64 find module

* build: update libnatpmp find module

* build: update libpsl find module

* build: support system fast_float library

* chore: reformat long brew commands

* build: support system fmt library

* build: support system rapidjson library

* build: support system small library

* build: support system library utf8cpp

* build: support system library WideInteger

* build: support system library gtest

* fix: incorrectly labeled test suites

* build: remove unused parameters from tr_add_external_auto_library

* build: update crc32c cmake script

* fix: dht system library

* fix: add libutp interface target

* code review: move TrGtest.cmake

* code review: move tr_get_fmt_version into Findfmt.cmake

* code review: use option() for gtest

* code review: move find_package(PkgConfig) out of loop

* build: delete FindCrc32c.cmake

Impossible to parse package version from distributed source files.

* code review: Finddht.cmake

* build: delete FindFastFloat.cmake

Impossible to parse package version from distributed source files.

* code review: Findfmt.cmake

* code review: Findlibb64.cmake

* code review: Findlibdeflate.cmake

* code review: Findlibevent.cmake

* code review: Findlibnatpmp.cmake

* code review: Findlibpsl.cmake

* code review: Findlibutp.cmake

* code review: Findlibminiupnpc.cmake

* code review: FindRapidJSON.cmake

* build: delete FindSmall.cmake

Impossible to parse package version from distributed source files.

* build: only accept cmake config package for utf8cpp

Impossible to parse package version from distributed source files.

* build: delete FindWideInteger.cmake

Impossible to parse package version from distributed source files.

* build: add `USE_SYSTEM_DEFAULT`

* ci: drop Fedora 40 and adopt Fedora 43

* ci: try to silence system header warnings

* ci: use `cmake --install`

* Revert "build: only accept cmake config package for utf8cpp"

This reverts commit 2158d631fd.

* build: harden utf8cpp find module

* chore: bump wide-integer

Pick up bf9398f9da and bcc726a30f

* refactor: gtest should be included with angled brackets

Now that gtest is built as a system library, it should be included with angled brackets instead of quotes.

* code review: fixup libutp variables before `find_package_handle_standard_args`

* code review: define `WIDE_INTEGER_HAS_LIMB_TYPE_UINT64` only for targets depending on WideInteger

* chore: bump wide-integer

Pickup 4b2258acac so that wide-integer tests won't run in Transmission project.
2026-01-12 09:04:47 -06:00

135 lines
3.3 KiB
CMake

include(GoogleTest)
add_executable(libtransmission-test)
target_sources(libtransmission-test
PRIVATE
announce-list-test.cc
announcer-test.cc
announcer-udp-test.cc
api-compat-test.cc
benc-test.cc
bitfield-test.cc
block-info-test.cc
blocklist-test.cc
buffer-test.cc
clients-test.cc
completion-test.cc
copy-test.cc
crypto-test.cc
dht-test.cc
error-test.cc
file-piece-map-test.cc
file-test.cc
getopt-test.cc
handshake-test.cc
history-test.cc
ip-cache-test.cc
json-test.cc
lpd-test.cc
magnet-metainfo-test.cc
makemeta-test.cc
move-test.cc
net-test.cc
open-files-test.cc
peer-mgr-wishlist-test.cc
peer-msgs-test.cc
platform-test.cc
quark-test.cc
remove-test.cc
rename-test.cc
rpc-test.cc
serializer-tests.cc
session-test.cc
session-alt-speeds-test.cc
settings-test.cc
strbuf-test.cc
subprocess-test-script.cmd
subprocess-test.cc
test-fixtures.h
timer-test.cc
torrent-files-test.cc
torrent-magnet-test.cc
torrent-metainfo-test.cc
torrent-queue-test.cc
torrents-test.cc
tr-peer-info-test.cc
utils-test.cc
values-test.cc
variant-test.cc
watchdir-test.cc
web-utils-test.cc)
set_property(
TARGET libtransmission-test
PROPERTY FOLDER "tests")
target_compile_definitions(libtransmission-test
PRIVATE
-DLIBTRANSMISSION_TEST_ASSETS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/assets"
__TRANSMISSION__)
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}
GTest::gtest_main
dht::dht
fmt::fmt-header-only
libevent::core
transmission::WideInteger)
if (WIN32)
cmake_policy(PUSH)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
add_custom_command(
TARGET libtransmission-test POST_BUILD
COMMAND
${CMAKE_COMMAND}
-E copy_if_different
$<TARGET_RUNTIME_DLLS:libtransmission-test>
$<TARGET_FILE_DIR:libtransmission-test>
COMMAND_EXPAND_LISTS
)
cmake_policy(POP)
endif ()
if(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
gtest_discover_tests(libtransmission-test
TEST_PREFIX "LT.")
else()
add_test(
NAME libtransmission-test
COMMAND libtransmission-test)
endif()
add_custom_command(
TARGET libtransmission-test
PRE_BUILD
COMMAND
${CMAKE_COMMAND}
-E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/subprocess-test-script.cmd
$<TARGET_FILE_DIR:libtransmission-test>/subprocess-test.cmd)
add_executable(subprocess-test)
target_sources(subprocess-test
PRIVATE
subprocess-test-program.cc)
set_property(
TARGET subprocess-test
PROPERTY FOLDER "tests")
target_link_libraries(subprocess-test
PRIVATE
${TR_NAME})
add_dependencies(libtransmission-test
subprocess-test)