File: CMakeLists.txt

package info (click to toggle)
thrift 0.22.0-3
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 29,588 kB
  • sloc: cpp: 103,295; java: 26,996; ansic: 21,793; pascal: 15,437; php: 12,823; cs: 10,610; python: 9,733; javascript: 9,274; ruby: 8,316; erlang: 7,360; sh: 5,569; makefile: 4,203; perl: 3,351; yacc: 1,145; xml: 1,079; ml: 962; lisp: 664; lex: 322
file content (427 lines) | stat: -rw-r--r-- 14,723 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# Unit tests still require boost
include(BoostMacros)
REQUIRE_BOOST_HEADERS()
set(BOOST_COMPONENTS filesystem thread unit_test_framework chrono)
REQUIRE_BOOST_LIBRARIES(BOOST_COMPONENTS)

include(ThriftMacros)

# Make sure gen-cpp files can be included
include_directories("${CMAKE_CURRENT_BINARY_DIR}")

# Create the thrift C++ test library
set(testgencpp_SOURCES
    gen-cpp/AnnotationTest_types.cpp
    gen-cpp/AnnotationTest_types.h
    gen-cpp/DebugProtoTest_types.cpp
    gen-cpp/DebugProtoTest_types.h
    gen-cpp/EnumTest_types.cpp
    gen-cpp/EnumTest_types.h
    gen-cpp/OptionalRequiredTest_types.cpp
    gen-cpp/OptionalRequiredTest_types.h
    gen-cpp/Recursive_types.cpp
    gen-cpp/Recursive_types.h
    gen-cpp/ThriftTest_types.cpp
    gen-cpp/ThriftTest_types.h
    gen-cpp/OneWayTest_types.h
    gen-cpp/OneWayService.cpp
    gen-cpp/OneWayService.h
    gen-cpp/TypedefTest_types.cpp
    gen-cpp/TypedefTest_types.h
    gen-cpp/Thrift5272_types.cpp
    gen-cpp/Thrift5272_types.h
    ThriftTest_extras.cpp
    DebugProtoTest_extras.cpp
)

add_library(testgencpp STATIC ${testgencpp_SOURCES})

set(testgencpp_cob_SOURCES
    gen-cpp/ChildService.cpp
    gen-cpp/ChildService.h
    gen-cpp/EmptyService.cpp
    gen-cpp/EmptyService.h
    gen-cpp/ParentService.cpp
    gen-cpp/ParentService.h
    gen-cpp/proc_types.cpp
    gen-cpp/proc_types.h
)
add_library(testgencpp_cob STATIC ${testgencpp_cob_SOURCES})

add_executable(Benchmark Benchmark.cpp)
target_link_libraries(Benchmark testgencpp)
target_link_libraries(Benchmark thrift)
add_test(NAME Benchmark COMMAND Benchmark)
target_link_libraries(Benchmark testgencpp)

set(UnitTest_SOURCES
    UnitTestMain.cpp
    OneWayHTTPTest.cpp
    TMemoryBufferTest.cpp
    TBufferBaseTest.cpp
    Base64Test.cpp
    ToStringTest.cpp
    TypedefTest.cpp
    TServerSocketTest.cpp
    TServerTransportTest.cpp
    ThrifttReadCheckTests.cpp
    TUuidTest.cpp
    Thrift5272.cpp
)

add_executable(UnitTests ${UnitTest_SOURCES})
target_link_libraries(UnitTests testgencpp ${Boost_LIBRARIES})
target_link_libraries(UnitTests thrift)
add_test(NAME UnitTests COMMAND UnitTests)
if(MSVC)
    # Disable C4503: decorated name length exceeded, name was truncated
    # 'insanity' results in very long decorated names
    set_property( TARGET UnitTests APPEND_STRING PROPERTY COMPILE_FLAGS /wd4503 )
endif()

# Test the THRIFT_TUUID_SUPPORT_BOOST_UUID compiler directive globally set on the target
add_executable(UnitTestsUuid
    UnitTestMain.cpp
    TUuidTestBoost.cpp
)
target_link_libraries(UnitTestsUuid testgencpp ${Boost_LIBRARIES})
target_link_libraries(UnitTestsUuid thrift)
target_compile_definitions(UnitTestsUuid PUBLIC THRIFT_TUUID_SUPPORT_BOOST_UUID)
add_test(NAME UnitTestsUuid COMMAND UnitTestsUuid)

# Test not setting the THRIFT_TUUID_SUPPORT_BOOST_UUID compiler directive as with the test above.
# The test does set the directive before including the thrift header to test the behaviour
add_executable(UnitTestsUuidNoDirective
    UnitTestMain.cpp
    TUuidTestBoostNoDirective.cpp
)
target_link_libraries(UnitTestsUuidNoDirective testgencpp ${Boost_LIBRARIES})
target_link_libraries(UnitTestsUuidNoDirective thrift)
add_test(NAME UnitTestsUuidNoDirective COMMAND UnitTestsUuidNoDirective)

set( TInterruptTest_SOURCES
     TSocketInterruptTest.cpp
     TSSLSocketInterruptTest.cpp
)
if (WIN32)
    list(APPEND TInterruptTest_SOURCES
        TPipeInterruptTest.cpp
    )
endif()
add_executable(TInterruptTest ${TInterruptTest_SOURCES})
target_link_libraries(TInterruptTest
    testgencpp
    ${Boost_LIBRARIES}
)
target_link_libraries(TInterruptTest thrift)
if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD" AND NOT MINGW)
    target_link_libraries(TInterruptTest -lrt)
endif ()
add_test(NAME TInterruptTest COMMAND TInterruptTest -- "${CMAKE_CURRENT_SOURCE_DIR}/../../../test/keys")

add_executable(TServerIntegrationTest TServerIntegrationTest.cpp)
target_link_libraries(TServerIntegrationTest
    testgencpp_cob
    ${Boost_LIBRARIES}
)
target_link_libraries(TServerIntegrationTest thrift)
if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD" AND NOT MINGW)
    target_link_libraries(TServerIntegrationTest -lrt)
endif ()
add_test(NAME TServerIntegrationTest COMMAND TServerIntegrationTest)

if(WITH_ZLIB)
include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
add_executable(TransportTest TransportTest.cpp)
target_link_libraries(TransportTest
    testgencpp
    ${Boost_LIBRARIES}
    ${ZLIB_LIBRARIES}
)
target_link_libraries(TransportTest thrift)
target_link_libraries(TransportTest thriftz)
add_test(NAME TransportTest COMMAND TransportTest)

add_executable(ZlibTest ZlibTest.cpp)
target_link_libraries(ZlibTest
    testgencpp
    ${Boost_LIBRARIES}
    ${ZLIB_LIBRARIES}
)
target_link_libraries(ZlibTest thrift)
target_link_libraries(ZlibTest thriftz)
add_test(NAME ZlibTest COMMAND ZlibTest)
endif(WITH_ZLIB)

add_executable(AnnotationTest AnnotationTest.cpp)
target_link_libraries(AnnotationTest
    testgencpp
    ${Boost_LIBRARIES}
)
target_link_libraries(AnnotationTest thrift)
add_test(NAME AnnotationTest COMMAND AnnotationTest)

add_executable(EnumTest EnumTest.cpp)
target_link_libraries(EnumTest
    testgencpp
    ${Boost_LIBRARIES}
)
target_link_libraries(EnumTest thrift)
add_test(NAME EnumTest COMMAND EnumTest)

if(HAVE_GETOPT_H)
add_executable(TFileTransportTest TFileTransportTest.cpp)
target_link_libraries(TFileTransportTest
    testgencpp
    ${Boost_LIBRARIES}
)
target_link_libraries(TFileTransportTest thrift)
add_test(NAME TFileTransportTest COMMAND TFileTransportTest)
endif()

add_executable(TFDTransportTest TFDTransportTest.cpp)
target_link_libraries(TFDTransportTest
    ${Boost_LIBRARIES}
)
target_link_libraries(TFDTransportTest thrift)
add_test(NAME TFDTransportTest COMMAND TFDTransportTest)

add_executable(TPipedTransportTest TPipedTransportTest.cpp)
target_link_libraries(TPipedTransportTest
    ${Boost_LIBRARIES}
)
target_link_libraries(TPipedTransportTest thrift)
add_test(NAME TPipedTransportTest COMMAND TPipedTransportTest)

set(AllProtocolsTest_SOURCES
    AllProtocolTests.cpp
    AllProtocolTests.tcc
    GenericHelpers.h
)

add_executable(AllProtocolsTest ${AllProtocolsTest_SOURCES})
target_link_libraries(AllProtocolsTest
    testgencpp
    ${Boost_LIBRARIES}
)
target_link_libraries(AllProtocolsTest thrift)
add_test(NAME AllProtocolsTest COMMAND AllProtocolsTest)

# The debug run-time in Windows asserts on isprint() with negative inputs
if (NOT MSVC OR (MSVC AND CMAKE_BUILD_TYPE EQUAL "DEBUG"))
    add_executable(DebugProtoTest DebugProtoTest.cpp)
    target_link_libraries(DebugProtoTest
        testgencpp
        ${Boost_LIBRARIES}
    )
    target_link_libraries(DebugProtoTest thrift)
    add_test(NAME DebugProtoTest COMMAND DebugProtoTest)
endif()

add_executable(JSONProtoTest JSONProtoTest.cpp)
target_link_libraries(JSONProtoTest
    testgencpp
    ${Boost_LIBRARIES}
)
target_link_libraries(JSONProtoTest thrift)
add_test(NAME JSONProtoTest COMMAND JSONProtoTest)

add_executable(OptionalRequiredTest OptionalRequiredTest.cpp)
target_link_libraries(OptionalRequiredTest
    testgencpp
    ${Boost_LIBRARIES}
)
target_link_libraries(OptionalRequiredTest thrift)
add_test(NAME OptionalRequiredTest COMMAND OptionalRequiredTest)

add_executable(RecursiveTest RecursiveTest.cpp)
target_link_libraries(RecursiveTest
    testgencpp
    ${Boost_LIBRARIES}
)
target_link_libraries(RecursiveTest thrift)
add_test(NAME RecursiveTest COMMAND RecursiveTest)

add_executable(SpecializationTest SpecializationTest.cpp)
target_link_libraries(SpecializationTest
    testgencpp
    ${Boost_LIBRARIES}
)
target_link_libraries(SpecializationTest thrift)
add_test(NAME SpecializationTest COMMAND SpecializationTest)

set(concurrency_test_SOURCES
    concurrency/Tests.cpp
    concurrency/ThreadFactoryTests.h
    concurrency/ThreadManagerTests.h
    concurrency/TimerManagerTests.h
)
add_executable(concurrency_test ${concurrency_test_SOURCES})
target_link_libraries(concurrency_test thrift)
add_test(NAME concurrency_test COMMAND concurrency_test)

set(link_test_SOURCES
    link/LinkTest.cpp
    gen-cpp/ParentService.h
    link/TemplatedService1.cpp
    link/TemplatedService2.cpp
)

add_executable(link_test ${link_test_SOURCES})
target_link_libraries(link_test testgencpp_cob)
target_link_libraries(link_test thrift)
target_link_libraries(link_test testgencpp)
add_test(NAME link_test COMMAND link_test)

if(WITH_LIBEVENT)
    set(processor_test_SOURCES
        processor/ProcessorTest.cpp
        processor/EventLog.cpp
        processor/ServerThread.cpp
        processor/EventLog.h
        processor/Handlers.h
        processor/ServerThread.h
    )
    add_executable(processor_test ${processor_test_SOURCES})
    target_link_libraries(processor_test
        testgencpp_cob
        ${Boost_LIBRARIES}
    )
    target_link_libraries(processor_test thriftnb)
    add_test(NAME processor_test COMMAND processor_test)

    set(TNonblockingServerTest_SOURCES TNonblockingServerTest.cpp)
    add_executable(TNonblockingServerTest ${TNonblockingServerTest_SOURCES})
    include_directories(${LIBEVENT_INCLUDE_DIRS})
    target_link_libraries(TNonblockingServerTest
        testgencpp_cob
        ${Boost_LIBRARIES}
    )
    target_link_libraries(TNonblockingServerTest thriftnb)
    add_test(NAME TNonblockingServerTest COMMAND TNonblockingServerTest)

    if(OPENSSL_FOUND AND WITH_OPENSSL)
      set(TNonblockingSSLServerTest_SOURCES TNonblockingSSLServerTest.cpp)
      add_executable(TNonblockingSSLServerTest ${TNonblockingSSLServerTest_SOURCES})
      include_directories(${LIBEVENT_INCLUDE_DIRS})
      target_link_libraries(TNonblockingSSLServerTest
        testgencpp_cob
        ${Boost_LIBRARIES}
      )
      target_link_libraries(TNonblockingSSLServerTest thriftnb)
      add_test(NAME TNonblockingSSLServerTest COMMAND TNonblockingSSLServerTest -- "${CMAKE_CURRENT_SOURCE_DIR}/../../../test/keys")
    endif(OPENSSL_FOUND AND WITH_OPENSSL)
endif()

if(OPENSSL_FOUND AND WITH_OPENSSL)
add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp)
target_link_libraries(OpenSSLManualInitTest
    ${OPENSSL_LIBRARIES}
    ${Boost_LIBRARIES}
)
target_link_libraries(OpenSSLManualInitTest thrift)
add_test(NAME OpenSSLManualInitTest COMMAND OpenSSLManualInitTest)

add_executable(SecurityTest SecurityTest.cpp)
target_link_libraries(SecurityTest
    testgencpp
    ${Boost_LIBRARIES}
)
target_link_libraries(SecurityTest thrift)
if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD" AND NOT MINGW)
    target_link_libraries(SecurityTest -lrt)
endif ()
add_test(NAME SecurityTest COMMAND SecurityTest -- "${CMAKE_CURRENT_SOURCE_DIR}/../../../test/keys")

add_executable(SecurityFromBufferTest SecurityFromBufferTest.cpp)
target_link_libraries(SecurityFromBufferTest
    testgencpp
    ${Boost_LIBRARIES}
)
target_link_libraries(SecurityFromBufferTest thrift)
if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD" AND NOT MINGW)
    target_link_libraries(SecurityFromBufferTest -lrt)
endif ()
add_test(NAME SecurityFromBufferTest COMMAND SecurityFromBufferTest -- "${CMAKE_CURRENT_SOURCE_DIR}/../../../test/keys")

endif()

if(WITH_QT5)
    add_subdirectory(qt)
endif()

#
# Common thrift code generation rules
#
# files from /test
#

add_custom_command(OUTPUT gen-cpp/AnnotationTest_constants.cpp
                          gen-cpp/AnnotationTest_constants.h
                          gen-cpp/AnnotationTest_types.cpp
                          gen-cpp/AnnotationTest_types.h
                          gen-cpp/foo_service.cpp
                          gen-cpp/foo_service.h
    COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/AnnotationTest.thrift
)

add_custom_command(OUTPUT gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h gen-cpp/EmptyService.cpp gen-cpp/EmptyService.h
    COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift
)

add_custom_command(OUTPUT gen-cpp/EnumTest_types.cpp gen-cpp/EnumTest_types.h
    COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/EnumTest.thrift
)

add_custom_command(OUTPUT gen-cpp/TypedefTest_types.cpp gen-cpp/TypedefTest_types.h
    COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/TypedefTest.thrift
)

add_custom_command(OUTPUT gen-cpp/OptionalRequiredTest_types.cpp gen-cpp/OptionalRequiredTest_types.h
    COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift
)

add_custom_command(OUTPUT gen-cpp/Recursive_types.cpp gen-cpp/Recursive_types.h
    COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/Recursive.thrift
)

add_custom_command(OUTPUT gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp
    COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/StressTest.thrift
)

add_custom_command(OUTPUT gen-cpp/SecondService.cpp gen-cpp/ThriftTest_constants.cpp gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_types.h
    COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
)

# files from /lib/cpp/test

add_custom_command(OUTPUT gen-cpp/OneWayService.cpp gen-cpp/OneWayTest_types.h gen-cpp/OneWayService.h
    COMMAND ${THRIFT_COMPILER} --gen cpp ${CMAKE_CURRENT_SOURCE_DIR}/OneWayTest.thrift
)

add_custom_command(OUTPUT gen-cpp/Thrift5272_types.cpp gen-cpp/Thrift5272_types.h
    COMMAND ${THRIFT_COMPILER} --gen cpp ${CMAKE_CURRENT_SOURCE_DIR}/Thrift5272.thrift
)

add_custom_command(OUTPUT gen-cpp/ChildService.cpp gen-cpp/ChildService.h gen-cpp/ParentService.cpp gen-cpp/ParentService.h gen-cpp/proc_types.cpp gen-cpp/proc_types.h
    COMMAND ${THRIFT_COMPILER} --gen cpp:templates,cob_style ${CMAKE_CURRENT_SOURCE_DIR}/processor/proc.thrift
)