2014-12-01 19:55:22 +00:00
|
|
|
project(libtr)
|
|
|
|
|
|
|
|
configure_file(version.h.in version.h)
|
|
|
|
|
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
|
|
|
set(THIRD_PARTY_SOURCES ConvertUTF.c jsonsl.c wildmat.c)
|
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|
|
|
set(DISABLE_WARNINGS -w)
|
|
|
|
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
|
|
set(DISABLE_WARNINGS -w)
|
|
|
|
elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro")
|
|
|
|
set(DISABLE_WARNINGS -erroff)
|
|
|
|
elseif(MSVC)
|
|
|
|
set(DISABLE_WARNINGS /w)
|
|
|
|
endif()
|
|
|
|
set_source_files_properties(${THIRD_PARTY_SOURCES} PROPERTIES COMPILE_FLAGS ${DISABLE_WARNINGS})
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
set(${PROJECT_NAME}_SOURCES
|
|
|
|
announcer.c
|
|
|
|
announcer-http.c
|
|
|
|
announcer-udp.c
|
|
|
|
bandwidth.c
|
|
|
|
bitfield.c
|
|
|
|
blocklist.c
|
|
|
|
cache.c
|
|
|
|
clients.c
|
|
|
|
completion.c
|
|
|
|
ConvertUTF.c
|
|
|
|
crypto.c
|
2014-12-04 12:13:59 +00:00
|
|
|
crypto-utils.c
|
2015-12-29 02:04:37 +00:00
|
|
|
crypto-utils-cyassl.c
|
#4400, #5462: Move DH helpers to crypto-utils
On a way to factoring out OpenSSL support to a standalone file to ease
addition of other crypto libraries support in the future, move helpers
providing DH key exchange to crypto-utils.{c,h}. OpenSSL-related
functionality (DH context management) is moved to crypto-utils-openssl.c.
Since we know in advance that DH secret key management code will be the
same for most of backends, implement common functionality in separate
crypto-utils-fallback.c.
Add new tr_dh_ctx_t and tr_dh_secret_t types and functions to be
implemented by crypto backends:
* tr_dh_new - allocate DH context,
* tr_dh_free - free the context,
* tr_dh_make_key - generate private/public keypair,
* tr_dh_agree - perform DH key exchange and generate secret key,
* tr_dh_secret_derive - calculate secret key hash,
* tr_dh_secret_free - free the secret key,
* tr_dh_align_key - align some DH key in the buffer allocated for it.
Make DH secret key not accessible in plain form outside the crypto
backend. This allows for implementations where the key is managed by
the underlying library and is not even exposed to our backend.
2014-12-04 19:18:08 +00:00
|
|
|
crypto-utils-fallback.c
|
2015-12-29 02:04:37 +00:00
|
|
|
crypto-utils-openssl.c
|
|
|
|
crypto-utils-polarssl.c
|
2014-12-01 19:55:22 +00:00
|
|
|
error.c
|
|
|
|
fdlimit.c
|
|
|
|
file.c
|
2015-12-29 02:04:37 +00:00
|
|
|
file-posix.c
|
|
|
|
file-win32.c
|
2014-12-01 19:55:22 +00:00
|
|
|
handshake.c
|
|
|
|
history.c
|
|
|
|
inout.c
|
|
|
|
list.c
|
|
|
|
log.c
|
|
|
|
magnet.c
|
|
|
|
makemeta.c
|
|
|
|
metainfo.c
|
|
|
|
natpmp.c
|
|
|
|
net.c
|
|
|
|
peer-io.c
|
|
|
|
peer-mgr.c
|
|
|
|
peer-msgs.c
|
|
|
|
platform.c
|
|
|
|
platform-quota.c
|
|
|
|
port-forwarding.c
|
|
|
|
ptrarray.c
|
|
|
|
quark.c
|
|
|
|
resume.c
|
|
|
|
rpcimpl.c
|
|
|
|
rpc-server.c
|
|
|
|
session.c
|
2016-09-05 19:06:26 +00:00
|
|
|
session-id.c
|
2017-11-27 22:22:44 +00:00
|
|
|
subprocess-posix.c
|
|
|
|
subprocess-win32.c
|
2014-12-01 19:55:22 +00:00
|
|
|
stats.c
|
|
|
|
torrent.c
|
|
|
|
torrent-ctor.c
|
|
|
|
torrent-magnet.c
|
|
|
|
tr-dht.c
|
|
|
|
trevent.c
|
2017-06-08 07:24:12 +00:00
|
|
|
tr-assert.c
|
2014-12-01 19:55:22 +00:00
|
|
|
tr-getopt.c
|
|
|
|
tr-lpd.c
|
|
|
|
tr-udp.c
|
2015-12-29 02:04:37 +00:00
|
|
|
tr-utp.c
|
2014-12-01 19:55:22 +00:00
|
|
|
upnp.c
|
|
|
|
utils.c
|
|
|
|
variant-benc.c
|
|
|
|
variant.c
|
|
|
|
variant-json.c
|
|
|
|
verify.c
|
2016-01-02 14:28:59 +00:00
|
|
|
watchdir.c
|
|
|
|
watchdir-generic.c
|
|
|
|
watchdir-inotify.c
|
|
|
|
watchdir-kqueue.c
|
|
|
|
watchdir-win32.c
|
2014-12-01 19:55:22 +00:00
|
|
|
web.c
|
|
|
|
webseed.c
|
|
|
|
wildmat.c
|
|
|
|
)
|
|
|
|
|
2015-12-29 02:04:37 +00:00
|
|
|
set_source_files_properties(crypto-utils-fallback.c PROPERTIES HEADER_FILE_ONLY ON)
|
|
|
|
foreach(CP cyassl openssl polarssl)
|
|
|
|
if(NOT CP STREQUAL CRYPTO_PKG)
|
|
|
|
set_source_files_properties(crypto-utils-${CP}.c PROPERTIES HEADER_FILE_ONLY ON)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2016-01-02 14:28:59 +00:00
|
|
|
if(WITH_INOTIFY)
|
|
|
|
add_definitions(-DWITH_INOTIFY)
|
|
|
|
else()
|
|
|
|
set_source_files_properties(watchdir-inotify.c PROPERTIES HEADER_FILE_ONLY ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_KQUEUE)
|
|
|
|
add_definitions(-DWITH_KQUEUE)
|
|
|
|
else()
|
|
|
|
set_source_files_properties(watchdir-kqueue.c PROPERTIES HEADER_FILE_ONLY ON)
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
if(WIN32)
|
2017-11-27 22:22:44 +00:00
|
|
|
set_source_files_properties(file-posix.c subprocess-posix.c PROPERTIES HEADER_FILE_ONLY ON)
|
2014-12-01 19:55:22 +00:00
|
|
|
else()
|
2017-11-27 22:22:44 +00:00
|
|
|
set_source_files_properties(file-win32.c subprocess-win32.c watchdir-win32.c PROPERTIES HEADER_FILE_ONLY ON)
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(${PROJECT_NAME}_PUBLIC_HEADERS
|
|
|
|
error.h
|
2014-12-10 18:23:11 +00:00
|
|
|
error-types.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
|
2014-12-01 19:55:22 +00:00
|
|
|
web.h
|
|
|
|
${PROJECT_BINARY_DIR}/version.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(${PROJECT_NAME}_PRIVATE_HEADERS
|
|
|
|
announcer-common.h
|
|
|
|
announcer.h
|
|
|
|
bandwidth.h
|
|
|
|
bitfield.h
|
|
|
|
blocklist.h
|
|
|
|
cache.h
|
|
|
|
clients.h
|
|
|
|
completion.h
|
|
|
|
ConvertUTF.h
|
|
|
|
crypto.h
|
2014-12-04 12:13:59 +00:00
|
|
|
crypto-utils.h
|
2014-12-01 19:55:22 +00:00
|
|
|
fdlimit.h
|
|
|
|
handshake.h
|
|
|
|
history.h
|
|
|
|
inout.h
|
|
|
|
list.h
|
|
|
|
magnet.h
|
|
|
|
metainfo.h
|
|
|
|
natpmp_local.h
|
|
|
|
net.h
|
|
|
|
peer-common.h
|
|
|
|
peer-io.h
|
|
|
|
peer-mgr.h
|
|
|
|
peer-msgs.h
|
2017-06-28 15:46:06 +00:00
|
|
|
peer-socket.h
|
2014-12-01 19:55:22 +00:00
|
|
|
platform.h
|
|
|
|
platform-quota.h
|
|
|
|
port-forwarding.h
|
|
|
|
ptrarray.h
|
|
|
|
resume.h
|
|
|
|
rpc-server.h
|
|
|
|
session.h
|
2017-11-27 22:22:44 +00:00
|
|
|
subprocess.h
|
2014-12-01 19:55:22 +00:00
|
|
|
stats.h
|
|
|
|
torrent.h
|
|
|
|
torrent-magnet.h
|
|
|
|
tr-dht.h
|
|
|
|
trevent.h
|
|
|
|
tr-lpd.h
|
|
|
|
tr-udp.h
|
2015-12-29 02:04:37 +00:00
|
|
|
tr-utp.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)
|
|
|
|
set_source_files_properties(tr-utp.c 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}
|
|
|
|
${ZLIB_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)
|
|
|
|
include_directories(${ICONV_INCLUDE_DIRS})
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
if(ENABLE_UTP)
|
|
|
|
include_directories(${TP_TOP}/libutp)
|
|
|
|
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}
|
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}
|
|
|
|
${ZLIB_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}
|
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()
|
|
|
|
|
2014-12-01 19:55:22 +00:00
|
|
|
if(ENABLE_TESTS)
|
|
|
|
add_library(${TR_NAME}-test STATIC
|
|
|
|
libtransmission-test.c
|
|
|
|
libtransmission-test.h
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(${TR_NAME}-test ${TR_NAME})
|
2015-04-14 22:46:40 +00:00
|
|
|
set_property(TARGET ${TR_NAME}-test PROPERTY FOLDER "UnitTests")
|
2014-12-01 19:55:22 +00:00
|
|
|
|
2015-01-01 14:23:47 +00:00
|
|
|
set(crypto-test_ADD_SOURCES crypto-test-ref.h)
|
2017-11-27 22:22:44 +00:00
|
|
|
set(subprocess-test_ADD_SOURCES subprocess-test.cmd)
|
2015-01-01 14:23:47 +00:00
|
|
|
|
2016-01-25 21:48:58 +00:00
|
|
|
set(watchdir@generic-test_DEFINITIONS WATCHDIR_TEST_FORCE_GENERIC)
|
|
|
|
|
2017-05-13 22:38:31 +00:00
|
|
|
foreach(T bitfield blocklist clients crypto error file history json magnet makemeta metainfo move peer-msgs quark rename rpc
|
2017-11-27 22:22:44 +00:00
|
|
|
session subprocess tr-getopt utils variant watchdir watchdir@generic)
|
2014-12-01 19:55:22 +00:00
|
|
|
set(TP ${TR_NAME}-test-${T})
|
2016-01-25 21:48:58 +00:00
|
|
|
if(T MATCHES "^([^@]+)@.+$")
|
2017-12-02 14:58:15 +00:00
|
|
|
string(REPLACE "@" "-" TP "${TP}")
|
|
|
|
string(REPLACE "@" "-" T_NAME "${T}")
|
2016-01-25 21:48:58 +00:00
|
|
|
set(${TP}_TEST_BASENAME "${CMAKE_MATCH_1}")
|
|
|
|
else()
|
2017-12-02 14:58:15 +00:00
|
|
|
set(T_NAME "${T}")
|
2016-01-25 21:48:58 +00:00
|
|
|
set(${TP}_TEST_BASENAME "${T}")
|
|
|
|
endif()
|
|
|
|
add_executable(${TP} ${${TP}_TEST_BASENAME}-test.c ${${T}-test_ADD_SOURCES})
|
2014-12-01 19:55:22 +00:00
|
|
|
target_link_libraries(${TP} ${TR_NAME} ${TR_NAME}-test)
|
2016-01-25 21:48:58 +00:00
|
|
|
if(DEFINED ${T}-test_DEFINITIONS)
|
|
|
|
target_compile_definitions(${TP} PRIVATE ${${T}-test_DEFINITIONS})
|
|
|
|
endif()
|
2017-12-02 14:58:15 +00:00
|
|
|
add_test(NAME ${T_NAME}-test COMMAND ${TP})
|
2015-04-14 22:46:40 +00:00
|
|
|
set_property(TARGET ${TP} PROPERTY FOLDER "UnitTests")
|
2014-12-01 19:55:22 +00:00
|
|
|
endforeach()
|
2017-11-27 22:22:44 +00:00
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
add_custom_command(TARGET ${TR_NAME}-test-subprocess PRE_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/subprocess-test.cmd
|
|
|
|
$<TARGET_FILE_DIR:${TR_NAME}-test-subprocess>/${TR_NAME}-test-subprocess.cmd)
|
|
|
|
endif()
|
2014-12-01 19:55:22 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(INSTALL_LIB)
|
|
|
|
install(TARGETS ${TR_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
install(FILES ${${PROJECT_NAME}_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TR_NAME})
|
|
|
|
endif()
|