2008-09-28 02:18:03 +02:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
project(libtorrent)
|
|
|
|
|
|
|
|
set(sources
|
2010-10-10 20:43:58 +02:00
|
|
|
web_connection_base
|
2008-09-28 02:18:03 +02:00
|
|
|
alert
|
2009-01-15 18:09:36 +01:00
|
|
|
allocator
|
2012-03-15 07:08:08 +01:00
|
|
|
asio
|
2012-03-19 00:31:04 +01:00
|
|
|
asio_ssl
|
2008-09-28 02:18:03 +02:00
|
|
|
assert
|
2009-09-16 06:41:35 +02:00
|
|
|
bandwidth_limit
|
|
|
|
bandwidth_manager
|
|
|
|
bandwidth_queue_entry
|
2010-12-24 02:31:41 +01:00
|
|
|
bloom_filter
|
2011-08-14 01:01:38 +02:00
|
|
|
chained_buffer
|
2008-09-28 02:18:03 +02:00
|
|
|
connection_queue
|
|
|
|
create_torrent
|
|
|
|
disk_buffer_holder
|
|
|
|
entry
|
|
|
|
error_code
|
|
|
|
file_storage
|
|
|
|
lazy_bdecode
|
|
|
|
escape_string
|
2012-08-26 17:26:17 +02:00
|
|
|
string_util
|
2008-09-28 02:18:03 +02:00
|
|
|
file
|
|
|
|
gzip
|
|
|
|
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
|
|
|
|
peer_connection
|
|
|
|
bt_peer_connection
|
|
|
|
web_peer_connection
|
2008-12-30 04:54:07 +01:00
|
|
|
http_seed_connection
|
2008-09-28 02:18:03 +02:00
|
|
|
instantiate_connection
|
|
|
|
natpmp
|
2010-11-29 02:33:05 +01:00
|
|
|
packet_buffer
|
2008-09-28 02:18:03 +02:00
|
|
|
piece_picker
|
|
|
|
policy
|
2010-03-16 07:14:22 +01:00
|
|
|
puff
|
2011-02-26 08:55:51 +01:00
|
|
|
random
|
2011-05-24 01:42:52 +02:00
|
|
|
rsa
|
2011-01-18 04:41:54 +01:00
|
|
|
rss
|
2008-09-28 02:18:03 +02:00
|
|
|
session
|
|
|
|
session_impl
|
2010-10-10 04:22:57 +02:00
|
|
|
settings
|
2009-09-16 05:46:36 +02:00
|
|
|
socket_io
|
2009-12-05 17:50:07 +01:00
|
|
|
socket_type
|
2008-09-28 02:18:03 +02:00
|
|
|
socks5_stream
|
|
|
|
stat
|
|
|
|
storage
|
2010-08-26 19:00:24 +02:00
|
|
|
thread
|
2009-11-25 07:55:34 +01:00
|
|
|
time
|
2012-05-16 06:34:18 +02:00
|
|
|
timestamp_history
|
2008-09-28 02:18:03 +02:00
|
|
|
torrent
|
|
|
|
torrent_handle
|
|
|
|
torrent_info
|
|
|
|
tracker_manager
|
|
|
|
http_tracker_connection
|
2012-03-20 04:53:07 +01:00
|
|
|
utf8
|
2008-09-28 02:18:03 +02:00
|
|
|
udp_tracker_connection
|
|
|
|
udp_socket
|
|
|
|
upnp
|
2012-05-16 06:34:18 +02:00
|
|
|
utp_socket_manager
|
2012-05-16 06:23:47 +02:00
|
|
|
utp_stream
|
2008-09-28 02:18:03 +02:00
|
|
|
logger
|
|
|
|
file_pool
|
|
|
|
lsd
|
2011-07-31 04:24:36 +02:00
|
|
|
disk_buffer_pool
|
2008-09-28 02:18:03 +02:00
|
|
|
disk_io_thread
|
|
|
|
enum_net
|
|
|
|
broadcast_socket
|
|
|
|
magnet_uri
|
|
|
|
parse_url
|
2008-11-14 06:25:56 +01:00
|
|
|
ConvertUTF
|
2008-09-28 02:18:03 +02:00
|
|
|
|
|
|
|
# -- extensions --
|
|
|
|
metadata_transfer
|
|
|
|
ut_pex
|
|
|
|
ut_metadata
|
|
|
|
smart_ban
|
2008-12-25 02:24:48 +01:00
|
|
|
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_tracker
|
|
|
|
node
|
|
|
|
refresh
|
|
|
|
rpc_manager
|
|
|
|
find_data
|
|
|
|
node_id
|
|
|
|
routing_table
|
|
|
|
traversal_algorithm
|
|
|
|
)
|
|
|
|
|
2010-03-16 07:14:22 +01:00
|
|
|
set(includes include)
|
2008-09-28 02:18:03 +02:00
|
|
|
|
2008-09-29 01:10:17 +02:00
|
|
|
option(shared "build libtorrent as a shared library" ON)
|
|
|
|
option(tcmalloc "link against google performance tools tcmalloc" OFF)
|
|
|
|
option(pool-allocators "Uses a pool allocator for disk and piece buffers" ON)
|
|
|
|
option(encryption "link against openssl and enable encryption" ON)
|
|
|
|
option(geoip "link against LGPL GeoIP code from Maxmind, to enable geoip database support" OFF)
|
|
|
|
option(dht "enable support for Mainline DHT" ON)
|
|
|
|
option(resolve-countries "enable support for resolving countries from peer IPs" ON)
|
|
|
|
option(unicode "enable unicode support" ON)
|
|
|
|
option(deprecated-functions "enable deprecated functions for backwards compatibility" ON)
|
2009-02-13 08:10:27 +01:00
|
|
|
option(exceptions "build with exception support" ON)
|
2009-06-22 17:46:00 +02:00
|
|
|
option(logging "build with logging" OFF)
|
|
|
|
option(verbose-logging "build with verbose logging" OFF)
|
2009-07-07 23:55:50 +02:00
|
|
|
option(build_tests "build tests" OFF)
|
2012-06-09 06:48:53 +02:00
|
|
|
option(build_examples "build examples" ON)
|
2008-09-29 01:10:17 +02:00
|
|
|
|
2008-12-29 00:07:46 +01:00
|
|
|
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo)
|
|
|
|
|
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release FORCE)
|
|
|
|
endif (NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
|
|
|
# add_definitions() doesn't seem to let you say wich build type to apply it to
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DTORRENT_DEBUG")
|
|
|
|
|
2009-06-22 17:46:00 +02:00
|
|
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
|
|
|
|
2008-09-29 01:10:17 +02:00
|
|
|
if (encryption)
|
2008-09-28 02:18:03 +02:00
|
|
|
list(APPEND sources pe_crypto)
|
2008-09-29 01:10:17 +02:00
|
|
|
endif (encryption)
|
2008-09-28 02:18:03 +02:00
|
|
|
|
2009-06-22 17:46:00 +02:00
|
|
|
if (logging)
|
|
|
|
add_definitions(-DTORRENT_LOGGING)
|
|
|
|
endif (logging)
|
|
|
|
if (verbose-logging)
|
|
|
|
add_definitions(-DTORRENT_VERBOSE_LOGGING)
|
|
|
|
endif (verbose-logging)
|
|
|
|
|
2008-09-28 02:18:03 +02:00
|
|
|
foreach(s ${sources})
|
|
|
|
list(APPEND sources2 src/${s})
|
|
|
|
endforeach(s)
|
|
|
|
|
2008-09-29 01:10:17 +02:00
|
|
|
if (dht)
|
2008-09-28 02:18:03 +02:00
|
|
|
foreach(s ${kademlia_sources})
|
|
|
|
list(APPEND sources2 src/kademlia/${s})
|
|
|
|
endforeach(s)
|
2008-09-29 01:10:17 +02:00
|
|
|
else (dht)
|
2008-09-28 02:18:03 +02:00
|
|
|
add_definitions(-DTORRENT_DISABLE_DHT)
|
2008-09-29 01:10:17 +02:00
|
|
|
endif (dht)
|
2008-09-28 02:18:03 +02:00
|
|
|
|
2012-06-17 01:19:36 +02:00
|
|
|
if(NOT MSVC)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fvisibility-inlines-hidden")
|
|
|
|
endif()
|
2009-02-13 08:10:27 +01:00
|
|
|
|
2008-09-29 01:10:17 +02:00
|
|
|
if (shared)
|
2012-11-01 04:51:50 +01:00
|
|
|
add_definitions(-DTORRENT_BUILDING_SHARED)
|
2010-03-16 07:14:22 +01:00
|
|
|
add_library(torrent-rasterbar SHARED ${sources2})
|
2008-09-29 01:10:17 +02:00
|
|
|
else (shared)
|
2010-03-16 07:14:22 +01:00
|
|
|
add_library(torrent-rasterbar STATIC ${sources2})
|
2008-09-29 01:10:17 +02:00
|
|
|
endif (shared)
|
2008-09-28 02:18:03 +02:00
|
|
|
|
2008-10-12 21:55:37 +02:00
|
|
|
if (NOT Boost_VERSION LESS 103500)
|
2012-06-17 01:19:36 +02:00
|
|
|
if(NOT MSVC)
|
|
|
|
FIND_PACKAGE( Boost 1.35 COMPONENTS system)
|
|
|
|
else(NOT MSVC)
|
|
|
|
FIND_PACKAGE( Boost 1.35 COMPONENTS system thread date_time)
|
|
|
|
endif(NOT MSVC)
|
2008-10-12 21:55:37 +02:00
|
|
|
endif (NOT Boost_VERSION LESS 103500)
|
|
|
|
include_directories(${Boost_INCLUDE_DIR})
|
2008-12-25 02:24:48 +01:00
|
|
|
target_link_libraries(torrent-rasterbar ${Boost_LIBRARIES})
|
2008-09-28 02:18:03 +02:00
|
|
|
|
2009-06-27 21:30:15 +02:00
|
|
|
# this works around a bug in asio in boost-1.39
|
2012-06-09 06:48:53 +02:00
|
|
|
add_definitions(-DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_ASIO_DYN_LINK -D__USE_W32_SOCKETS -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0500)
|
2009-06-27 21:30:15 +02:00
|
|
|
|
2012-11-01 04:51:50 +01:00
|
|
|
add_definitions(-DBOOST_DATE_TIME_DYN_LINK -DBOOST_THREAD_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_CHRONO_DYN_LINK)
|
2012-06-17 01:19:36 +02:00
|
|
|
|
2008-09-28 02:18:03 +02:00
|
|
|
if (WIN32)
|
2008-12-25 02:24:48 +01:00
|
|
|
target_link_libraries(torrent-rasterbar wsock32 ws2_32)
|
2008-09-28 02:18:03 +02:00
|
|
|
endif (WIN32)
|
|
|
|
|
2008-09-29 01:10:17 +02:00
|
|
|
if (encryption)
|
2012-06-17 01:19:36 +02:00
|
|
|
FIND_PACKAGE(OpenSSL REQUIRED)
|
2008-09-28 02:18:03 +02:00
|
|
|
add_definitions(-DTORRENT_USE_OPENSSL)
|
2012-06-17 01:19:36 +02:00
|
|
|
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
|
|
target_link_libraries(torrent-rasterbar ${OPENSSL_LIBRARIES})
|
2008-09-29 01:10:17 +02:00
|
|
|
else (encryption)
|
2008-09-28 02:18:03 +02:00
|
|
|
add_definitions(-DTORRENT_DISABLE_ENCRYPTION)
|
2008-10-12 21:55:37 +02:00
|
|
|
list(APPEND sources sha1)
|
2008-09-29 01:10:17 +02:00
|
|
|
endif (encryption)
|
2008-09-28 02:18:03 +02:00
|
|
|
|
2008-09-29 01:10:17 +02:00
|
|
|
if (NOT pool-allocators)
|
2008-09-28 02:18:03 +02:00
|
|
|
add_definitions(-DTORRENT_DISABLE_POOL_ALLOCATOR)
|
2008-09-29 01:10:17 +02:00
|
|
|
endif (NOT pool-allocators)
|
2008-09-28 02:18:03 +02:00
|
|
|
|
2008-09-29 01:10:17 +02:00
|
|
|
if (NOT geoip)
|
2008-09-28 02:18:03 +02:00
|
|
|
add_definitions(-DTORRENT_DISABLE_GEO_IP)
|
2008-09-29 01:10:17 +02:00
|
|
|
endif (NOT geoip)
|
2008-09-28 02:18:03 +02:00
|
|
|
|
2008-09-29 01:10:17 +02:00
|
|
|
if (NOT resolve-countries)
|
2008-09-28 02:18:03 +02:00
|
|
|
add_definitions(-DTORRENT_DISABLE_RESOLVE_COUNTRIES)
|
2008-09-29 01:10:17 +02:00
|
|
|
endif (NOT resolve-countries)
|
2008-09-28 02:18:03 +02:00
|
|
|
|
2008-09-29 01:10:17 +02:00
|
|
|
if (unicode)
|
2008-09-28 02:18:03 +02:00
|
|
|
add_definitions(-DUNICODE -D_UNICODE)
|
2008-09-29 01:10:17 +02:00
|
|
|
endif (unicode)
|
2008-09-28 02:18:03 +02:00
|
|
|
|
2008-09-29 01:10:17 +02:00
|
|
|
if (NOT deprecated-functions)
|
2008-09-28 02:18:03 +02:00
|
|
|
add_definitions(-DTORRENT_NO_DEPRECATE)
|
2008-09-29 01:10:17 +02:00
|
|
|
endif (NOT deprecated-functions)
|
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)
|
|
|
|
add_definitions(/EHsc)
|
|
|
|
else (MSVC)
|
|
|
|
add_definitions(-fexceptions)
|
|
|
|
endif (MSVC)
|
2009-02-13 08:10:27 +01:00
|
|
|
else (exceptions)
|
|
|
|
add_definitions(-fno-exceptions)
|
|
|
|
endif (exceptions)
|
|
|
|
|
2008-09-28 02:18:03 +02:00
|
|
|
if (MSVC)
|
|
|
|
# disable bogus deprecation warnings on msvc8
|
|
|
|
add_definitions(-D_SCL_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE)
|
|
|
|
# these compiler settings just makes the compiler standard conforming
|
|
|
|
add_definitions(/Zc:wchar_t /Zc:forScope)
|
2012-06-17 01:19:36 +02:00
|
|
|
# for multi-core compilation
|
|
|
|
add_definitions(/MP)
|
2008-09-28 02:18:03 +02:00
|
|
|
|
|
|
|
# <toolset>msvc,<variant>release:<linkflags>/OPT:ICF=5
|
|
|
|
# <toolset>msvc,<variant>release:<linkflags>/OPT:REF
|
|
|
|
endif(MSVC)
|
|
|
|
|
|
|
|
add_definitions(-D_FILE_OFFSET_BITS=64)
|
2009-01-07 02:58:43 +01:00
|
|
|
add_definitions(-DBOOST_DISABLE_EXCEPTION)
|
2010-11-29 02:33:05 +01:00
|
|
|
add_definitions(-DBOOST_ASIO_ENABLE_CANCELIO)
|
2008-09-28 02:18:03 +02:00
|
|
|
|
2008-09-29 01:10:17 +02:00
|
|
|
if (tcmalloc)
|
2008-12-25 02:24:48 +01:00
|
|
|
target_link_libraries(torrent-rasterbar tcmalloc)
|
2008-09-29 01:10:17 +02:00
|
|
|
endif (tcmalloc)
|
2008-09-28 02:18:03 +02:00
|
|
|
|
|
|
|
include_directories(${includes})
|
|
|
|
|
2008-12-25 02:24:48 +01:00
|
|
|
set_target_properties(torrent-rasterbar PROPERTIES
|
|
|
|
SOVERSION 1
|
|
|
|
VERSION 1)
|
2008-09-29 01:10:17 +02:00
|
|
|
|
2012-11-18 05:32:22 +01:00
|
|
|
set (VERSION "1.0.0")
|
2008-12-28 21:06:40 +01:00
|
|
|
|
|
|
|
get_property (COMPILETIME_OPTIONS_LIST
|
|
|
|
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIRECTORY}
|
|
|
|
PROPERTY COMPILE_DEFINITIONS
|
|
|
|
)
|
|
|
|
foreach (s ${COMPILETIME_OPTIONS_LIST})
|
|
|
|
set (COMPILETIME_OPTIONS "${COMPILETIME_OPTIONS} -D${s}")
|
|
|
|
endforeach (s)
|
|
|
|
|
2012-06-17 01:19:36 +02:00
|
|
|
if (MSVC)
|
|
|
|
configure_file(libtorrent-rasterbar-cmake.pc.in libtorrent-rasterbar.pc)
|
|
|
|
endif (MSVC)
|
2008-12-28 21:06:40 +01:00
|
|
|
|
2012-03-19 00:31:04 +01:00
|
|
|
string (COMPARE EQUAL "${CMAKE_SIZEOF_VOID_P}" "8" IS64BITS)
|
2009-06-22 17:46:00 +02:00
|
|
|
|
|
|
|
if (IS64BITS AND RESPECTLIB64)
|
|
|
|
set (LIBDIR "lib64")
|
|
|
|
else (IS64BITS AND RESPECTLIB64)
|
|
|
|
set (LIBDIR "lib")
|
|
|
|
endif (IS64BITS AND RESPECTLIB64)
|
|
|
|
|
|
|
|
install(TARGETS torrent-rasterbar DESTINATION ${LIBDIR} CONFIGURATIONS release)
|
2008-12-25 02:24:48 +01:00
|
|
|
install(DIRECTORY include/libtorrent
|
|
|
|
DESTINATION include
|
|
|
|
PATTERN ".svn" EXCLUDE)
|
2009-06-22 20:42:20 +02:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtorrent-rasterbar.pc DESTINATION ${LIBDIR}/pkgconfig)
|
2008-09-28 02:26:49 +02:00
|
|
|
|
2008-12-25 02:24:48 +01:00
|
|
|
# === build examples ===
|
|
|
|
if(build_examples)
|
|
|
|
set(examples client_test dump_torrent simple_client enum_if make_torrent)
|
2008-09-28 02:26:49 +02:00
|
|
|
|
2008-12-25 02:24:48 +01:00
|
|
|
foreach(s ${examples})
|
|
|
|
add_executable(${s} examples/${s}.cpp)
|
2008-12-25 03:12:54 +01:00
|
|
|
target_link_libraries(${s} torrent-rasterbar)
|
2008-12-25 02:24:48 +01:00
|
|
|
endforeach(s)
|
2008-10-12 21:55:37 +02:00
|
|
|
|
2008-12-25 02:24:48 +01:00
|
|
|
include_directories(${Boost_INCLUDE_DIR})
|
|
|
|
endif(build_examples)
|
2008-10-12 21:55:37 +02:00
|
|
|
# === build tests ===
|
2008-12-25 02:24:48 +01:00
|
|
|
if(build_tests)
|
|
|
|
set(tests
|
|
|
|
test_auto_unchoke
|
|
|
|
test_http_connection
|
|
|
|
test_buffer
|
|
|
|
test_storage
|
|
|
|
test_torrent
|
2009-09-27 05:38:41 +02:00
|
|
|
test_dht
|
2008-12-25 02:24:48 +01:00
|
|
|
test_transfer
|
|
|
|
test_piece_picker
|
|
|
|
test_fast_extension
|
|
|
|
test_pe_crypto
|
|
|
|
test_bencoding
|
|
|
|
test_bdecode_performance
|
|
|
|
test_primitives
|
|
|
|
test_ip_filter
|
|
|
|
test_hasher
|
|
|
|
test_metadata_extension
|
|
|
|
test_swarm
|
|
|
|
test_lsd
|
|
|
|
test_pex
|
|
|
|
test_web_seed
|
|
|
|
test_bandwidth_limiter
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(test_common STATIC test/main.cpp test/setup_transfer.cpp)
|
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
foreach(s ${tests})
|
|
|
|
add_executable(${s} test/${s}.cpp)
|
2008-12-25 03:12:54 +01:00
|
|
|
target_link_libraries(${s} torrent-rasterbar test_common)
|
2008-12-25 02:24:48 +01:00
|
|
|
add_test(${s} ${s})
|
|
|
|
endforeach(s)
|
2008-10-12 21:55:37 +02:00
|
|
|
|
2008-12-25 02:24:48 +01:00
|
|
|
add_executable(test_upnp test/test_upnp.cpp)
|
2008-12-25 03:12:54 +01:00
|
|
|
target_link_libraries(test_upnp torrent-rasterbar)
|
2008-10-15 18:25:39 +02:00
|
|
|
|
2008-12-25 02:24:48 +01:00
|
|
|
add_executable(test_natpmp test/test_natpmp.cpp)
|
2008-12-25 03:12:54 +01:00
|
|
|
target_link_libraries(test_natpmp torrent-rasterbar)
|
2008-12-25 02:24:48 +01:00
|
|
|
endif(build_tests)
|