source: trunk/libtransmission/CMakeLists.txt

Last change on this file was 14679, checked in by mikedld, 5 years ago

Only depend on iconv if found

File size: 6.2 KB
Line 
1project(libtr)
2
3configure_file(version.h.in version.h)
4
5set(${PROJECT_NAME}_SOURCES
6    announcer.c
7    announcer-http.c
8    announcer-udp.c
9    bandwidth.c
10    bitfield.c
11    blocklist.c
12    cache.c
13    clients.c
14    completion.c
15    ConvertUTF.c
16    crypto.c
17    crypto-utils.c
18    crypto-utils-cyassl.c
19    crypto-utils-fallback.c
20    crypto-utils-openssl.c
21    crypto-utils-polarssl.c
22    error.c
23    fdlimit.c
24    file.c
25    file-posix.c
26    file-win32.c
27    handshake.c
28    history.c
29    inout.c
30    list.c
31    log.c
32    magnet.c
33    makemeta.c
34    metainfo.c
35    natpmp.c
36    net.c
37    peer-io.c
38    peer-mgr.c
39    peer-msgs.c
40    platform.c
41    platform-quota.c
42    port-forwarding.c
43    ptrarray.c
44    quark.c
45    resume.c
46    rpcimpl.c
47    rpc-server.c
48    session.c
49    stats.c
50    torrent.c
51    torrent-ctor.c
52    torrent-magnet.c
53    tr-dht.c
54    trevent.c
55    tr-getopt.c
56    tr-lpd.c
57    tr-udp.c
58    tr-utp.c
59    upnp.c
60    utils.c
61    variant-benc.c
62    variant.c
63    variant-json.c
64    verify.c
65    watchdir.c
66    watchdir-generic.c
67    watchdir-inotify.c
68    watchdir-kqueue.c
69    watchdir-win32.c
70    web.c
71    webseed.c
72    wildmat.c
73)
74
75set_source_files_properties(crypto-utils-fallback.c PROPERTIES HEADER_FILE_ONLY ON)
76foreach(CP cyassl openssl polarssl)
77    if(NOT CP STREQUAL CRYPTO_PKG)
78        set_source_files_properties(crypto-utils-${CP}.c PROPERTIES HEADER_FILE_ONLY ON)
79    endif()
80endforeach()
81
82if(WITH_INOTIFY)
83    add_definitions(-DWITH_INOTIFY)
84else()
85    set_source_files_properties(watchdir-inotify.c PROPERTIES HEADER_FILE_ONLY ON)
86endif()
87
88if(WITH_KQUEUE)
89    add_definitions(-DWITH_KQUEUE)
90else()
91    set_source_files_properties(watchdir-kqueue.c PROPERTIES HEADER_FILE_ONLY ON)
92endif()
93
94if(WIN32)
95    set_source_files_properties(file-posix.c PROPERTIES HEADER_FILE_ONLY ON)
96else()
97    set_source_files_properties(file-win32.c watchdir-win32.c PROPERTIES HEADER_FILE_ONLY ON)
98endif()
99
100set(${PROJECT_NAME}_PUBLIC_HEADERS
101    error.h
102    error-types.h
103    file.h
104    log.h
105    makemeta.h
106    quark.h
107    rpcimpl.h
108    tr-getopt.h
109    transmission.h
110    utils.h
111    variant.h
112    watchdir.h
113    web.h
114    ${PROJECT_BINARY_DIR}/version.h
115)
116
117set(${PROJECT_NAME}_PRIVATE_HEADERS
118    announcer-common.h
119    announcer.h
120    bandwidth.h
121    bitfield.h
122    blocklist.h
123    cache.h
124    clients.h
125    completion.h
126    ConvertUTF.h
127    crypto.h
128    crypto-utils.h
129    fdlimit.h
130    handshake.h
131    history.h
132    inout.h
133    list.h
134    magnet.h
135    metainfo.h
136    natpmp_local.h
137    net.h
138    peer-common.h
139    peer-io.h
140    peer-mgr.h
141    peer-msgs.h
142    platform.h
143    platform-quota.h
144    port-forwarding.h
145    ptrarray.h
146    resume.h
147    rpc-server.h
148    session.h
149    stats.h
150    torrent.h
151    torrent-magnet.h
152    tr-dht.h
153    trevent.h
154    tr-lpd.h
155    tr-udp.h
156    tr-utp.h
157    upnp.h
158    variant-common.h
159    verify.h
160    version.h
161    watchdir-common.h
162    webseed.h
163)
164
165if(NOT ENABLE_UTP)
166    set_source_files_properties(tr-utp.c PROPERTIES HEADER_FILE_ONLY ON)
167endif()
168
169add_definitions(
170    -D__TRANSMISSION__
171    "-DPACKAGE_DATA_DIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}\""
172    ${NATPMP_DEFINITIONS}
173    ${MINIUPNPC_DEFINITIONS}
174)
175
176if(ENABLE_LIGHTWEIGHT)
177    add_definitions(-DTR_LIGHTWEIGHT)
178endif()
179
180if(NOT ENABLE_NLS)
181    add_definitions(-DDISABLE_GETTEXT)
182endif()
183
184if(ENABLE_UTP)
185    add_definitions(-DWITH_UTP)
186endif()
187
188if(MINIUPNPC_VERSION VERSION_LESS 1.7)
189    # API version macro was only added in 1.7
190    add_definitions(-DMINIUPNPC_API_VERSION=${MINIUPNPC_API_VERSION})
191endif()
192
193if(USE_SYSTEM_B64)
194    add_definitions(-DUSE_SYSTEM_B64)
195endif()
196
197include_directories(
198    ${PROJECT_SOURCE_DIR}
199    ${PROJECT_BINARY_DIR}
200    ${ZLIB_INCLUDE_DIRS}
201    ${CRYPTO_INCLUDE_DIRS}
202    ${CURL_INCLUDE_DIRS}
203    ${EVENT2_INCLUDE_DIRS}
204    ${NATPMP_INCLUDE_DIRS}
205    ${MINIUPNPC_INCLUDE_DIRS}
206    ${DHT_INCLUDE_DIRS}
207    ${UTP_INCLUDE_DIRS}
208    ${B64_INCLUDE_DIRS}
209)
210
211if(ICONV_FOUND)
212    include_directories(${ICONV_INCLUDE_DIRS})
213endif()
214
215if(ENABLE_UTP)
216    include_directories(${TP_TOP}/libutp)
217endif()
218
219add_library(${TR_NAME} STATIC
220    ${${PROJECT_NAME}_SOURCES}
221    ${${PROJECT_NAME}_PUBLIC_HEADERS}
222    ${${PROJECT_NAME}_PRIVATE_HEADERS}
223)
224
225foreach(UT ${EVENT2_UPSTREAM_TARGET}
226           ${NATPMP_UPSTREAM_TARGET}
227           ${MINIUPNPC_UPSTREAM_TARGET}
228           ${DHT_UPSTREAM_TARGET}
229           ${UTP_UPSTREAM_TARGET}
230           ${B64_UPSTREAM_TARGET})
231    add_dependencies(${TR_NAME} ${UT})
232endforeach()
233
234target_link_libraries(${TR_NAME}
235    ${CMAKE_THREAD_LIBS_INIT}
236    ${ZLIB_LIBRARIES}
237    ${CRYPTO_LIBRARIES}
238    ${CURL_LIBRARIES}
239    ${EVENT2_LIBRARIES}
240    ${NATPMP_LIBRARIES}
241    ${MINIUPNPC_LIBRARIES}
242    ${DHT_LIBRARIES}
243    ${UTP_LIBRARIES}
244    ${B64_LIBRARIES}
245    ${LIBINTL_LIBRARY}
246    ${LIBM_LIBRARY}
247)
248
249if(ICONV_FOUND)
250    target_link_libraries(${TR_NAME} ${ICONV_LIBRARIES})
251endif()
252
253if(WIN32)
254    target_link_libraries(${TR_NAME} iphlpapi ws2_32)
255endif()
256
257if(ENABLE_TESTS)
258    add_library(${TR_NAME}-test STATIC
259        libtransmission-test.c
260        libtransmission-test.h
261    )
262
263    target_link_libraries(${TR_NAME}-test ${TR_NAME})
264    set_property(TARGET ${TR_NAME}-test PROPERTY FOLDER "UnitTests")
265
266    set(crypto-test_ADD_SOURCES crypto-test-ref.h)
267
268    set(watchdir@generic-test_DEFINITIONS WATCHDIR_TEST_FORCE_GENERIC)
269
270    foreach(T bitfield blocklist clients crypto error file history json magnet metainfo move peer-msgs quark rename rpc session
271              tr-getopt utils variant watchdir watchdir@generic)
272        set(TP ${TR_NAME}-test-${T})
273        if(T MATCHES "^([^@]+)@.+$")
274            string(REPLACE "@" "_" TP "${TP}")
275            set(${TP}_TEST_BASENAME "${CMAKE_MATCH_1}")
276        else()
277            set(${TP}_TEST_BASENAME "${T}")
278        endif()
279        add_executable(${TP} ${${TP}_TEST_BASENAME}-test.c ${${T}-test_ADD_SOURCES})
280        target_link_libraries(${TP} ${TR_NAME} ${TR_NAME}-test)
281        if(DEFINED ${T}-test_DEFINITIONS)
282            target_compile_definitions(${TP} PRIVATE ${${T}-test_DEFINITIONS})
283        endif()
284        add_test(NAME ${T} COMMAND ${TP})
285        set_property(TARGET ${TP} PROPERTY FOLDER "UnitTests")
286    endforeach()
287endif()
288
289if(INSTALL_LIB)
290    install(TARGETS ${TR_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
291    install(FILES ${${PROJECT_NAME}_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TR_NAME})
292endif()
Note: See TracBrowser for help on using the repository browser.