1
cmake_minimum_required(VERSION 2.6)
27
instantiate_connection
40
http_tracker_connection
41
udp_tracker_connection
90
set(includes include zlib)
92
option(shared "build libtorrent as a shared library" ON)
93
option(tcmalloc "link against google performance tools tcmalloc" OFF)
94
option(pool-allocators "Uses a pool allocator for disk and piece buffers" ON)
95
option(encryption "link against openssl and enable encryption" ON)
96
option(geoip "link against LGPL GeoIP code from Maxmind, to enable geoip database support" OFF)
97
option(dht "enable support for Mainline DHT" ON)
98
option(resolve-countries "enable support for resolving countries from peer IPs" ON)
99
option(unicode "enable unicode support" ON)
100
option(deprecated-functions "enable deprecated functions for backwards compatibility" ON)
101
option(exceptions "build with exception support" ON)
102
option(logging "build with logging" OFF)
103
option(verbose-logging "build with verbose logging" OFF)
104
option(build_tests "build tests" OFF)
105
option(build_examples "build examples" OFF)
107
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo)
109
if (NOT CMAKE_BUILD_TYPE)
110
set(CMAKE_BUILD_TYPE Release FORCE)
111
endif (NOT CMAKE_BUILD_TYPE)
113
# add_definitions() doesn't seem to let you say wich build type to apply it to
114
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DTORRENT_DEBUG")
116
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g")
117
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
120
list(APPEND sources pe_crypto)
124
add_definitions(-DTORRENT_LOGGING)
127
add_definitions(-DTORRENT_VERBOSE_LOGGING)
128
endif (verbose-logging)
130
foreach(s ${sources})
131
list(APPEND sources2 src/${s})
133
foreach(s ${zlib_sources})
134
list(APPEND zlib_sources2 zlib/${s})
138
foreach(s ${kademlia_sources})
139
list(APPEND sources2 src/kademlia/${s})
142
add_definitions(-DTORRENT_DISABLE_DHT)
145
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
148
add_library(torrent-rasterbar SHARED ${sources2} ${zlib_sources2})
150
add_library(torrent-rasterbar STATIC ${sources2} ${zlib_sources2})
153
FIND_PACKAGE( Boost 1.34 COMPONENTS filesystem thread)
154
if (NOT Boost_VERSION LESS 103500)
155
FIND_PACKAGE( Boost 1.35 COMPONENTS filesystem thread system)
156
endif (NOT Boost_VERSION LESS 103500)
157
include_directories(${Boost_INCLUDE_DIR})
158
target_link_libraries(torrent-rasterbar ${Boost_LIBRARIES})
160
# this works around a bug in asio in boost-1.39
161
add_definitions(-DBOOST_ASIO_HASH_MAP_BUCKETS=1021)
164
target_link_libraries(torrent-rasterbar wsock32 ws2_32)
168
add_definitions(-DTORRENT_USE_OPENSSL)
170
target_link_libraries(torrent-rasterbar ssleay32 libeay32 advapi32 user32 shell32 gdi32)
172
target_link_libraries(torrent-rasterbar crypto ssl)
175
add_definitions(-DTORRENT_DISABLE_ENCRYPTION)
176
list(APPEND sources sha1)
179
if (NOT pool-allocators)
180
add_definitions(-DTORRENT_DISABLE_POOL_ALLOCATOR)
181
endif (NOT pool-allocators)
184
add_definitions(-DTORRENT_DISABLE_GEO_IP)
187
if (NOT resolve-countries)
188
add_definitions(-DTORRENT_DISABLE_RESOLVE_COUNTRIES)
189
endif (NOT resolve-countries)
192
add_definitions(-DUNICODE -D_UNICODE)
195
if (NOT deprecated-functions)
196
add_definitions(-DTORRENT_NO_DEPRECATE)
197
endif (NOT deprecated-functions)
200
add_definitions(-fexceptions)
202
add_definitions(-fno-exceptions)
206
# disable bogus deprecation warnings on msvc8
207
add_definitions(-D_SCL_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE)
208
# these compiler settings just makes the compiler standard conforming
209
add_definitions(/Zc:wchar_t /Zc:forScope)
211
# <toolset>msvc,<variant>release:<linkflags>/OPT:ICF=5
212
# <toolset>msvc,<variant>release:<linkflags>/OPT:REF
215
add_definitions(-D_FILE_OFFSET_BITS=64)
216
add_definitions(-DBOOST_DISABLE_EXCEPTION)
219
target_link_libraries(torrent-rasterbar tcmalloc)
222
target_link_libraries(torrent-rasterbar z)
223
include_directories(${includes})
225
set_target_properties(torrent-rasterbar PROPERTIES
229
set (VERSION "0.15.0")
231
get_property (COMPILETIME_OPTIONS_LIST
232
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIRECTORY}
233
PROPERTY COMPILE_DEFINITIONS
235
foreach (s ${COMPILETIME_OPTIONS_LIST})
236
set (COMPILETIME_OPTIONS "${COMPILETIME_OPTIONS} -D${s}")
239
configure_file(libtorrent-rasterbar-cmake.pc.in libtorrent-rasterbar.pc)
241
string (COMPARE EQUAL ${CMAKE_SIZEOF_VOID_P} "8" IS64BITS)
243
if (IS64BITS AND RESPECTLIB64)
245
else (IS64BITS AND RESPECTLIB64)
247
endif (IS64BITS AND RESPECTLIB64)
249
install(TARGETS torrent-rasterbar DESTINATION ${LIBDIR} CONFIGURATIONS release)
250
install(DIRECTORY include/libtorrent
252
PATTERN ".svn" EXCLUDE)
253
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtorrent-rasterbar.pc DESTINATION ${LIBDIR}/pkgconfig)
255
# === build examples ===
257
set(examples client_test dump_torrent simple_client enum_if make_torrent)
259
foreach(s ${examples})
260
add_executable(${s} examples/${s}.cpp)
261
target_link_libraries(${s} torrent-rasterbar)
264
FIND_PACKAGE( Boost 1.34 COMPONENTS program_options regex)
265
target_link_libraries(client_test ${Boost_LIBRARIES})
266
include_directories(${Boost_INCLUDE_DIR})
267
endif(build_examples)
268
# === build tests ===
281
test_bdecode_performance
285
test_metadata_extension
290
test_bandwidth_limiter
293
add_library(test_common STATIC test/main.cpp test/setup_transfer.cpp)
297
add_executable(${s} test/${s}.cpp)
298
target_link_libraries(${s} torrent-rasterbar test_common)
302
add_executable(test_upnp test/test_upnp.cpp)
303
target_link_libraries(test_upnp torrent-rasterbar)
305
add_executable(test_natpmp test/test_natpmp.cpp)
306
target_link_libraries(test_natpmp torrent-rasterbar)