blob: 721053ae05b538d925c3e666ea1e0bc9bf9e3616 [file] [log] [blame]
Pascal Bachd5f87e12014-12-12 15:59:17 +01001#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19
Roger Meier5af78c82015-04-12 21:43:12 +020020
Pascal Bachd5f87e12014-12-12 15:59:17 +010021# Find required packages
22set(Boost_USE_STATIC_LIBS ON) # Force the use of static boost test framework
23find_package(Boost 1.53.0 REQUIRED COMPONENTS unit_test_framework)
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +090024include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
Pascal Bachd5f87e12014-12-12 15:59:17 +010025
26#Make sure gen-cpp files can be included
27include_directories("${CMAKE_CURRENT_BINARY_DIR}")
28
29# Create the thrift C++ test library
30set(testgencpp_SOURCES
31 gen-cpp/DebugProtoTest_types.cpp
32 gen-cpp/DebugProtoTest_types.h
33 gen-cpp/EnumTest_types.cpp
34 gen-cpp/EnumTest_types.h
35 gen-cpp/OptionalRequiredTest_types.cpp
36 gen-cpp/OptionalRequiredTest_types.h
37 gen-cpp/Recursive_types.cpp
38 gen-cpp/Recursive_types.h
39 gen-cpp/ThriftTest_types.cpp
40 gen-cpp/ThriftTest_types.h
41 gen-cpp/TypedefTest_types.cpp
42 gen-cpp/TypedefTest_types.h
43 ThriftTest_extras.cpp
44 DebugProtoTest_extras.cpp
45)
46
47add_library(testgencpp STATIC ${testgencpp_SOURCES})
48target_link_libraries(testgencpp thrift)
49
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +090050set(testgencpp_cob_SOURCES
Pascal Bachd5f87e12014-12-12 15:59:17 +010051 gen-cpp/ChildService.cpp
52 gen-cpp/ChildService.h
53 gen-cpp/ParentService.cpp
54 gen-cpp/ParentService.h
55 gen-cpp/proc_types.cpp
56 gen-cpp/proc_types.h
57)
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +090058add_library(testgencpp_cob STATIC ${testgencpp_cob_SOURCES})
59target_link_libraries(testgencpp_cob thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +010060
61
62add_executable(Benchmark Benchmark.cpp)
63target_link_libraries(Benchmark testgencpp)
64add_test(NAME Benchmark COMMAND Benchmark)
65
66set(UnitTest_SOURCES
67 UnitTestMain.cpp
68 TMemoryBufferTest.cpp
69 TBufferBaseTest.cpp
70 Base64Test.cpp
71 ToStringTest.cpp
72 TypedefTest.cpp
Roger Meier3815e0b2015-04-04 16:26:30 +020073 TServerSocketTest.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010074)
75
76if(NOT WITH_BOOSTTHREADS AND NOT WITH_STDTHREADS)
77 list(APPEND UnitTest_SOURCES RWMutexStarveTest.cpp)
78endif()
79
80add_executable(UnitTests ${UnitTest_SOURCES})
81target_link_libraries(UnitTests testgencpp thrift ${Boost_LIBRARIES})
82add_test(NAME UnitTests COMMAND UnitTests)
83
84
85if(WITH_ZLIB)
86add_executable(TransportTest TransportTest.cpp)
87target_link_libraries(TransportTest
88 testgencpp
89 thriftz
90 ${Boost_LIBRARIES}
91 ${ZLIB_LIBRARIES}
92)
93add_test(NAME TransportTest COMMAND TransportTest)
94
95add_executable(ZlibTest ZlibTest.cpp)
96target_link_libraries(ZlibTest
97 testgencpp
98 thriftz
99 ${Boost_LIBRARIES}
100 ${ZLIB_LIBRARIES}
101)
102add_test(NAME ZlibTest COMMAND ZlibTest)
103endif(WITH_ZLIB)
104
105
106add_executable(EnumTest EnumTest.cpp)
107target_link_libraries(EnumTest
108 testgencpp
109 ${Boost_LIBRARIES}
110)
111add_test(NAME EnumTest COMMAND EnumTest)
112
113add_executable(TFileTransportTest TFileTransportTest.cpp)
114target_link_libraries(TFileTransportTest
115 testgencpp
116 ${Boost_LIBRARIES}
117)
118add_test(NAME TFileTransportTest COMMAND TFileTransportTest)
119
120add_executable(TFDTransportTest TFDTransportTest.cpp)
121target_link_libraries(TFDTransportTest
122 thrift
123)
124add_test(NAME TFDTransportTest COMMAND TFDTransportTest)
125
126add_executable(TPipedTransportTest TPipedTransportTest.cpp)
127target_link_libraries(TPipedTransportTest
128 thrift
129)
130add_test(NAME TPipedTransportTest COMMAND TPipedTransportTest)
131
132set(AllProtocolsTest_SOURCES
133 AllProtocolTests.cpp
134 AllProtocolTests.tcc
135 GenericHelpers
136 )
137
138add_executable(AllProtocolsTest ${AllProtocolsTest_SOURCES})
139target_link_libraries(AllProtocolsTest
140 testgencpp
141)
142add_test(NAME AllProtocolsTest COMMAND AllProtocolsTest)
143
144add_executable(DebugProtoTest DebugProtoTest.cpp)
145target_link_libraries(DebugProtoTest
146 testgencpp
147)
148add_test(NAME DebugProtoTest COMMAND DebugProtoTest)
149
150add_executable(JSONProtoTest JSONProtoTest.cpp)
151target_link_libraries(JSONProtoTest
152 testgencpp
153)
154add_test(NAME JSONProtoTest COMMAND JSONProtoTest)
155
156add_executable(OptionalRequiredTest OptionalRequiredTest.cpp)
157target_link_libraries(OptionalRequiredTest
158 testgencpp
159)
160add_test(NAME OptionalRequiredTest COMMAND OptionalRequiredTest)
161
162add_executable(RecursiveTest RecursiveTest.cpp)
163target_link_libraries(RecursiveTest
164 testgencpp
165)
166add_test(NAME RecursiveTest COMMAND RecursiveTest)
167
168add_executable(SpecializationTest SpecializationTest.cpp)
169target_link_libraries(SpecializationTest
170 testgencpp
171)
172add_test(NAME SpecializationTest COMMAND SpecializationTest)
173
174set(concurrency_test_SOURCES
175 concurrency/Tests.cpp
176 concurrency/ThreadFactoryTests.h
177 concurrency/ThreadManagerTests.h
178 concurrency/TimerManagerTests.h
179)
180add_executable(concurrency_test ${concurrency_test_SOURCES})
181target_link_libraries(concurrency_test
182 thrift
183)
184add_test(NAME concurrency_test COMMAND concurrency_test)
185
186set(link_test_SOURCES
187 link/LinkTest.cpp
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900188 gen-cpp/ParentService.h
Pascal Bachd5f87e12014-12-12 15:59:17 +0100189 link/TemplatedService1.cpp
190 link/TemplatedService2.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100191)
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900192
Pascal Bachd5f87e12014-12-12 15:59:17 +0100193add_executable(link_test ${link_test_SOURCES})
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900194target_link_libraries(concurrency_test testgencpp_cob thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100195add_test(NAME link_test COMMAND link_test)
196
197if(WITH_LIBEVENT)
198set(processor_test_SOURCES
199 processor/ProcessorTest.cpp
200 processor/EventLog.cpp
201 processor/ServerThread.cpp
202 processor/EventLog.h
203 processor/Handlers.h
204 processor/ServerThread.h
205)
206add_executable(processor_test ${processor_test_SOURCES})
207target_link_libraries(processor_test
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900208 testgencpp_cob
Pascal Bachd5f87e12014-12-12 15:59:17 +0100209 thrift
210 thriftnb
211 ${Boost_LIBRARIES}
212)
213add_test(NAME processor_test COMMAND processor_test)
Nobuaki Sukegawa8016af82015-01-02 23:14:22 +0900214
215set(TNonblockingServerTest_SOURCES TNonblockingServerTest.cpp)
216add_executable(TNonblockingServerTest ${TNonblockingServerTest_SOURCES})
217include_directories(${LIBEVENT_INCLUDE_DIRS})
218target_link_libraries(TNonblockingServerTest
219 testgencpp_cob
220 thrift
221 thriftnb
222 ${LIBEVENT_LIBRARIES}
223 ${Boost_LIBRARIES}
224)
225add_test(NAME TNonblockingServerTest COMMAND TNonblockingServerTest)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100226endif()
227
228if(OPENSSL_FOUND AND WITH_OPENSSL)
229add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp)
230target_link_libraries(OpenSSLManualInitTest
231 thrift
232 ${OPENSSL_LIBRARIES}
233 ${Boost_LIBRARIES}
234)
235add_test(NAME OpenSSLManualInitTest COMMAND OpenSSLManualInitTest)
236endif()
237
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900238if(WITH_QT4)
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900239set(CMAKE_AUTOMOC ON)
240find_package(Qt4 REQUIRED COMPONENTS QtTest)
241set(TQTcpServerTest_SOURCES
242 qt/TQTcpServerTest.cpp
243)
244add_executable(TQTcpServerTest ${TQTcpServerTest_SOURCES})
245target_link_libraries(TQTcpServerTest testgencpp_cob thriftqt thrift Qt4::QtTest)
246add_test(NAME TQTcpServerTest COMMAND TQTcpServerTest)
247endif()
248
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900249if(WITH_QT5)
250add_subdirectory(qt)
251endif()
252
Pascal Bachd5f87e12014-12-12 15:59:17 +0100253#
254# Common thrift code generation rules
255#
256
257
258add_custom_command(OUTPUT gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h
259 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift
260)
261
262add_custom_command(OUTPUT gen-cpp/EnumTest_types.cpp gen-cpp/EnumTest_types.h
263 COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/EnumTest.thrift
264)
265
266add_custom_command(OUTPUT gen-cpp/TypedefTest_types.cpp gen-cpp/TypedefTest_types.h
267 COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/TypedefTest.thrift
268)
269
270add_custom_command(OUTPUT gen-cpp/OptionalRequiredTest_types.cpp gen-cpp/OptionalRequiredTest_types.h
271 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift
272)
273
274add_custom_command(OUTPUT gen-cpp/Recursive_types.cpp gen-cpp/Recursive_types.h
275 COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/Recursive.thrift
276)
277
278add_custom_command(OUTPUT gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp
279 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/StressTest.thrift
280)
281
282add_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
283 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
284)
285
286add_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
287 COMMAND thrift-compiler --gen cpp:templates,cob_style ${CMAKE_CURRENT_SOURCE_DIR}/processor/proc.thrift
288)