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 |
| 23 | find_package(Boost 1.53.0 REQUIRED COMPONENTS 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 |
| 53 | gen-cpp/ParentService.cpp |
| 54 | gen-cpp/ParentService.h |
| 55 | gen-cpp/proc_types.cpp |
| 56 | gen-cpp/proc_types.h |
| 57 | ) |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 58 | add_library(testgencpp_cob STATIC ${testgencpp_cob_SOURCES}) |
| 59 | target_link_libraries(testgencpp_cob thrift) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 60 | |
| 61 | |
| 62 | add_executable(Benchmark Benchmark.cpp) |
| 63 | target_link_libraries(Benchmark testgencpp) |
| 64 | add_test(NAME Benchmark COMMAND Benchmark) |
| 65 | |
| 66 | set(UnitTest_SOURCES |
| 67 | UnitTestMain.cpp |
| 68 | TMemoryBufferTest.cpp |
| 69 | TBufferBaseTest.cpp |
| 70 | Base64Test.cpp |
| 71 | ToStringTest.cpp |
| 72 | TypedefTest.cpp |
Roger Meier | 3815e0b | 2015-04-04 16:26:30 +0200 | [diff] [blame] | 73 | TServerSocketTest.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 74 | ) |
| 75 | |
| 76 | if(NOT WITH_BOOSTTHREADS AND NOT WITH_STDTHREADS) |
| 77 | list(APPEND UnitTest_SOURCES RWMutexStarveTest.cpp) |
| 78 | endif() |
| 79 | |
| 80 | add_executable(UnitTests ${UnitTest_SOURCES}) |
| 81 | target_link_libraries(UnitTests testgencpp thrift ${Boost_LIBRARIES}) |
| 82 | add_test(NAME UnitTests COMMAND UnitTests) |
| 83 | |
| 84 | |
| 85 | if(WITH_ZLIB) |
| 86 | add_executable(TransportTest TransportTest.cpp) |
| 87 | target_link_libraries(TransportTest |
| 88 | testgencpp |
| 89 | thriftz |
| 90 | ${Boost_LIBRARIES} |
| 91 | ${ZLIB_LIBRARIES} |
| 92 | ) |
| 93 | add_test(NAME TransportTest COMMAND TransportTest) |
| 94 | |
| 95 | add_executable(ZlibTest ZlibTest.cpp) |
| 96 | target_link_libraries(ZlibTest |
| 97 | testgencpp |
| 98 | thriftz |
| 99 | ${Boost_LIBRARIES} |
| 100 | ${ZLIB_LIBRARIES} |
| 101 | ) |
| 102 | add_test(NAME ZlibTest COMMAND ZlibTest) |
| 103 | endif(WITH_ZLIB) |
| 104 | |
| 105 | |
| 106 | add_executable(EnumTest EnumTest.cpp) |
| 107 | target_link_libraries(EnumTest |
| 108 | testgencpp |
| 109 | ${Boost_LIBRARIES} |
| 110 | ) |
| 111 | add_test(NAME EnumTest COMMAND EnumTest) |
| 112 | |
| 113 | add_executable(TFileTransportTest TFileTransportTest.cpp) |
| 114 | target_link_libraries(TFileTransportTest |
| 115 | testgencpp |
| 116 | ${Boost_LIBRARIES} |
| 117 | ) |
| 118 | add_test(NAME TFileTransportTest COMMAND TFileTransportTest) |
| 119 | |
| 120 | add_executable(TFDTransportTest TFDTransportTest.cpp) |
| 121 | target_link_libraries(TFDTransportTest |
| 122 | thrift |
| 123 | ) |
| 124 | add_test(NAME TFDTransportTest COMMAND TFDTransportTest) |
| 125 | |
| 126 | add_executable(TPipedTransportTest TPipedTransportTest.cpp) |
| 127 | target_link_libraries(TPipedTransportTest |
| 128 | thrift |
| 129 | ) |
| 130 | add_test(NAME TPipedTransportTest COMMAND TPipedTransportTest) |
| 131 | |
| 132 | set(AllProtocolsTest_SOURCES |
| 133 | AllProtocolTests.cpp |
| 134 | AllProtocolTests.tcc |
| 135 | GenericHelpers |
| 136 | ) |
| 137 | |
| 138 | add_executable(AllProtocolsTest ${AllProtocolsTest_SOURCES}) |
| 139 | target_link_libraries(AllProtocolsTest |
| 140 | testgencpp |
| 141 | ) |
| 142 | add_test(NAME AllProtocolsTest COMMAND AllProtocolsTest) |
| 143 | |
| 144 | add_executable(DebugProtoTest DebugProtoTest.cpp) |
| 145 | target_link_libraries(DebugProtoTest |
| 146 | testgencpp |
| 147 | ) |
| 148 | add_test(NAME DebugProtoTest COMMAND DebugProtoTest) |
| 149 | |
| 150 | add_executable(JSONProtoTest JSONProtoTest.cpp) |
| 151 | target_link_libraries(JSONProtoTest |
| 152 | testgencpp |
| 153 | ) |
| 154 | add_test(NAME JSONProtoTest COMMAND JSONProtoTest) |
| 155 | |
| 156 | add_executable(OptionalRequiredTest OptionalRequiredTest.cpp) |
| 157 | target_link_libraries(OptionalRequiredTest |
| 158 | testgencpp |
| 159 | ) |
| 160 | add_test(NAME OptionalRequiredTest COMMAND OptionalRequiredTest) |
| 161 | |
| 162 | add_executable(RecursiveTest RecursiveTest.cpp) |
| 163 | target_link_libraries(RecursiveTest |
| 164 | testgencpp |
| 165 | ) |
| 166 | add_test(NAME RecursiveTest COMMAND RecursiveTest) |
| 167 | |
| 168 | add_executable(SpecializationTest SpecializationTest.cpp) |
| 169 | target_link_libraries(SpecializationTest |
| 170 | testgencpp |
| 171 | ) |
| 172 | add_test(NAME SpecializationTest COMMAND SpecializationTest) |
| 173 | |
| 174 | set(concurrency_test_SOURCES |
| 175 | concurrency/Tests.cpp |
| 176 | concurrency/ThreadFactoryTests.h |
| 177 | concurrency/ThreadManagerTests.h |
| 178 | concurrency/TimerManagerTests.h |
| 179 | ) |
| 180 | add_executable(concurrency_test ${concurrency_test_SOURCES}) |
| 181 | target_link_libraries(concurrency_test |
| 182 | thrift |
| 183 | ) |
| 184 | add_test(NAME concurrency_test COMMAND concurrency_test) |
| 185 | |
| 186 | set(link_test_SOURCES |
| 187 | link/LinkTest.cpp |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 188 | gen-cpp/ParentService.h |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 189 | link/TemplatedService1.cpp |
| 190 | link/TemplatedService2.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 191 | ) |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 192 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 193 | add_executable(link_test ${link_test_SOURCES}) |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 194 | target_link_libraries(concurrency_test testgencpp_cob thrift) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 195 | add_test(NAME link_test COMMAND link_test) |
| 196 | |
| 197 | if(WITH_LIBEVENT) |
| 198 | set(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 | ) |
| 206 | add_executable(processor_test ${processor_test_SOURCES}) |
| 207 | target_link_libraries(processor_test |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 208 | testgencpp_cob |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 209 | thrift |
| 210 | thriftnb |
| 211 | ${Boost_LIBRARIES} |
| 212 | ) |
| 213 | add_test(NAME processor_test COMMAND processor_test) |
Nobuaki Sukegawa | 8016af8 | 2015-01-02 23:14:22 +0900 | [diff] [blame] | 214 | |
| 215 | set(TNonblockingServerTest_SOURCES TNonblockingServerTest.cpp) |
| 216 | add_executable(TNonblockingServerTest ${TNonblockingServerTest_SOURCES}) |
| 217 | include_directories(${LIBEVENT_INCLUDE_DIRS}) |
| 218 | target_link_libraries(TNonblockingServerTest |
| 219 | testgencpp_cob |
| 220 | thrift |
| 221 | thriftnb |
| 222 | ${LIBEVENT_LIBRARIES} |
| 223 | ${Boost_LIBRARIES} |
| 224 | ) |
| 225 | add_test(NAME TNonblockingServerTest COMMAND TNonblockingServerTest) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 226 | endif() |
| 227 | |
| 228 | if(OPENSSL_FOUND AND WITH_OPENSSL) |
| 229 | add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp) |
| 230 | target_link_libraries(OpenSSLManualInitTest |
| 231 | thrift |
| 232 | ${OPENSSL_LIBRARIES} |
| 233 | ${Boost_LIBRARIES} |
| 234 | ) |
| 235 | add_test(NAME OpenSSLManualInitTest COMMAND OpenSSLManualInitTest) |
| 236 | endif() |
| 237 | |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 238 | if(WITH_QT4) |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 239 | set(CMAKE_AUTOMOC ON) |
| 240 | find_package(Qt4 REQUIRED COMPONENTS QtTest) |
| 241 | set(TQTcpServerTest_SOURCES |
| 242 | qt/TQTcpServerTest.cpp |
| 243 | ) |
| 244 | add_executable(TQTcpServerTest ${TQTcpServerTest_SOURCES}) |
| 245 | target_link_libraries(TQTcpServerTest testgencpp_cob thriftqt thrift Qt4::QtTest) |
| 246 | add_test(NAME TQTcpServerTest COMMAND TQTcpServerTest) |
| 247 | endif() |
| 248 | |
Nobuaki Sukegawa | 6622877 | 2014-12-07 21:45:33 +0900 | [diff] [blame] | 249 | if(WITH_QT5) |
| 250 | add_subdirectory(qt) |
| 251 | endif() |
| 252 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 253 | # |
| 254 | # Common thrift code generation rules |
| 255 | # |
| 256 | |
| 257 | |
| 258 | add_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 | |
| 262 | add_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 | |
| 266 | add_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 | |
| 270 | add_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 | |
| 274 | add_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 | |
| 278 | add_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 | |
| 282 | 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 |
| 283 | COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift |
| 284 | ) |
| 285 | |
| 286 | 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 |
| 287 | COMMAND thrift-compiler --gen cpp:templates,cob_style ${CMAKE_CURRENT_SOURCE_DIR}/processor/proc.thrift |
| 288 | ) |