blob: ba63a4d359d7d452b900060848fce1bdeafb4096 [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
Pascal Bachd5f87e12014-12-12 15:59:17 +010020# Find required packages
21set(Boost_USE_STATIC_LIBS ON) # Force the use of static boost test framework
22find_package(Boost 1.53.0 REQUIRED COMPONENTS unit_test_framework)
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +090023include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
Pascal Bachd5f87e12014-12-12 15:59:17 +010024
25#Make sure gen-cpp files can be included
26include_directories("${CMAKE_CURRENT_BINARY_DIR}")
27
28# Create the thrift C++ test library
29set(testgencpp_SOURCES
30 gen-cpp/DebugProtoTest_types.cpp
31 gen-cpp/DebugProtoTest_types.h
32 gen-cpp/EnumTest_types.cpp
33 gen-cpp/EnumTest_types.h
34 gen-cpp/OptionalRequiredTest_types.cpp
35 gen-cpp/OptionalRequiredTest_types.h
36 gen-cpp/Recursive_types.cpp
37 gen-cpp/Recursive_types.h
38 gen-cpp/ThriftTest_types.cpp
39 gen-cpp/ThriftTest_types.h
40 gen-cpp/TypedefTest_types.cpp
41 gen-cpp/TypedefTest_types.h
42 ThriftTest_extras.cpp
43 DebugProtoTest_extras.cpp
44)
45
46add_library(testgencpp STATIC ${testgencpp_SOURCES})
47target_link_libraries(testgencpp thrift)
48
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +090049set(testgencpp_cob_SOURCES
Pascal Bachd5f87e12014-12-12 15:59:17 +010050 gen-cpp/ChildService.cpp
51 gen-cpp/ChildService.h
52 gen-cpp/ParentService.cpp
53 gen-cpp/ParentService.h
54 gen-cpp/proc_types.cpp
55 gen-cpp/proc_types.h
56)
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +090057add_library(testgencpp_cob STATIC ${testgencpp_cob_SOURCES})
58target_link_libraries(testgencpp_cob thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +010059
60
61add_executable(Benchmark Benchmark.cpp)
62target_link_libraries(Benchmark testgencpp)
63add_test(NAME Benchmark COMMAND Benchmark)
64
65set(UnitTest_SOURCES
66 UnitTestMain.cpp
67 TMemoryBufferTest.cpp
68 TBufferBaseTest.cpp
69 Base64Test.cpp
70 ToStringTest.cpp
71 TypedefTest.cpp
Roger Meier3815e0b2015-04-04 16:26:30 +020072 TServerSocketTest.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010073)
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)
Nobuaki Sukegawa8016af82015-01-02 23:14:22 +0900213
214set(TNonblockingServerTest_SOURCES TNonblockingServerTest.cpp)
215add_executable(TNonblockingServerTest ${TNonblockingServerTest_SOURCES})
216include_directories(${LIBEVENT_INCLUDE_DIRS})
217target_link_libraries(TNonblockingServerTest
218 testgencpp_cob
219 thrift
220 thriftnb
221 ${LIBEVENT_LIBRARIES}
222 ${Boost_LIBRARIES}
223)
224add_test(NAME TNonblockingServerTest COMMAND TNonblockingServerTest)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100225endif()
226
227if(OPENSSL_FOUND AND WITH_OPENSSL)
228add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp)
229target_link_libraries(OpenSSLManualInitTest
230 thrift
231 ${OPENSSL_LIBRARIES}
232 ${Boost_LIBRARIES}
233)
234add_test(NAME OpenSSLManualInitTest COMMAND OpenSSLManualInitTest)
235endif()
236
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900237if(WITH_QT4)
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900238set(CMAKE_AUTOMOC ON)
239find_package(Qt4 REQUIRED COMPONENTS QtTest)
240set(TQTcpServerTest_SOURCES
241 qt/TQTcpServerTest.cpp
242)
243add_executable(TQTcpServerTest ${TQTcpServerTest_SOURCES})
244target_link_libraries(TQTcpServerTest testgencpp_cob thriftqt thrift Qt4::QtTest)
245add_test(NAME TQTcpServerTest COMMAND TQTcpServerTest)
246endif()
247
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900248if(WITH_QT5)
249add_subdirectory(qt)
250endif()
251
Pascal Bachd5f87e12014-12-12 15:59:17 +0100252#
253# Common thrift code generation rules
254#
255
256
257add_custom_command(OUTPUT gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h
258 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift
259)
260
261add_custom_command(OUTPUT gen-cpp/EnumTest_types.cpp gen-cpp/EnumTest_types.h
262 COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/EnumTest.thrift
263)
264
265add_custom_command(OUTPUT gen-cpp/TypedefTest_types.cpp gen-cpp/TypedefTest_types.h
266 COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/TypedefTest.thrift
267)
268
269add_custom_command(OUTPUT gen-cpp/OptionalRequiredTest_types.cpp gen-cpp/OptionalRequiredTest_types.h
270 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift
271)
272
273add_custom_command(OUTPUT gen-cpp/Recursive_types.cpp gen-cpp/Recursive_types.h
274 COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/Recursive.thrift
275)
276
277add_custom_command(OUTPUT gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp
278 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/StressTest.thrift
279)
280
281add_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
282 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
283)
284
285add_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
286 COMMAND thrift-compiler --gen cpp:templates,cob_style ${CMAKE_CURRENT_SOURCE_DIR}/processor/proc.thrift
287)