premiere-libtorrent/CMakeLists.txt

451 lines
11 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR)
project(libtorrent
DESCRIPTION "Bittorrent library"
2019-01-11 02:37:26 +01:00
VERSION 1.1.12
)
2018-10-07 09:42:24 +02:00
set (SOVERSION "9")
list(APPEND CMAKE_MODULE_PATH ${libtorrent_SOURCE_DIR}/cmake/Modules)
include(GNUInstallDirs)
include(GeneratePkgConfig)
include(LibtorrentMacros)
2008-09-28 02:18:03 +02:00
set(sources
web_connection_base
2008-09-28 02:18:03 +02:00
alert
alert_manager
announce_entry
2008-09-28 02:18:03 +02:00
assert
bandwidth_limit
bandwidth_manager
bandwidth_queue_entry
bdecode
bitfield
2014-07-06 21:18:00 +02:00
block_cache
bloom_filter
chained_buffer
choker
close_reason
cpuid
2014-10-15 05:01:39 +02:00
crc32c
2008-09-28 02:18:03 +02:00
create_torrent
disk_buffer_holder
entry
error_code
file_storage
file_progress
2008-09-28 02:18:03 +02:00
lazy_bdecode
escape_string
string_util
2008-09-28 02:18:03 +02:00
file
fingerprint
2008-09-28 02:18:03 +02:00
gzip
hasher
2015-04-21 02:23:00 +02:00
hex
2008-09-28 02:18:03 +02:00
http_connection
http_stream
http_parser
2009-08-20 05:19:12 +02:00
i2p_stream
2008-09-28 02:18:03 +02:00
identify_client
ip_filter
ip_voter
2014-07-06 21:18:00 +02:00
performance_counters
peer_class
peer_class_set
2008-09-28 02:18:03 +02:00
peer_connection
bt_peer_connection
web_peer_connection
2008-12-30 04:54:07 +01:00
http_seed_connection
2015-07-02 06:13:26 +02:00
peer_connection_handle
2008-09-28 02:18:03 +02:00
instantiate_connection
merkle
2008-09-28 02:18:03 +02:00
natpmp
2014-07-06 21:18:00 +02:00
part_file
2010-11-29 02:33:05 +01:00
packet_buffer
2008-09-28 02:18:03 +02:00
piece_picker
2014-07-06 21:18:00 +02:00
platform_util
proxy_base
2014-10-26 08:34:31 +01:00
peer_list
2010-03-16 07:14:22 +01:00
puff
random
receive_buffer
2014-07-06 21:18:00 +02:00
request_blocks
resolve_links
2014-10-15 05:01:39 +02:00
resolver
2011-01-18 04:41:54 +01:00
rss
2008-09-28 02:18:03 +02:00
session
session_call
session_handle
2008-09-28 02:18:03 +02:00
session_impl
session_settings
proxy_settings
2014-07-06 21:18:00 +02:00
session_stats
settings_pack
socket_io
socket_type
2008-09-28 02:18:03 +02:00
socks5_stream
stat
2014-07-06 21:18:00 +02:00
stat_cache
2008-09-28 02:18:03 +02:00
storage
2009-11-25 07:55:34 +01:00
time
timestamp_history
2008-09-28 02:18:03 +02:00
torrent
torrent_handle
torrent_info
2014-07-06 21:18:00 +02:00
torrent_peer
torrent_peer_allocator
torrent_status
2008-09-28 02:18:03 +02:00
tracker_manager
http_tracker_connection
utf8
2008-09-28 02:18:03 +02:00
udp_tracker_connection
udp_socket
upnp
utp_socket_manager
2012-05-16 06:23:47 +02:00
utp_stream
2008-09-28 02:18:03 +02:00
file_pool
lsd
2014-07-06 21:18:00 +02:00
disk_io_job
disk_job_pool
disk_buffer_pool
2008-09-28 02:18:03 +02:00
disk_io_thread
enum_net
broadcast_socket
magnet_uri
parse_url
ConvertUTF
2014-05-03 23:10:44 +02:00
thread
xml_parse
version
2008-09-28 02:18:03 +02:00
# -- extensions --
metadata_transfer
ut_pex
ut_metadata
smart_ban
lt_trackers
2008-09-28 02:18:03 +02:00
)
2008-09-29 01:10:17 +02:00
# -- kademlia --
2008-09-28 02:18:03 +02:00
set(kademlia_sources
dht_storage
2014-10-15 05:01:39 +02:00
dos_blocker
2008-09-28 02:18:03 +02:00
dht_tracker
msg
2008-09-28 02:18:03 +02:00
node
node_entry
2008-09-28 02:18:03 +02:00
refresh
rpc_manager
find_data
2015-09-22 20:10:57 +02:00
put_data
2008-09-28 02:18:03 +02:00
node_id
routing_table
traversal_algorithm
2014-05-10 09:10:17 +02:00
item
get_peers
get_item
2008-09-28 02:18:03 +02:00
)
# -- ed25519 --
set(ed25519_sources
add_scalar
fe
ge
key_exchange
keypair
sc
seed
sha512
sign
verify
)
2014-05-10 09:10:17 +02:00
set(includes include ed25519/src)
2008-09-28 02:18:03 +02:00
list_prepend(sources "src/")
list_prepend(kademlia_sources "src/kademlia/")
list_prepend(ed25519_sources "ed25519/src/")
# these options control target creation and thus have to be declared before the add_library() call
feature_option(BUILD_SHARED_LIBS "build libtorrent as a shared library" ON)
feature_option(static_runtime "build libtorrent with static runtime" OFF)
find_public_dependency(Threads REQUIRED)
if(static_runtime)
include(ucm_flags)
ucm_set_runtime(STATIC)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME ON)
set(OPENSSL_USE_STATIC_LIBS TRUE)
set(OPENSSL_MSVC_STATIC_RT TRUE)
2014-05-10 09:10:17 +02:00
endif()
if (NOT BUILD_SHARED_LIBS)
set(Boost_USE_STATIC_LIBS ON)
2014-05-10 09:10:17 +02:00
endif()
add_library(torrent-rasterbar ${sources})
if (BUILD_SHARED_LIBS)
target_compile_definitions(torrent-rasterbar
PRIVATE TORRENT_BUILDING_SHARED
INTERFACE TORRENT_LINKING_SHARED
)
endif()
2014-11-17 04:41:01 +01:00
set_target_properties(torrent-rasterbar
PROPERTIES
CXX_VISIBILITY_PRESET "hidden"
VISIBILITY_INLINES_HIDDEN "true"
VERSION ${PROJECT_VERSION}
SOVERSION ${SOVERSION}
)
2008-09-28 02:18:03 +02:00
target_compile_definitions(torrent-rasterbar
PUBLIC
$<$<CONFIG:Debug>:TORRENT_DEBUG>
PRIVATE
TORRENT_BUILDING_LIBRARY
_FILE_OFFSET_BITS=64
BOOST_EXCEPTION_DISABLE
BOOST_ASIO_ENABLE_CANCELIO
)
target_include_directories(torrent-rasterbar
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(torrent-rasterbar
PUBLIC
Threads::Threads
)
feature_option(build_tests "build tests" OFF)
if(NOT build_tests) # tests require deprecated symbols
target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME deprecated-functions DEFAULT ON
DESCRIPTION "enable deprecated functions for backwards compatibility" DISABLED TORRENT_NO_DEPRECATE)
endif()
feature_option(build_examples "build examples" OFF)
feature_option(build_tools "build tools" OFF)
feature_option(python-bindings "build python bindings" OFF)
target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME logging DEFAULT ON
DESCRIPTION "build with logging" DISABLED TORRENT_DISABLE_LOGGING)
target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME pool-allocators DEFAULT ON
DESCRIPTION "Uses a pool allocator for disk and piece buffers" DISABLED TORRENT_DISABLE_POOL_ALLOCATOR)
target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME resolve-countries DEFAULT ON
DESCRIPTION "enable support for resolving countries from peer IPs" DISABLED TORRENT_DISABLE_RESOLVE_COUNTRIES)
target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME unicode DEFAULT ON
DESCRIPTION "enable unicode support" ENABLED UNICODE _UNICODE)
feature_option(dht "enable support for Mainline DHT" ON)
feature_option(encryption "link against openssl and enable encryption" ON)
feature_option(exceptions "build with exception support" ON)
2008-09-28 02:18:03 +02:00
2008-09-29 01:10:17 +02:00
if (dht)
target_sources(torrent-rasterbar PRIVATE ${kademlia_sources} ${ed25519_sources})
2014-05-10 09:10:17 +02:00
else()
target_compile_definitions(torrent-rasterbar PUBLIC TORRENT_DISABLE_DHT)
2014-05-10 09:10:17 +02:00
endif()
2008-09-28 02:18:03 +02:00
if (encryption)
find_public_dependency(OpenSSL REQUIRED)
set_package_properties(OpenSSL
PROPERTIES
URL "https://www.openssl.org/"
DESCRIPTION "Full-strength general purpose cryptography library"
TYPE RECOMMENDED
PURPOSE "Provides encryption support to libtorrent"
)
target_sources(torrent-rasterbar PRIVATE src/mpi src/pe_crypto)
target_link_libraries(torrent-rasterbar PUBLIC OpenSSL::SSL)
target_compile_definitions(torrent-rasterbar PUBLIC TORRENT_USE_OPENSSL)
else()
target_sources(torrent-rasterbar PRIVATE src/sha1)
target_compile_definitions(torrent-rasterbar PUBLIC TORRENT_DISABLE_ENCRYPTION)
2014-05-10 09:10:17 +02:00
endif()
option(tcmalloc "link against google performance tools tcmalloc" OFF)
# C++ standard and Boost requirements are connected:
# 1. With C++11 onward, we require Boost system component, with C++03 we need chrono and random components too
# 2. When building against boost 1.66 and newer, C++11 is required.
set(minimal_required_cxx_standard 98)
# For the first requirement we do:
set(required_boost_components system)
if (NOT cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
list(APPEND required_boost_components chrono random)
endif()
2014-05-10 09:10:17 +02:00
# Boost
find_public_dependency(Boost REQUIRED COMPONENTS ${required_boost_components})
target_include_directories(torrent-rasterbar PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(torrent-rasterbar PUBLIC ${Boost_SYSTEM_LIBRARY})
# now test the second requirement:
if (Boost_VERSION VERSION_GREATER_EQUAL 106600)
set(minimal_required_cxx_standard 11)
if (NOT cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
message(FATAL_ERROR "When building against boost 1.66 and newer, C++11 is required,\n"
"and your compiler does not support that")
endif()
endif()
select_cxx_standard(torrent-rasterbar ${minimal_required_cxx_standard})
target_link_libraries(torrent-rasterbar PUBLIC ${Boost_LIBRARIES})
2009-06-27 21:30:15 +02:00
2008-09-28 02:18:03 +02:00
if (WIN32)
target_link_libraries(torrent-rasterbar
PRIVATE
wsock32 ws2_32 Iphlpapi
debug dbghelp
)
2014-11-27 04:05:06 +01:00
add_definitions(-D_WIN32_WINNT=0x0600)
2015-04-26 03:25:45 +02:00
# prevent winsock1 to be included
add_definitions(-DWIN32_LEAN_AND_MEAN)
2014-11-27 04:05:06 +01:00
if (MSVC)
target_compile_definitions(torrent-rasterbar
PUBLIC
BOOST_ALL_NO_LIB
_SCL_SECURE_NO_DEPRECATE _CRT_SECURE_NO_DEPRECATE # disable bogus deprecation warnings on msvc8
)
target_compile_options(torrent-rasterbar
PRIVATE
/Zc:wchar_t /Zc:forScope # these compiler settings just make the compiler standard conforming
/MP # for multi-core compilation
/bigobj # increase the number of sections for obj files
)
2014-11-27 04:05:06 +01:00
endif()
2014-05-10 09:10:17 +02:00
endif()
2008-09-28 02:18:03 +02:00
2009-02-13 08:10:27 +01:00
if (exceptions)
2012-06-17 01:19:36 +02:00
if (MSVC)
target_compile_options(torrent-rasterbar PUBLIC /EHsc)
2012-06-17 01:19:36 +02:00
else (MSVC)
target_compile_options(torrent-rasterbar PUBLIC -fexceptions)
2012-06-17 01:19:36 +02:00
endif (MSVC)
2014-05-10 09:10:17 +02:00
else()
if (MSVC)
target_compile_definitions(torrent-rasterbar PUBLIC _HAS_EXCEPTIONS=0)
2014-05-10 09:10:17 +02:00
else (MSVC)
target_compile_options(torrent-rasterbar PUBLIC -fno-exceptions)
2014-05-10 09:10:17 +02:00
endif (MSVC)
endif()
2009-02-13 08:10:27 +01:00
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_definitions(-Wno-c++11-extensions)
add_definitions(-fcolor-diagnostics)
2014-05-10 09:10:17 +02:00
endif()
2008-09-28 02:18:03 +02:00
2008-09-29 01:10:17 +02:00
if (tcmalloc)
target_link_libraries(torrent-rasterbar PRIVATE tcmalloc)
2014-05-10 09:10:17 +02:00
endif()
2008-09-28 02:18:03 +02:00
set_target_properties(torrent-rasterbar PROPERTIES
2014-09-13 21:47:51 +02:00
SOVERSION ${SOVERSION})
2008-12-28 21:06:40 +01:00
get_property (COMPILETIME_OPTIONS_LIST
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIRECTORY}
PROPERTY COMPILE_DEFINITIONS
)
set(COMPILETIME_OPTIONS ${CXX_MODE_COMPILE_OPTION})
2008-12-28 21:06:40 +01:00
foreach (s ${COMPILETIME_OPTIONS_LIST})
set (COMPILETIME_OPTIONS "${COMPILETIME_OPTIONS} -D${s}")
endforeach (s)
# There is little to none support for using pkg-config with MSVC and most users won't bother with it.
# However, msys is a linux-like platform on Windows that do support/prefer using pkg-config.
if (NOT MSVC)
generate_and_install_pkg_config_file(torrent-rasterbar libtorrent-rasterbar)
endif()
2008-12-28 21:06:40 +01:00
install(TARGETS torrent-rasterbar EXPORT LibtorrentRasterbarTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY include/libtorrent DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h*")
# === generate a CMake Config File ===
include(CMakePackageConfigHelpers)
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/LibtorrentRasterbar)
string(REGEX REPLACE "([^;]+)" "find_dependency(\\1)" _find_dependency_calls "${_package_dependencies}")
string(REPLACE ";" "\n" _find_dependency_calls "${_find_dependency_calls}")
if(CMAKE_VERSION VERSION_LESS "3.11.0")
set(_compatibility ExactVersion)
2014-05-10 09:10:17 +02:00
else()
set(_compatibility SameMinorVersion)
2014-05-10 09:10:17 +02:00
endif()
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/LibtorrentRasterbar/LibtorrentRasterbarConfigVersion.cmake"
VERSION ${libtorrent_VERSION}
COMPATIBILITY ${_compatibility}
)
2008-09-28 02:26:49 +02:00
export(EXPORT LibtorrentRasterbarTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/LibtorrentRasterbar/LibtorrentRasterbarTargets.cmake"
NAMESPACE LibtorrentRasterbar::
)
configure_package_config_file(LibtorrentRasterbarConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/LibtorrentRasterbar/LibtorrentRasterbarConfig.cmake"
INSTALL_DESTINATION "${ConfigPackageLocation}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(EXPORT LibtorrentRasterbarTargets
NAMESPACE
LibtorrentRasterbar::
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/LibtorrentRasterbar/LibtorrentRasterbarConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/LibtorrentRasterbar/LibtorrentRasterbarConfigVersion.cmake"
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/examples/cmake/FindLibtorrentRasterbar.cmake
DESTINATION
${CMAKE_INSTALL_DATADIR}/cmake/Modules
)
include(CheckCXXCompilerFlag)
add_subdirectory(bindings)
# === build tools ===
if (build_tools)
add_subdirectory(tools)
endif()
# === build examples ===
if (build_examples)
add_subdirectory(examples)
endif()
2014-05-10 09:10:17 +02:00
# === build tests ===
if(build_tests)
enable_testing()
# this will make some internal functions available in the DLL interface
target_compile_definitions(torrent-rasterbar PUBLIC TORRENT_EXPORT_EXTRA)
add_subdirectory(test)
2014-05-10 09:10:17 +02:00
endif()
feature_summary(DEFAULT_DESCRIPTION WHAT ALL)