~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to CMakeLists.txt

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-08-10 12:59:37 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125937-jbcmmf17y8yo9hgz
Tags: 0.15.0-0ubuntu1
* New upstream version.
* debian/patches/100_fix_html_docs.patch: refreshed.
* debian/control: bump up standards-version to 3.9.1 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
cmake_minimum_required(VERSION 2.6)
 
2
project(libtorrent)
 
3
 
 
4
set(sources
 
5
        alert
 
6
        allocator
 
7
        assert
 
8
        connection_queue
 
9
        create_torrent
 
10
        disk_buffer_holder
 
11
        entry
 
12
        error_code
 
13
        file_storage
 
14
        lazy_bdecode
 
15
        escape_string
 
16
        file
 
17
        gzip
 
18
        http_connection
 
19
        http_stream
 
20
        http_parser
 
21
        identify_client
 
22
        ip_filter
 
23
        peer_connection
 
24
        bt_peer_connection
 
25
        web_peer_connection
 
26
        http_seed_connection
 
27
        instantiate_connection
 
28
        natpmp
 
29
        piece_picker
 
30
        policy
 
31
        session
 
32
        session_impl
 
33
        socks5_stream
 
34
        stat
 
35
        storage
 
36
        torrent
 
37
        torrent_handle
 
38
        torrent_info
 
39
        tracker_manager
 
40
        http_tracker_connection
 
41
        udp_tracker_connection
 
42
        udp_socket
 
43
        upnp
 
44
        logger
 
45
        file_pool
 
46
        lsd
 
47
        disk_io_thread
 
48
        enum_net
 
49
        broadcast_socket
 
50
        magnet_uri
 
51
        parse_url
 
52
        ConvertUTF
 
53
 
 
54
# -- extensions --
 
55
        metadata_transfer
 
56
        ut_pex
 
57
        ut_metadata
 
58
        smart_ban
 
59
        lt_trackers
 
60
)
 
61
 
 
62
# -- kademlia --
 
63
set(kademlia_sources
 
64
        closest_nodes
 
65
        dht_tracker
 
66
        node
 
67
        refresh
 
68
        rpc_manager
 
69
        find_data
 
70
        node_id
 
71
        routing_table
 
72
        traversal_algorithm
 
73
)
 
74
 
 
75
set(zlib_sources
 
76
        adler32
 
77
        compress
 
78
        crc32
 
79
        deflate
 
80
        gzio
 
81
        infback
 
82
        inffast
 
83
        inflate
 
84
        inftrees
 
85
        trees
 
86
        uncompr
 
87
        zutil
 
88
)
 
89
 
 
90
set(includes include zlib)
 
91
 
 
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)
 
106
 
 
107
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo)
 
108
 
 
109
if (NOT CMAKE_BUILD_TYPE)
 
110
        set(CMAKE_BUILD_TYPE Release FORCE)
 
111
endif (NOT CMAKE_BUILD_TYPE)
 
112
 
 
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")
 
115
 
 
116
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g")
 
117
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
 
118
 
 
119
if (encryption)
 
120
        list(APPEND sources pe_crypto)
 
121
endif (encryption)
 
122
 
 
123
if (logging)
 
124
        add_definitions(-DTORRENT_LOGGING)
 
125
endif (logging)
 
126
if (verbose-logging)
 
127
        add_definitions(-DTORRENT_VERBOSE_LOGGING)
 
128
endif (verbose-logging)
 
129
 
 
130
foreach(s ${sources})
 
131
        list(APPEND sources2 src/${s})
 
132
endforeach(s)
 
133
foreach(s ${zlib_sources})
 
134
        list(APPEND zlib_sources2 zlib/${s})
 
135
endforeach(s)
 
136
 
 
137
if (dht)
 
138
        foreach(s ${kademlia_sources})
 
139
                list(APPEND sources2 src/kademlia/${s})
 
140
        endforeach(s)
 
141
else (dht)
 
142
        add_definitions(-DTORRENT_DISABLE_DHT)
 
143
endif (dht)
 
144
 
 
145
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
 
146
 
 
147
if (shared)
 
148
        add_library(torrent-rasterbar SHARED ${sources2} ${zlib_sources2})
 
149
else (shared)
 
150
        add_library(torrent-rasterbar STATIC ${sources2} ${zlib_sources2})
 
151
endif (shared)
 
152
 
 
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})
 
159
 
 
160
# this works around a bug in asio in boost-1.39
 
161
add_definitions(-DBOOST_ASIO_HASH_MAP_BUCKETS=1021)
 
162
 
 
163
if (WIN32)
 
164
        target_link_libraries(torrent-rasterbar wsock32 ws2_32)
 
165
endif (WIN32)
 
166
 
 
167
if (encryption)
 
168
        add_definitions(-DTORRENT_USE_OPENSSL)
 
169
        if (WIN32)
 
170
                target_link_libraries(torrent-rasterbar ssleay32 libeay32 advapi32 user32 shell32 gdi32)
 
171
        else (WIN32)
 
172
                target_link_libraries(torrent-rasterbar crypto ssl)
 
173
        endif (WIN32)
 
174
else (encryption)
 
175
        add_definitions(-DTORRENT_DISABLE_ENCRYPTION)
 
176
        list(APPEND sources sha1)
 
177
endif (encryption)
 
178
 
 
179
if (NOT pool-allocators)
 
180
        add_definitions(-DTORRENT_DISABLE_POOL_ALLOCATOR)
 
181
endif (NOT pool-allocators)
 
182
 
 
183
if (NOT geoip)
 
184
        add_definitions(-DTORRENT_DISABLE_GEO_IP)
 
185
endif (NOT geoip)
 
186
 
 
187
if (NOT resolve-countries)
 
188
        add_definitions(-DTORRENT_DISABLE_RESOLVE_COUNTRIES)
 
189
endif (NOT resolve-countries)
 
190
 
 
191
if (unicode)
 
192
        add_definitions(-DUNICODE -D_UNICODE)
 
193
endif (unicode)
 
194
 
 
195
if (NOT deprecated-functions)
 
196
        add_definitions(-DTORRENT_NO_DEPRECATE)
 
197
endif (NOT deprecated-functions)
 
198
 
 
199
if (exceptions)
 
200
        add_definitions(-fexceptions)
 
201
else (exceptions)
 
202
        add_definitions(-fno-exceptions)
 
203
endif (exceptions)
 
204
 
 
205
if (MSVC)
 
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)
 
210
 
 
211
#       <toolset>msvc,<variant>release:<linkflags>/OPT:ICF=5
 
212
#       <toolset>msvc,<variant>release:<linkflags>/OPT:REF
 
213
endif(MSVC)
 
214
 
 
215
add_definitions(-D_FILE_OFFSET_BITS=64)
 
216
add_definitions(-DBOOST_DISABLE_EXCEPTION)
 
217
 
 
218
if (tcmalloc)
 
219
        target_link_libraries(torrent-rasterbar tcmalloc)
 
220
endif (tcmalloc)
 
221
 
 
222
target_link_libraries(torrent-rasterbar z)
 
223
include_directories(${includes})
 
224
 
 
225
set_target_properties(torrent-rasterbar PROPERTIES
 
226
        SOVERSION 1
 
227
        VERSION 1)
 
228
 
 
229
set (VERSION "0.15.0")
 
230
 
 
231
get_property (COMPILETIME_OPTIONS_LIST
 
232
        DIRECTORY ${CMAKE_CURRENT_SOURCE_DIRECTORY}
 
233
        PROPERTY COMPILE_DEFINITIONS
 
234
        )
 
235
foreach (s ${COMPILETIME_OPTIONS_LIST})
 
236
        set (COMPILETIME_OPTIONS "${COMPILETIME_OPTIONS} -D${s}")
 
237
endforeach (s)
 
238
 
 
239
configure_file(libtorrent-rasterbar-cmake.pc.in libtorrent-rasterbar.pc)
 
240
 
 
241
string (COMPARE EQUAL ${CMAKE_SIZEOF_VOID_P} "8" IS64BITS)
 
242
 
 
243
if (IS64BITS AND RESPECTLIB64)
 
244
        set (LIBDIR "lib64")
 
245
else (IS64BITS AND RESPECTLIB64)
 
246
        set (LIBDIR "lib")
 
247
endif (IS64BITS AND RESPECTLIB64)
 
248
 
 
249
install(TARGETS torrent-rasterbar DESTINATION ${LIBDIR} CONFIGURATIONS release)
 
250
install(DIRECTORY include/libtorrent
 
251
        DESTINATION include
 
252
        PATTERN ".svn" EXCLUDE)
 
253
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtorrent-rasterbar.pc DESTINATION ${LIBDIR}/pkgconfig)
 
254
 
 
255
# === build examples ===
 
256
if(build_examples)
 
257
        set(examples client_test dump_torrent simple_client enum_if make_torrent)
 
258
 
 
259
        foreach(s ${examples})
 
260
                add_executable(${s} examples/${s}.cpp)
 
261
                target_link_libraries(${s} torrent-rasterbar)
 
262
        endforeach(s)
 
263
 
 
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 ===
 
269
if(build_tests)
 
270
        set(tests
 
271
                test_auto_unchoke
 
272
                test_http_connection
 
273
                test_buffer
 
274
                test_storage
 
275
                test_torrent
 
276
                test_transfer
 
277
                test_piece_picker
 
278
                test_fast_extension
 
279
                test_pe_crypto
 
280
                test_bencoding
 
281
                test_bdecode_performance
 
282
                test_primitives
 
283
                test_ip_filter
 
284
                test_hasher
 
285
                test_metadata_extension
 
286
                test_swarm
 
287
                test_lsd
 
288
                test_pex
 
289
                test_web_seed
 
290
                test_bandwidth_limiter
 
291
                )
 
292
 
 
293
        add_library(test_common STATIC test/main.cpp test/setup_transfer.cpp)
 
294
        enable_testing()
 
295
 
 
296
        foreach(s ${tests})
 
297
                add_executable(${s} test/${s}.cpp)
 
298
                target_link_libraries(${s} torrent-rasterbar test_common)
 
299
                add_test(${s} ${s})
 
300
        endforeach(s)
 
301
 
 
302
        add_executable(test_upnp test/test_upnp.cpp)
 
303
        target_link_libraries(test_upnp torrent-rasterbar)
 
304
 
 
305
        add_executable(test_natpmp test/test_natpmp.cpp)
 
306
        target_link_libraries(test_natpmp torrent-rasterbar)
 
307
endif(build_tests)