2014-12-01 19:55:22 +00:00
|
|
|
project(libtr)
|
|
|
|
|
2020-08-11 18:11:55 +00:00
|
|
|
configure_file(
|
|
|
|
version.h.in
|
|
|
|
version.h
|
|
|
|
)
|
2014-12-01 19:55:22 +00:00
|
|
|
|
2020-08-11 18:11:55 +00:00
|
|
|
set(PROJECT_FILES
|
2021-12-14 20:59:40 +00:00
|
|
|
announce-list.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
announcer-http.cc
|
|
|
|
announcer-udp.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
announcer.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
bandwidth.cc
|
|
|
|
bitfield.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
block-info.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
blocklist.cc
|
|
|
|
cache.cc
|
|
|
|
clients.cc
|
|
|
|
completion.cc
|
2021-10-24 18:19:57 +00:00
|
|
|
crypto-utils-ccrypto.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
crypto-utils-cyassl.cc
|
|
|
|
crypto-utils-fallback.cc
|
|
|
|
crypto-utils-openssl.cc
|
|
|
|
crypto-utils-polarssl.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
crypto-utils.cc
|
|
|
|
crypto.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
error.cc
|
|
|
|
fdlimit.cc
|
2021-11-29 01:12:54 +00:00
|
|
|
file-piece-map.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
file-posix.cc
|
|
|
|
file-win32.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
file.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
handshake.cc
|
|
|
|
inout.cc
|
|
|
|
log.cc
|
2021-11-10 02:42:18 +00:00
|
|
|
magnet-metainfo.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
makemeta.cc
|
|
|
|
natpmp.cc
|
|
|
|
net.cc
|
|
|
|
peer-io.cc
|
2021-11-19 18:37:38 +00:00
|
|
|
peer-mgr-active-requests.cc
|
|
|
|
peer-mgr-wishlist.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
peer-mgr.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
peer-msgs.cc
|
|
|
|
platform-quota.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
platform.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
port-forwarding.cc
|
|
|
|
ptrarray.cc
|
|
|
|
quark.cc
|
|
|
|
resume.cc
|
|
|
|
rpc-server.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
rpcimpl.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
session-id.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
session.cc
|
|
|
|
stats.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
subprocess-posix.cc
|
|
|
|
subprocess-win32.cc
|
|
|
|
torrent-ctor.cc
|
|
|
|
torrent-magnet.cc
|
2021-12-25 21:21:13 +00:00
|
|
|
torrent-metainfo.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
torrent.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
tr-assert.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
tr-dht.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
tr-getopt.cc
|
|
|
|
tr-lpd.cc
|
|
|
|
tr-udp.cc
|
|
|
|
tr-utp.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
trevent.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
upnp.cc
|
|
|
|
utils.cc
|
|
|
|
variant-benc.cc
|
|
|
|
variant-json.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
variant.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
verify.cc
|
|
|
|
watchdir-generic.cc
|
|
|
|
watchdir-inotify.cc
|
|
|
|
watchdir-kqueue.cc
|
|
|
|
watchdir-win32.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
watchdir.cc
|
2021-11-09 03:30:03 +00:00
|
|
|
web-utils.cc
|
2021-11-24 14:48:52 +00:00
|
|
|
web.cc
|
2021-09-12 17:41:49 +00:00
|
|
|
webseed.cc
|
2020-08-11 18:11:55 +00:00
|
|
|
)
|
|
|
|
|
2021-09-21 13:56:34 +00:00
|
|
|
string(REPLACE ";" " " CXX_WARNING_FLAGS_STR "${CXX_WARNING_FLAGS}")
|
2020-08-11 18:11:55 +00:00
|
|
|
foreach(FILE ${PROJECT_FILES})
|
2021-09-21 13:56:34 +00:00
|
|
|
set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS "${CXX_WARNING_FLAGS_STR}")
|
2020-08-11 18:11:55 +00:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(THIRD_PARTY_FILES
|
|
|
|
jsonsl.c
|
|
|
|
wildmat.c
|
|
|
|
)
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
set(${PROJECT_NAME}_SOURCES
|
2020-08-11 18:11:55 +00:00
|
|
|
${PROJECT_FILES}
|
|
|
|
${THIRD_PARTY_FILES}
|
2014-12-01 19:55:22 +00:00
|
|
|
)
|
|
|
|
|
2021-09-12 17:41:49 +00:00
|
|
|
set_source_files_properties(crypto-utils-fallback.cc PROPERTIES HEADER_FILE_ONLY ON)
|
2021-10-24 18:19:57 +00:00
|
|
|
foreach(CP ccrypto cyassl openssl polarssl)
|
2015-12-29 02:04:37 +00:00
|
|
|
if(NOT CP STREQUAL CRYPTO_PKG)
|
2021-09-12 17:41:49 +00:00
|
|
|
set_source_files_properties(crypto-utils-${CP}.cc PROPERTIES HEADER_FILE_ONLY ON)
|
2015-12-29 02:04:37 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2016-01-02 14:28:59 +00:00
|
|
|
if(WITH_INOTIFY)
|
|
|
|
add_definitions(-DWITH_INOTIFY)
|
|
|
|
else()
|
2021-09-12 17:41:49 +00:00
|
|
|
set_source_files_properties(watchdir-inotify.cc PROPERTIES HEADER_FILE_ONLY ON)
|
2016-01-02 14:28:59 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_KQUEUE)
|
|
|
|
add_definitions(-DWITH_KQUEUE)
|
|
|
|
else()
|
2021-09-12 17:41:49 +00:00
|
|
|
set_source_files_properties(watchdir-kqueue.cc PROPERTIES HEADER_FILE_ONLY ON)
|
2016-01-02 14:28:59 +00:00
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
if(WIN32)
|
2021-09-12 17:41:49 +00:00
|
|
|
set_source_files_properties(file-posix.cc subprocess-posix.cc PROPERTIES HEADER_FILE_ONLY ON)
|
2014-12-01 19:55:22 +00:00
|
|
|
else()
|
2021-09-12 17:41:49 +00:00
|
|
|
set_source_files_properties(file-win32.cc subprocess-win32.cc watchdir-win32.cc PROPERTIES HEADER_FILE_ONLY ON)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(${PROJECT_NAME}_PUBLIC_HEADERS
|
2021-11-09 03:30:03 +00:00
|
|
|
${PROJECT_BINARY_DIR}/version.h
|
2014-12-10 18:23:11 +00:00
|
|
|
error-types.h
|
2021-11-09 03:30:03 +00:00
|
|
|
error.h
|
2014-12-01 19:55:22 +00:00
|
|
|
file.h
|
|
|
|
log.h
|
|
|
|
makemeta.h
|
|
|
|
quark.h
|
|
|
|
rpcimpl.h
|
2016-09-05 19:06:26 +00:00
|
|
|
session-id.h
|
2017-06-08 07:24:12 +00:00
|
|
|
tr-assert.h
|
2014-12-01 19:55:22 +00:00
|
|
|
tr-getopt.h
|
2017-06-18 12:34:21 +00:00
|
|
|
tr-macros.h
|
2014-12-01 19:55:22 +00:00
|
|
|
transmission.h
|
|
|
|
utils.h
|
|
|
|
variant.h
|
2016-01-02 14:28:59 +00:00
|
|
|
watchdir.h
|
2021-11-09 03:30:03 +00:00
|
|
|
web-utils.h
|
2014-12-01 19:55:22 +00:00
|
|
|
web.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(${PROJECT_NAME}_PRIVATE_HEADERS
|
2021-12-14 20:59:40 +00:00
|
|
|
announce-list.h
|
2014-12-01 19:55:22 +00:00
|
|
|
announcer-common.h
|
|
|
|
announcer.h
|
|
|
|
bandwidth.h
|
|
|
|
bitfield.h
|
2021-11-24 14:48:52 +00:00
|
|
|
block-info.h
|
2014-12-01 19:55:22 +00:00
|
|
|
blocklist.h
|
|
|
|
cache.h
|
|
|
|
clients.h
|
|
|
|
completion.h
|
2014-12-04 12:13:59 +00:00
|
|
|
crypto-utils.h
|
2021-11-09 03:30:03 +00:00
|
|
|
crypto.h
|
2014-12-01 19:55:22 +00:00
|
|
|
fdlimit.h
|
2021-11-29 01:12:54 +00:00
|
|
|
file-piece-map.h
|
2014-12-01 19:55:22 +00:00
|
|
|
handshake.h
|
|
|
|
history.h
|
|
|
|
inout.h
|
2021-11-10 02:42:18 +00:00
|
|
|
magnet-metainfo.h
|
2020-10-13 15:33:56 +00:00
|
|
|
mime-types.h
|
2014-12-01 19:55:22 +00:00
|
|
|
natpmp_local.h
|
|
|
|
net.h
|
|
|
|
peer-common.h
|
|
|
|
peer-io.h
|
2021-11-19 18:37:38 +00:00
|
|
|
peer-mgr-active-requests.h
|
|
|
|
peer-mgr-wishlist.h
|
2021-11-24 14:48:52 +00:00
|
|
|
peer-mgr.h
|
2014-12-01 19:55:22 +00:00
|
|
|
peer-msgs.h
|
2017-06-28 15:46:06 +00:00
|
|
|
peer-socket.h
|
2014-12-01 19:55:22 +00:00
|
|
|
platform-quota.h
|
2021-11-09 03:30:03 +00:00
|
|
|
platform.h
|
2014-12-01 19:55:22 +00:00
|
|
|
port-forwarding.h
|
|
|
|
ptrarray.h
|
|
|
|
resume.h
|
|
|
|
rpc-server.h
|
|
|
|
session.h
|
|
|
|
stats.h
|
2021-11-09 03:30:03 +00:00
|
|
|
subprocess.h
|
2014-12-01 19:55:22 +00:00
|
|
|
torrent-magnet.h
|
2021-12-25 21:21:13 +00:00
|
|
|
torrent-metainfo.h
|
2021-11-09 03:30:03 +00:00
|
|
|
torrent.h
|
2014-12-01 19:55:22 +00:00
|
|
|
tr-dht.h
|
|
|
|
tr-lpd.h
|
|
|
|
tr-udp.h
|
2015-12-29 02:04:37 +00:00
|
|
|
tr-utp.h
|
2021-11-09 03:30:03 +00:00
|
|
|
trevent.h
|
2014-12-01 19:55:22 +00:00
|
|
|
upnp.h
|
|
|
|
variant-common.h
|
|
|
|
verify.h
|
|
|
|
version.h
|
2016-01-02 14:28:59 +00:00
|
|
|
watchdir-common.h
|
2014-12-01 19:55:22 +00:00
|
|
|
webseed.h
|
|
|
|
)
|
|
|
|
|
2015-12-29 02:04:37 +00:00
|
|
|
if(NOT ENABLE_UTP)
|
2021-09-12 17:41:49 +00:00
|
|
|
set_source_files_properties(tr-utp.cc PROPERTIES HEADER_FILE_ONLY ON)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(
|
|
|
|
-D__TRANSMISSION__
|
|
|
|
"-DPACKAGE_DATA_DIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}\""
|
|
|
|
${NATPMP_DEFINITIONS}
|
|
|
|
${MINIUPNPC_DEFINITIONS}
|
|
|
|
)
|
|
|
|
|
|
|
|
if(ENABLE_LIGHTWEIGHT)
|
|
|
|
add_definitions(-DTR_LIGHTWEIGHT)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT ENABLE_NLS)
|
|
|
|
add_definitions(-DDISABLE_GETTEXT)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_UTP)
|
|
|
|
add_definitions(-DWITH_UTP)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MINIUPNPC_VERSION VERSION_LESS 1.7)
|
|
|
|
# API version macro was only added in 1.7
|
|
|
|
add_definitions(-DMINIUPNPC_API_VERSION=${MINIUPNPC_API_VERSION})
|
|
|
|
endif()
|
|
|
|
|
2015-01-03 21:35:20 +00:00
|
|
|
if(USE_SYSTEM_B64)
|
|
|
|
add_definitions(-DUSE_SYSTEM_B64)
|
|
|
|
endif()
|
|
|
|
|
2016-10-26 19:12:51 +00:00
|
|
|
if(CYASSL_IS_WOLFSSL)
|
|
|
|
add_definitions(-DCYASSL_IS_WOLFSSL)
|
|
|
|
endif()
|
|
|
|
|
2016-10-26 17:37:10 +00:00
|
|
|
if(POLARSSL_IS_MBEDTLS)
|
|
|
|
add_definitions(-DPOLARSSL_IS_MBEDTLS)
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
include_directories(
|
|
|
|
${PROJECT_SOURCE_DIR}
|
|
|
|
${PROJECT_BINARY_DIR}
|
2020-08-11 18:11:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
SYSTEM
|
2021-11-30 21:13:56 +00:00
|
|
|
${UTFCPP_INCLUDE_DIRS}
|
2022-01-17 16:20:12 +00:00
|
|
|
${DEFLATE_INCLUDE_DIRS}
|
2015-01-07 02:04:08 +00:00
|
|
|
${CRYPTO_INCLUDE_DIRS}
|
2014-12-01 19:55:22 +00:00
|
|
|
${CURL_INCLUDE_DIRS}
|
|
|
|
${EVENT2_INCLUDE_DIRS}
|
|
|
|
${NATPMP_INCLUDE_DIRS}
|
|
|
|
${MINIUPNPC_INCLUDE_DIRS}
|
|
|
|
${DHT_INCLUDE_DIRS}
|
|
|
|
${UTP_INCLUDE_DIRS}
|
2015-01-01 21:16:36 +00:00
|
|
|
${B64_INCLUDE_DIRS}
|
2014-12-01 19:55:22 +00:00
|
|
|
)
|
|
|
|
|
2016-02-07 12:00:15 +00:00
|
|
|
if(ICONV_FOUND)
|
2020-08-11 18:11:55 +00:00
|
|
|
include_directories(SYSTEM ${ICONV_INCLUDE_DIRS})
|
2016-02-07 12:00:15 +00:00
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
if(ENABLE_UTP)
|
2020-08-11 18:11:55 +00:00
|
|
|
include_directories(SYSTEM ${TP_TOP}/libutp)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_library(${TR_NAME} STATIC
|
|
|
|
${${PROJECT_NAME}_SOURCES}
|
|
|
|
${${PROJECT_NAME}_PUBLIC_HEADERS}
|
|
|
|
${${PROJECT_NAME}_PRIVATE_HEADERS}
|
|
|
|
)
|
|
|
|
|
|
|
|
foreach(UT ${EVENT2_UPSTREAM_TARGET}
|
|
|
|
${NATPMP_UPSTREAM_TARGET}
|
|
|
|
${MINIUPNPC_UPSTREAM_TARGET}
|
|
|
|
${DHT_UPSTREAM_TARGET}
|
2022-01-17 16:20:12 +00:00
|
|
|
${DEFLATE_UPSTREAM_TARGET}
|
2015-01-01 21:16:36 +00:00
|
|
|
${UTP_UPSTREAM_TARGET}
|
|
|
|
${B64_UPSTREAM_TARGET})
|
2014-12-01 19:55:22 +00:00
|
|
|
add_dependencies(${TR_NAME} ${UT})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
target_link_libraries(${TR_NAME}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
2022-01-17 16:20:12 +00:00
|
|
|
${DEFLATE_LIBRARIES}
|
2015-01-07 02:04:08 +00:00
|
|
|
${CRYPTO_LIBRARIES}
|
2014-12-01 19:55:22 +00:00
|
|
|
${CURL_LIBRARIES}
|
|
|
|
${EVENT2_LIBRARIES}
|
|
|
|
${NATPMP_LIBRARIES}
|
|
|
|
${MINIUPNPC_LIBRARIES}
|
|
|
|
${DHT_LIBRARIES}
|
|
|
|
${UTP_LIBRARIES}
|
2015-01-01 21:16:36 +00:00
|
|
|
${B64_LIBRARIES}
|
2014-12-20 22:28:43 +00:00
|
|
|
${LIBINTL_LIBRARY}
|
2014-12-01 19:55:22 +00:00
|
|
|
${LIBM_LIBRARY}
|
2016-12-24 17:11:27 +00:00
|
|
|
${TR_NETWORK_LIBRARIES}
|
2021-09-12 03:47:29 +00:00
|
|
|
arc4::arc4
|
2014-12-01 19:55:22 +00:00
|
|
|
)
|
|
|
|
|
2016-02-07 12:00:15 +00:00
|
|
|
if(ICONV_FOUND)
|
|
|
|
target_link_libraries(${TR_NAME} ${ICONV_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2019-03-17 14:37:52 +00:00
|
|
|
if(WIN32)
|
2019-06-22 13:02:17 +00:00
|
|
|
target_link_libraries(${TR_NAME} crypt32 shlwapi)
|
2019-03-17 14:37:52 +00:00
|
|
|
endif()
|
2021-08-13 18:26:38 +00:00
|
|
|
|
|
|
|
if(INSTALL_LIB)
|
|
|
|
install(TARGETS ${TR_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
install(FILES ${${PROJECT_NAME}_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TR_NAME})
|
|
|
|
endif()
|