blob: 9a7d2455f3691b89a7f4791a4e0cbc3642a2a40d [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
20
21# 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)
24include_directories("${Boost_INCLUDE_DIR}")
25
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
73)
74
75if(NOT WITH_BOOSTTHREADS AND NOT WITH_STDTHREADS)
76 list(APPEND UnitTest_SOURCES RWMutexStarveTest.cpp)
77endif()
78
79add_executable(UnitTests ${UnitTest_SOURCES})
80target_link_libraries(UnitTests testgencpp thrift ${Boost_LIBRARIES})
81add_test(NAME UnitTests COMMAND UnitTests)
82
83
84if(WITH_ZLIB)
85add_executable(TransportTest TransportTest.cpp)
86target_link_libraries(TransportTest
87 testgencpp
88 thriftz
89 ${Boost_LIBRARIES}
90 ${ZLIB_LIBRARIES}
91)
92add_test(NAME TransportTest COMMAND TransportTest)
93
94add_executable(ZlibTest ZlibTest.cpp)
95target_link_libraries(ZlibTest
96 testgencpp
97 thriftz
98 ${Boost_LIBRARIES}
99 ${ZLIB_LIBRARIES}
100)
101add_test(NAME ZlibTest COMMAND ZlibTest)
102endif(WITH_ZLIB)
103
104
105add_executable(EnumTest EnumTest.cpp)
106target_link_libraries(EnumTest
107 testgencpp
108 ${Boost_LIBRARIES}
109)
110add_test(NAME EnumTest COMMAND EnumTest)
111
112add_executable(TFileTransportTest TFileTransportTest.cpp)
113target_link_libraries(TFileTransportTest
114 testgencpp
115 ${Boost_LIBRARIES}
116)
117add_test(NAME TFileTransportTest COMMAND TFileTransportTest)
118
119add_executable(TFDTransportTest TFDTransportTest.cpp)
120target_link_libraries(TFDTransportTest
121 thrift
122)
123add_test(NAME TFDTransportTest COMMAND TFDTransportTest)
124
125add_executable(TPipedTransportTest TPipedTransportTest.cpp)
126target_link_libraries(TPipedTransportTest
127 thrift
128)
129add_test(NAME TPipedTransportTest COMMAND TPipedTransportTest)
130
131set(AllProtocolsTest_SOURCES
132 AllProtocolTests.cpp
133 AllProtocolTests.tcc
134 GenericHelpers
135 )
136
137add_executable(AllProtocolsTest ${AllProtocolsTest_SOURCES})
138target_link_libraries(AllProtocolsTest
139 testgencpp
140)
141add_test(NAME AllProtocolsTest COMMAND AllProtocolsTest)
142
143add_executable(DebugProtoTest DebugProtoTest.cpp)
144target_link_libraries(DebugProtoTest
145 testgencpp
146)
147add_test(NAME DebugProtoTest COMMAND DebugProtoTest)
148
149add_executable(JSONProtoTest JSONProtoTest.cpp)
150target_link_libraries(JSONProtoTest
151 testgencpp
152)
153add_test(NAME JSONProtoTest COMMAND JSONProtoTest)
154
155add_executable(OptionalRequiredTest OptionalRequiredTest.cpp)
156target_link_libraries(OptionalRequiredTest
157 testgencpp
158)
159add_test(NAME OptionalRequiredTest COMMAND OptionalRequiredTest)
160
161add_executable(RecursiveTest RecursiveTest.cpp)
162target_link_libraries(RecursiveTest
163 testgencpp
164)
165add_test(NAME RecursiveTest COMMAND RecursiveTest)
166
167add_executable(SpecializationTest SpecializationTest.cpp)
168target_link_libraries(SpecializationTest
169 testgencpp
170)
171add_test(NAME SpecializationTest COMMAND SpecializationTest)
172
173set(concurrency_test_SOURCES
174 concurrency/Tests.cpp
175 concurrency/ThreadFactoryTests.h
176 concurrency/ThreadManagerTests.h
177 concurrency/TimerManagerTests.h
178)
179add_executable(concurrency_test ${concurrency_test_SOURCES})
180target_link_libraries(concurrency_test
181 thrift
182)
183add_test(NAME concurrency_test COMMAND concurrency_test)
184
185set(link_test_SOURCES
186 link/LinkTest.cpp
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900187 gen-cpp/ParentService.h
Pascal Bachd5f87e12014-12-12 15:59:17 +0100188 link/TemplatedService1.cpp
189 link/TemplatedService2.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100190)
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900191
Pascal Bachd5f87e12014-12-12 15:59:17 +0100192add_executable(link_test ${link_test_SOURCES})
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900193target_link_libraries(concurrency_test testgencpp_cob thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100194add_test(NAME link_test COMMAND link_test)
195
196if(WITH_LIBEVENT)
197set(processor_test_SOURCES
198 processor/ProcessorTest.cpp
199 processor/EventLog.cpp
200 processor/ServerThread.cpp
201 processor/EventLog.h
202 processor/Handlers.h
203 processor/ServerThread.h
204)
205add_executable(processor_test ${processor_test_SOURCES})
206target_link_libraries(processor_test
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900207 testgencpp_cob
Pascal Bachd5f87e12014-12-12 15:59:17 +0100208 thrift
209 thriftnb
210 ${Boost_LIBRARIES}
211)
212add_test(NAME processor_test COMMAND processor_test)
213endif()
214
215if(OPENSSL_FOUND AND WITH_OPENSSL)
216add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp)
217target_link_libraries(OpenSSLManualInitTest
218 thrift
219 ${OPENSSL_LIBRARIES}
220 ${Boost_LIBRARIES}
221)
222add_test(NAME OpenSSLManualInitTest COMMAND OpenSSLManualInitTest)
223endif()
224
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900225if(WITH_QT4)
226cmake_minimum_required(VERSION 2.8.12)
227set(CMAKE_AUTOMOC ON)
228find_package(Qt4 REQUIRED COMPONENTS QtTest)
229set(TQTcpServerTest_SOURCES
230 qt/TQTcpServerTest.cpp
231)
232add_executable(TQTcpServerTest ${TQTcpServerTest_SOURCES})
233target_link_libraries(TQTcpServerTest testgencpp_cob thriftqt thrift Qt4::QtTest)
234add_test(NAME TQTcpServerTest COMMAND TQTcpServerTest)
235endif()
236
Pascal Bachd5f87e12014-12-12 15:59:17 +0100237#
238# Common thrift code generation rules
239#
240
241
242add_custom_command(OUTPUT gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h
243 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift
244)
245
246add_custom_command(OUTPUT gen-cpp/EnumTest_types.cpp gen-cpp/EnumTest_types.h
247 COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/EnumTest.thrift
248)
249
250add_custom_command(OUTPUT gen-cpp/TypedefTest_types.cpp gen-cpp/TypedefTest_types.h
251 COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/TypedefTest.thrift
252)
253
254add_custom_command(OUTPUT gen-cpp/OptionalRequiredTest_types.cpp gen-cpp/OptionalRequiredTest_types.h
255 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift
256)
257
258add_custom_command(OUTPUT gen-cpp/Recursive_types.cpp gen-cpp/Recursive_types.h
259 COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/Recursive.thrift
260)
261
262add_custom_command(OUTPUT gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp
263 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/StressTest.thrift
264)
265
266add_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
267 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
268)
269
270add_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
271 COMMAND thrift-compiler --gen cpp:templates,cob_style ${CMAKE_CURRENT_SOURCE_DIR}/processor/proc.thrift
272)