premiere-libtorrent/CMakeLists.txt

376 lines
8.5 KiB
CMake
Raw Normal View History

2008-09-28 02:18:03 +02:00
cmake_minimum_required(VERSION 2.6)
project(libtorrent)
2014-09-13 21:47:51 +02:00
set (SOVERSION "8")
set (VERSION "1.1")
2008-09-28 02:18:03 +02:00
set(sources
web_connection_base
2008-09-28 02:18:03 +02:00
alert
alert_manager
allocator
asio
2008-09-28 02:18:03 +02:00
assert
bandwidth_limit
bandwidth_manager
bandwidth_queue_entry
2014-07-06 21:18:00 +02:00
block_cache
bloom_filter
chained_buffer
2008-09-28 02:18:03 +02:00
create_torrent
disk_buffer_holder
entry
error_code
file_storage
lazy_bdecode
escape_string
string_util
2008-09-28 02:18:03 +02:00
file
gzip
hasher
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
2008-09-28 02:18:03 +02:00
instantiate_connection
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
2008-09-28 02:18:03 +02:00
policy
2010-03-16 07:14:22 +01:00
puff
random
2014-07-06 21:18:00 +02:00
request_blocks
2011-01-18 04:41:54 +01:00
rss
2008-09-28 02:18:03 +02:00
session
session_call
2008-09-28 02:18:03 +02:00
session_impl
2014-07-06 21:18:00 +02:00
session_stats
settings_pack
socket_io
2009-12-05 17:50:07 +01:00
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
2014-07-06 21:18:00 +02:00
tailqueue
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
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
logger
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
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_tracker
node
refresh
rpc_manager
find_data
node_id
routing_table
traversal_algorithm
logging
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
2008-09-29 01:10:17 +02:00
option(shared "build libtorrent as a shared library" ON)
2014-05-10 09:10:17 +02:00
option(static_runtime "build libtorrent with static runtime" OFF)
2008-09-29 01:10:17 +02:00
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(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)
option(logging "build with logging" OFF)
option(verbose-logging "build with verbose logging" OFF)
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
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release FORCE)
2014-05-10 09:10:17 +02:00
endif()
# 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")
2014-05-10 09:10:17 +02:00
if(UNIX)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
endif()
2014-07-12 08:20:16 +02:00
if (build_tests)
# this will make some internal functions available in the
# DLL interface, for the tests to access
add_definitions(-DTORRENT_EXPORT_EXTRA)
endif (build_tests)
2008-09-29 01:10:17 +02:00
if (encryption)
2014-07-12 08:20:16 +02:00
list(APPEND sources pe_crypto asio_ssl)
if(NOT DEFINED OPENSSL_INCLUDE_DIR OR NOT DEFINED OPENSSL_LIBRARIES)
FIND_PACKAGE(OpenSSL REQUIRED)
endif()
add_definitions(-DTORRENT_USE_OPENSSL)
include_directories(${OPENSSL_INCLUDE_DIR})
else()
add_definitions(-DTORRENT_DISABLE_ENCRYPTION)
list(APPEND sources sha1)
2008-09-29 01:10:17 +02:00
endif (encryption)
2008-09-28 02:18:03 +02:00
if (logging)
add_definitions(-DTORRENT_LOGGING)
2014-05-10 09:10:17 +02:00
endif()
if (verbose-logging)
add_definitions(-DTORRENT_VERBOSE_LOGGING)
2014-05-10 09:10:17 +02:00
endif()
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)
foreach(s ${ed25519_sources})
list(APPEND sources2 ed25519/src/${s})
endforeach(s)
2014-05-10 09:10:17 +02:00
else()
2008-09-28 02:18:03 +02:00
add_definitions(-DTORRENT_DISABLE_DHT)
2014-05-10 09:10:17 +02:00
endif()
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)
2014-05-10 09:10:17 +02:00
if(static_runtime)
# fix /MT flag:
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
endif()
2010-03-16 07:14:22 +01:00
add_library(torrent-rasterbar STATIC ${sources2})
2014-05-10 09:10:17 +02:00
endif()
# Boost
if(NOT DEFINED Boost_INCLUDE_DIR OR NOT DEFINED Boost_LIBRARIES)
FIND_PACKAGE( Boost COMPONENTS system thread date_time chrono)
endif()
include_directories(${Boost_INCLUDE_DIR})
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
2014-05-10 09:10:17 +02:00
#add_definitions(-DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -D__USE_W32_SOCKETS -DWIN32_LEAN_AND_MEAN )
2009-06-27 21:30:15 +02:00
2014-05-10 09:10:17 +02:00
if(NOT static_runtime)
add_definitions(-DBOOST_ASIO_DYN_LINK -DBOOST_DATE_TIME_DYN_LINK -DBOOST_THREAD_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_CHRONO_DYN_LINK)
else()
add_definitions(-DBOOST_ASIO_SEPARATE_COMPILATION)
endif()
2012-06-17 01:19:36 +02:00
2008-09-28 02:18:03 +02:00
if (WIN32)
target_link_libraries(torrent-rasterbar wsock32 ws2_32)
2014-05-10 09:10:17 +02:00
add_definitions(-D_WIN32_WINNT=0x0500)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # multicore compilation
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 (encryption)
2012-06-17 01:19:36 +02:00
target_link_libraries(torrent-rasterbar ${OPENSSL_LIBRARIES})
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 (NOT pool-allocators)
2008-09-28 02:18:03 +02:00
add_definitions(-DTORRENT_DISABLE_POOL_ALLOCATOR)
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 (NOT resolve-countries)
2008-09-28 02:18:03 +02:00
add_definitions(-DTORRENT_DISABLE_RESOLVE_COUNTRIES)
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 (unicode)
2008-09-28 02:18:03 +02:00
add_definitions(-DUNICODE -D_UNICODE)
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 (NOT deprecated-functions)
2008-09-28 02:18:03 +02:00
add_definitions(-DTORRENT_NO_DEPRECATE)
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)
add_definitions(/EHsc)
else (MSVC)
add_definitions(-fexceptions)
endif (MSVC)
2014-05-10 09:10:17 +02:00
else()
if (MSVC)
add_definitions(-D_HAS_EXCEPTIONS=0)
else (MSVC)
add_definitions(-fno-exceptions)
endif (MSVC)
endif()
2009-02-13 08:10:27 +01:00
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
2014-05-10 09:10:17 +02:00
#$(SolutionDir)<toolset>msvc,<variant>release:<linkflags>/OPT:ICF=5
#$(SolutionDir)<toolset>msvc,<variant>release:<linkflags>/OPT:REF
else()
add_definitions(-Wno-c++11-extensions)
2014-05-10 09:10:17 +02:00
endif()
2008-09-28 02:18:03 +02:00
add_definitions(-D_FILE_OFFSET_BITS=64)
2014-06-22 20:49:33 +02:00
add_definitions(-DBOOST_EXCEPTION_DISABLE)
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)
target_link_libraries(torrent-rasterbar tcmalloc)
2014-05-10 09:10:17 +02:00
endif()
2008-09-28 02:18:03 +02:00
include_directories(${includes})
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
)
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)
2014-05-10 09:10:17 +02:00
endif()
2008-12-28 21:06:40 +01:00
string (COMPARE EQUAL "${CMAKE_SIZEOF_VOID_P}" "8" IS64BITS)
if (IS64BITS AND RESPECTLIB64)
set (LIBDIR "lib64")
2014-05-10 09:10:17 +02:00
else()
set (LIBDIR "lib")
2014-05-10 09:10:17 +02:00
endif()
2014-09-13 21:47:51 +02:00
install(TARGETS torrent-rasterbar DESTINATION ${LIBDIR})
install(DIRECTORY include/libtorrent
DESTINATION include
PATTERN ".svn" EXCLUDE)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtorrent-rasterbar.pc DESTINATION ${LIBDIR}/pkgconfig)
2008-09-28 02:26:49 +02:00
# === build examples ===
if(build_examples)
FILE(GLOB examples RELATIVE "${PROJECT_SOURCE_DIR}" "examples/*.cpp")
foreach(s ${examples})
2014-05-10 09:10:17 +02:00
get_filename_component (sn ${s} NAME_WE)
add_executable(${sn} ${s})
target_link_libraries(${sn} torrent-rasterbar)
endforeach(s)
include_directories(${Boost_INCLUDE_DIR})
2014-05-10 09:10:17 +02:00
endif()
# === build tests ===
if(build_tests)
2014-07-12 08:20:16 +02:00
FILE(GLOB tests RELATIVE "${PROJECT_SOURCE_DIR}" "test/test_*.cpp")
add_library(test_common STATIC test/main.cpp test/setup_transfer.cpp
test/dht_server.cpp test/udp_tracker.cpp test/peer_server.cpp
test/web_seed_suite.cpp)
enable_testing()
foreach(s ${tests})
2014-05-10 09:10:17 +02:00
get_filename_component (sn ${s} NAME_WE)
add_executable(${sn} ${s})
target_link_libraries(${sn} torrent-rasterbar test_common)
add_test(${sn} ${s})
endforeach(s)
2014-07-12 08:20:16 +02:00
# add_executable(test_upnp test/test_upnp.cpp)
# target_link_libraries(test_upnp torrent-rasterbar)
2014-07-12 08:20:16 +02:00
# add_executable(test_natpmp test/test_natpmp.cpp)
# target_link_libraries(test_natpmp torrent-rasterbar)
2014-05-10 09:10:17 +02:00
endif()