Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 1 | # |
| 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 Meier | 5af78c8 | 2015-04-12 21:43:12 +0200 | [diff] [blame] | 20 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 21 | # Find required packages |
| 22 | set(Boost_USE_STATIC_LIBS ON) # Force the use of static boost test framework |
Ben Craig | 1684c42 | 2015-04-24 08:52:44 -0500 | [diff] [blame^] | 23 | find_package(Boost 1.53.0 REQUIRED COMPONENTS chrono system thread unit_test_framework) |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 24 | include_directories(SYSTEM "${Boost_INCLUDE_DIRS}") |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 25 | |
| 26 | #Make sure gen-cpp files can be included |
| 27 | include_directories("${CMAKE_CURRENT_BINARY_DIR}") |
| 28 | |
| 29 | # Create the thrift C++ test library |
| 30 | set(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 | |
| 47 | add_library(testgencpp STATIC ${testgencpp_SOURCES}) |
| 48 | target_link_libraries(testgencpp thrift) |
| 49 | |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 50 | set(testgencpp_cob_SOURCES |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 51 | gen-cpp/ChildService.cpp |
| 52 | gen-cpp/ChildService.h |
Ben Craig | 1684c42 | 2015-04-24 08:52:44 -0500 | [diff] [blame^] | 53 | gen-cpp/EmptyService.cpp |
| 54 | gen-cpp/EmptyService.h |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 55 | gen-cpp/ParentService.cpp |
| 56 | gen-cpp/ParentService.h |
| 57 | gen-cpp/proc_types.cpp |
| 58 | gen-cpp/proc_types.h |
| 59 | ) |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 60 | add_library(testgencpp_cob STATIC ${testgencpp_cob_SOURCES}) |
| 61 | target_link_libraries(testgencpp_cob thrift) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 62 | |
| 63 | |
| 64 | add_executable(Benchmark Benchmark.cpp) |
| 65 | target_link_libraries(Benchmark testgencpp) |
| 66 | add_test(NAME Benchmark COMMAND Benchmark) |
| 67 | |
| 68 | set(UnitTest_SOURCES |
| 69 | UnitTestMain.cpp |
| 70 | TMemoryBufferTest.cpp |
| 71 | TBufferBaseTest.cpp |
| 72 | Base64Test.cpp |
| 73 | ToStringTest.cpp |
| 74 | TypedefTest.cpp |
Roger Meier | 3815e0b | 2015-04-04 16:26:30 +0200 | [diff] [blame] | 75 | TServerSocketTest.cpp |
Ben Craig | 1684c42 | 2015-04-24 08:52:44 -0500 | [diff] [blame^] | 76 | TServerTransportTest.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 77 | ) |
| 78 | |
| 79 | if(NOT WITH_BOOSTTHREADS AND NOT WITH_STDTHREADS) |
| 80 | list(APPEND UnitTest_SOURCES RWMutexStarveTest.cpp) |
| 81 | endif() |
| 82 | |
| 83 | add_executable(UnitTests ${UnitTest_SOURCES}) |
| 84 | target_link_libraries(UnitTests testgencpp thrift ${Boost_LIBRARIES}) |
| 85 | add_test(NAME UnitTests COMMAND UnitTests) |
| 86 | |
Ben Craig | 1684c42 | 2015-04-24 08:52:44 -0500 | [diff] [blame^] | 87 | add_executable(TSocketInterruptTest TSocketInterruptTest.cpp) |
| 88 | target_link_libraries(TSocketInterruptTest |
| 89 | testgencpp |
| 90 | ${Boost_LIBRARIES} |
| 91 | #-lrt |
| 92 | ) |
| 93 | if (NOT MSVC) |
| 94 | target_link_libraries(TSocketInterruptTest -lrt) |
| 95 | endif () |
| 96 | add_test(NAME TSocketInterruptTest COMMAND TSocketInterruptTest) |
| 97 | |
| 98 | add_executable(TServerIntegrationTest TServerIntegrationTest.cpp) |
| 99 | target_link_libraries(TServerIntegrationTest |
| 100 | testgencpp_cob |
| 101 | ${Boost_LIBRARIES} |
| 102 | ) |
| 103 | if (NOT MSVC) |
| 104 | target_link_libraries(TServerIntegrationTest -lrt) |
| 105 | endif () |
| 106 | add_test(NAME TServerIntegrationTest COMMAND TServerIntegrationTest) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 107 | |
| 108 | if(WITH_ZLIB) |
| 109 | add_executable(TransportTest TransportTest.cpp) |
| 110 | target_link_libraries(TransportTest |
| 111 | testgencpp |
| 112 | thriftz |
| 113 | ${Boost_LIBRARIES} |
| 114 | ${ZLIB_LIBRARIES} |
| 115 | ) |
| 116 | add_test(NAME TransportTest COMMAND TransportTest) |
| 117 | |
| 118 | add_executable(ZlibTest ZlibTest.cpp) |
| 119 | target_link_libraries(ZlibTest |
| 120 | testgencpp |
| 121 | thriftz |
| 122 | ${Boost_LIBRARIES} |
| 123 | ${ZLIB_LIBRARIES} |
| 124 | ) |
| 125 | add_test(NAME ZlibTest COMMAND ZlibTest) |
| 126 | endif(WITH_ZLIB) |
| 127 | |
| 128 | |
| 129 | add_executable(EnumTest EnumTest.cpp) |
| 130 | target_link_libraries(EnumTest |
| 131 | testgencpp |
| 132 | ${Boost_LIBRARIES} |
| 133 | ) |
| 134 | add_test(NAME EnumTest COMMAND EnumTest) |
| 135 | |
| 136 | add_executable(TFileTransportTest TFileTransportTest.cpp) |
| 137 | target_link_libraries(TFileTransportTest |
| 138 | testgencpp |
| 139 | ${Boost_LIBRARIES} |
| 140 | ) |
| 141 | add_test(NAME TFileTransportTest COMMAND TFileTransportTest) |
| 142 | |
| 143 | add_executable(TFDTransportTest TFDTransportTest.cpp) |
| 144 | target_link_libraries(TFDTransportTest |
| 145 | thrift |
| 146 | ) |
| 147 | add_test(NAME TFDTransportTest COMMAND TFDTransportTest) |
| 148 | |
| 149 | add_executable(TPipedTransportTest TPipedTransportTest.cpp) |
| 150 | target_link_libraries(TPipedTransportTest |
| 151 | thrift |
| 152 | ) |
| 153 | add_test(NAME TPipedTransportTest COMMAND TPipedTransportTest) |
| 154 | |
| 155 | set(AllProtocolsTest_SOURCES |
| 156 | AllProtocolTests.cpp |
| 157 | AllProtocolTests.tcc |
| 158 | GenericHelpers |
| 159 | ) |
| 160 | |
| 161 | add_executable(AllProtocolsTest ${AllProtocolsTest_SOURCES}) |
| 162 | target_link_libraries(AllProtocolsTest |
| 163 | testgencpp |
| 164 | ) |
| 165 | add_test(NAME AllProtocolsTest COMMAND AllProtocolsTest) |
| 166 | |
| 167 | add_executable(DebugProtoTest DebugProtoTest.cpp) |
| 168 | target_link_libraries(DebugProtoTest |
| 169 | testgencpp |
| 170 | ) |
| 171 | add_test(NAME DebugProtoTest COMMAND DebugProtoTest) |
| 172 | |
| 173 | add_executable(JSONProtoTest JSONProtoTest.cpp) |
| 174 | target_link_libraries(JSONProtoTest |
| 175 | testgencpp |
| 176 | ) |
| 177 | add_test(NAME JSONProtoTest COMMAND JSONProtoTest) |
| 178 | |
| 179 | add_executable(OptionalRequiredTest OptionalRequiredTest.cpp) |
| 180 | target_link_libraries(OptionalRequiredTest |
| 181 | testgencpp |
| 182 | ) |
| 183 | add_test(NAME OptionalRequiredTest COMMAND OptionalRequiredTest) |
| 184 | |
| 185 | add_executable(RecursiveTest RecursiveTest.cpp) |
| 186 | target_link_libraries(RecursiveTest |
| 187 | testgencpp |
| 188 | ) |
| 189 | add_test(NAME RecursiveTest COMMAND RecursiveTest) |
| 190 | |
| 191 | add_executable(SpecializationTest SpecializationTest.cpp) |
| 192 | target_link_libraries(SpecializationTest |
| 193 | testgencpp |
| 194 | ) |
| 195 | add_test(NAME SpecializationTest COMMAND SpecializationTest) |
| 196 | |
| 197 | set(concurrency_test_SOURCES |
| 198 | concurrency/Tests.cpp |
| 199 | concurrency/ThreadFactoryTests.h |
| 200 | concurrency/ThreadManagerTests.h |
| 201 | concurrency/TimerManagerTests.h |
| 202 | ) |
| 203 | add_executable(concurrency_test ${concurrency_test_SOURCES}) |
| 204 | target_link_libraries(concurrency_test |
| 205 | thrift |
| 206 | ) |
| 207 | add_test(NAME concurrency_test COMMAND concurrency_test) |
| 208 | |
| 209 | set(link_test_SOURCES |
| 210 | link/LinkTest.cpp |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 211 | gen-cpp/ParentService.h |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 212 | link/TemplatedService1.cpp |
| 213 | link/TemplatedService2.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 214 | ) |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 215 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 216 | add_executable(link_test ${link_test_SOURCES}) |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 217 | target_link_libraries(concurrency_test testgencpp_cob thrift) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 218 | add_test(NAME link_test COMMAND link_test) |
| 219 | |
| 220 | if(WITH_LIBEVENT) |
| 221 | set(processor_test_SOURCES |
| 222 | processor/ProcessorTest.cpp |
| 223 | processor/EventLog.cpp |
| 224 | processor/ServerThread.cpp |
| 225 | processor/EventLog.h |
| 226 | processor/Handlers.h |
| 227 | processor/ServerThread.h |
| 228 | ) |
| 229 | add_executable(processor_test ${processor_test_SOURCES}) |
| 230 | target_link_libraries(processor_test |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 231 | testgencpp_cob |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 232 | thrift |
| 233 | thriftnb |
| 234 | ${Boost_LIBRARIES} |
| 235 | ) |
| 236 | add_test(NAME processor_test COMMAND processor_test) |
Nobuaki Sukegawa | 8016af8 | 2015-01-02 23:14:22 +0900 | [diff] [blame] | 237 | |
| 238 | set(TNonblockingServerTest_SOURCES TNonblockingServerTest.cpp) |
| 239 | add_executable(TNonblockingServerTest ${TNonblockingServerTest_SOURCES}) |
| 240 | include_directories(${LIBEVENT_INCLUDE_DIRS}) |
| 241 | target_link_libraries(TNonblockingServerTest |
| 242 | testgencpp_cob |
| 243 | thrift |
| 244 | thriftnb |
| 245 | ${LIBEVENT_LIBRARIES} |
| 246 | ${Boost_LIBRARIES} |
| 247 | ) |
| 248 | add_test(NAME TNonblockingServerTest COMMAND TNonblockingServerTest) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 249 | endif() |
| 250 | |
| 251 | if(OPENSSL_FOUND AND WITH_OPENSSL) |
| 252 | add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp) |
| 253 | target_link_libraries(OpenSSLManualInitTest |
| 254 | thrift |
| 255 | ${OPENSSL_LIBRARIES} |
| 256 | ${Boost_LIBRARIES} |
| 257 | ) |
| 258 | add_test(NAME OpenSSLManualInitTest COMMAND OpenSSLManualInitTest) |
| 259 | endif() |
| 260 | |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 261 | if(WITH_QT4) |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 262 | set(CMAKE_AUTOMOC ON) |
| 263 | find_package(Qt4 REQUIRED COMPONENTS QtTest) |
| 264 | set(TQTcpServerTest_SOURCES |
| 265 | qt/TQTcpServerTest.cpp |
| 266 | ) |
| 267 | add_executable(TQTcpServerTest ${TQTcpServerTest_SOURCES}) |
| 268 | target_link_libraries(TQTcpServerTest testgencpp_cob thriftqt thrift Qt4::QtTest) |
| 269 | add_test(NAME TQTcpServerTest COMMAND TQTcpServerTest) |
| 270 | endif() |
| 271 | |
Nobuaki Sukegawa | 6622877 | 2014-12-07 21:45:33 +0900 | [diff] [blame] | 272 | if(WITH_QT5) |
| 273 | add_subdirectory(qt) |
| 274 | endif() |
| 275 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 276 | # |
| 277 | # Common thrift code generation rules |
| 278 | # |
| 279 | |
| 280 | |
Ben Craig | 1684c42 | 2015-04-24 08:52:44 -0500 | [diff] [blame^] | 281 | add_custom_command(OUTPUT gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h gen-cpp/EmptyService.cpp gen-cpp/EmptyService.h |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 282 | COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift |
| 283 | ) |
| 284 | |
| 285 | add_custom_command(OUTPUT gen-cpp/EnumTest_types.cpp gen-cpp/EnumTest_types.h |
| 286 | COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/EnumTest.thrift |
| 287 | ) |
| 288 | |
| 289 | add_custom_command(OUTPUT gen-cpp/TypedefTest_types.cpp gen-cpp/TypedefTest_types.h |
| 290 | COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/TypedefTest.thrift |
| 291 | ) |
| 292 | |
| 293 | add_custom_command(OUTPUT gen-cpp/OptionalRequiredTest_types.cpp gen-cpp/OptionalRequiredTest_types.h |
| 294 | COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift |
| 295 | ) |
| 296 | |
| 297 | add_custom_command(OUTPUT gen-cpp/Recursive_types.cpp gen-cpp/Recursive_types.h |
| 298 | COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/Recursive.thrift |
| 299 | ) |
| 300 | |
| 301 | add_custom_command(OUTPUT gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp |
| 302 | COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/StressTest.thrift |
| 303 | ) |
| 304 | |
| 305 | 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 |
| 306 | COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift |
| 307 | ) |
| 308 | |
| 309 | 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 |
| 310 | COMMAND thrift-compiler --gen cpp:templates,cob_style ${CMAKE_CURRENT_SOURCE_DIR}/processor/proc.thrift |
| 311 | ) |