source: trunk/libtransmission/CMakeLists.txt @ 14367

Last change on this file since 14367 was 14367, checked in by mikedld, 8 years ago

#5369: Improve file allocation error checking (initial patch by g.proskurin)

Additionally,

  • always close file descriptor on error in cached_file_open (FD leak),
  • only store file descriptor to tr_cached_file on success,
  • call ftruncate after xfsctl-based preallocation so that correct size is reported by the system.
File size: 4.4 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-fallback.c
19    crypto-utils-openssl.c
20    error.c
21    fdlimit.c
22    file.c
23    handshake.c
24    history.c
25    inout.c
26    list.c
27    log.c
28    magnet.c
29    makemeta.c
30    metainfo.c
31    natpmp.c
32    net.c
33    peer-io.c
34    peer-mgr.c
35    peer-msgs.c
36    platform.c
37    platform-quota.c
38    port-forwarding.c
39    ptrarray.c
40    quark.c
41    resume.c
42    rpcimpl.c
43    rpc-server.c
44    session.c
45    stats.c
46    torrent.c
47    torrent-ctor.c
48    torrent-magnet.c
49    tr-dht.c
50    trevent.c
51    tr-getopt.c
52    tr-lpd.c
53    tr-udp.c
54    upnp.c
55    utils.c
56    variant-benc.c
57    variant.c
58    variant-json.c
59    verify.c
60    web.c
61    webseed.c
62    wildmat.c
63)
64
65if(WIN32)
66    list(APPEND ${PROJECT_NAME}_SOURCES file-win32.c)
67else()
68    list(APPEND ${PROJECT_NAME}_SOURCES file-posix.c)
69endif()
70
71set(${PROJECT_NAME}_PUBLIC_HEADERS
72    error.h
73    error-types.h
74    file.h
75    log.h
76    makemeta.h
77    quark.h
78    rpcimpl.h
79    tr-getopt.h
80    transmission.h
81    utils.h
82    variant.h
83    web.h
84    ${PROJECT_BINARY_DIR}/version.h
85)
86
87set(${PROJECT_NAME}_PRIVATE_HEADERS
88    announcer-common.h
89    announcer.h
90    bandwidth.h
91    bitfield.h
92    blocklist.h
93    cache.h
94    clients.h
95    completion.h
96    ConvertUTF.h
97    crypto.h
98    crypto-utils.h
99    fdlimit.h
100    handshake.h
101    history.h
102    inout.h
103    list.h
104    magnet.h
105    metainfo.h
106    natpmp_local.h
107    net.h
108    peer-common.h
109    peer-io.h
110    peer-mgr.h
111    peer-msgs.h
112    platform.h
113    platform-quota.h
114    port-forwarding.h
115    ptrarray.h
116    resume.h
117    rpc-server.h
118    session.h
119    stats.h
120    torrent.h
121    torrent-magnet.h
122    tr-dht.h
123    trevent.h
124    tr-lpd.h
125    tr-udp.h
126    upnp.h
127    variant-common.h
128    verify.h
129    version.h
130    webseed.h
131)
132
133if(ENABLE_UTP)
134    list(APPEND ${PROJECT_NAME}_SOURCES tr-utp.c)
135    list(APPEND ${PROJECT_NAME}_PRIVATE_HEADERS tr-utp.h)
136endif()
137
138add_definitions(
139    -D__TRANSMISSION__
140    "-DPACKAGE_DATA_DIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}\""
141    ${NATPMP_DEFINITIONS}
142    ${MINIUPNPC_DEFINITIONS}
143)
144
145if(ENABLE_LIGHTWEIGHT)
146    add_definitions(-DTR_LIGHTWEIGHT)
147endif()
148
149if(NOT ENABLE_NLS)
150    add_definitions(-DDISABLE_GETTEXT)
151endif()
152
153if(ENABLE_UTP)
154    add_definitions(-DWITH_UTP)
155endif()
156
157if(MINIUPNPC_VERSION VERSION_LESS 1.7)
158    # API version macro was only added in 1.7
159    add_definitions(-DMINIUPNPC_API_VERSION=${MINIUPNPC_API_VERSION})
160endif()
161
162include_directories(
163    ${PROJECT_SOURCE_DIR}
164    ${PROJECT_BINARY_DIR}
165    ${ZLIB_INCLUDE_DIRS}
166    ${OPENSSL_INCLUDE_DIRS}
167    ${CURL_INCLUDE_DIRS}
168    ${ICONV_INCLUDE_DIRS}
169    ${EVENT2_INCLUDE_DIRS}
170    ${NATPMP_INCLUDE_DIRS}
171    ${MINIUPNPC_INCLUDE_DIRS}
172    ${DHT_INCLUDE_DIRS}
173    ${UTP_INCLUDE_DIRS}
174)
175
176if(ENABLE_UTP)
177    include_directories(${TP_TOP}/libutp)
178endif()
179
180add_library(${TR_NAME} STATIC
181    ${${PROJECT_NAME}_SOURCES}
182    ${${PROJECT_NAME}_PUBLIC_HEADERS}
183    ${${PROJECT_NAME}_PRIVATE_HEADERS}
184)
185
186foreach(UT ${EVENT2_UPSTREAM_TARGET}
187           ${NATPMP_UPSTREAM_TARGET}
188           ${MINIUPNPC_UPSTREAM_TARGET}
189           ${DHT_UPSTREAM_TARGET}
190           ${UTP_UPSTREAM_TARGET})
191    add_dependencies(${TR_NAME} ${UT})
192endforeach()
193
194target_link_libraries(${TR_NAME}
195    ${CMAKE_THREAD_LIBS_INIT}
196    ${ZLIB_LIBRARIES}
197    ${OPENSSL_LIBRARIES}
198    ${CURL_LIBRARIES}
199    ${ICONV_LIBRARIES}
200    ${EVENT2_LIBRARIES}
201    ${NATPMP_LIBRARIES}
202    ${MINIUPNPC_LIBRARIES}
203    ${DHT_LIBRARIES}
204    ${UTP_LIBRARIES}
205    ${LIBM_LIBRARY}
206)
207
208if(WIN32)
209    target_link_libraries(${TR_NAME} iphlpapi ws2_32)
210endif()
211
212if(ENABLE_TESTS)
213    add_library(${TR_NAME}-test STATIC
214        libtransmission-test.c
215        libtransmission-test.h
216    )
217
218    target_link_libraries(${TR_NAME}-test ${TR_NAME})
219
220    foreach(T bitfield blocklist clients crypto error file history json magnet metainfo move peer-msgs quark rename rpc session tr-getopt utils variant)
221        set(TP ${TR_NAME}-test-${T})
222        add_executable(${TP} ${T}-test.c)
223        target_link_libraries(${TP} ${TR_NAME} ${TR_NAME}-test)
224        add_test(${T} ${TP})
225    endforeach()
226endif()
227
228if(INSTALL_LIB)
229    install(TARGETS ${TR_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
230    install(FILES ${${PROJECT_NAME}_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TR_NAME})
231endif()
Note: See TracBrowser for help on using the repository browser.