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 | |
| 20 | |
| 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) |
| 24 | include_directories("${Boost_INCLUDE_DIR}") |
| 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 | |
| 50 | set(processortest_SOURCES |
| 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 | ) |
| 58 | |
| 59 | |
| 60 | add_executable(Benchmark Benchmark.cpp) |
| 61 | target_link_libraries(Benchmark testgencpp) |
| 62 | add_test(NAME Benchmark COMMAND Benchmark) |
| 63 | |
| 64 | set(UnitTest_SOURCES |
| 65 | UnitTestMain.cpp |
| 66 | TMemoryBufferTest.cpp |
| 67 | TBufferBaseTest.cpp |
| 68 | Base64Test.cpp |
| 69 | ToStringTest.cpp |
| 70 | TypedefTest.cpp |
| 71 | ) |
| 72 | |
| 73 | if(NOT WITH_BOOSTTHREADS AND NOT WITH_STDTHREADS) |
| 74 | list(APPEND UnitTest_SOURCES RWMutexStarveTest.cpp) |
| 75 | endif() |
| 76 | |
| 77 | add_executable(UnitTests ${UnitTest_SOURCES}) |
| 78 | target_link_libraries(UnitTests testgencpp thrift ${Boost_LIBRARIES}) |
| 79 | add_test(NAME UnitTests COMMAND UnitTests) |
| 80 | |
| 81 | |
| 82 | if(WITH_ZLIB) |
| 83 | add_executable(TransportTest TransportTest.cpp) |
| 84 | target_link_libraries(TransportTest |
| 85 | testgencpp |
| 86 | thriftz |
| 87 | ${Boost_LIBRARIES} |
| 88 | ${ZLIB_LIBRARIES} |
| 89 | ) |
| 90 | add_test(NAME TransportTest COMMAND TransportTest) |
| 91 | |
| 92 | add_executable(ZlibTest ZlibTest.cpp) |
| 93 | target_link_libraries(ZlibTest |
| 94 | testgencpp |
| 95 | thriftz |
| 96 | ${Boost_LIBRARIES} |
| 97 | ${ZLIB_LIBRARIES} |
| 98 | ) |
| 99 | add_test(NAME ZlibTest COMMAND ZlibTest) |
| 100 | endif(WITH_ZLIB) |
| 101 | |
| 102 | |
| 103 | add_executable(EnumTest EnumTest.cpp) |
| 104 | target_link_libraries(EnumTest |
| 105 | testgencpp |
| 106 | ${Boost_LIBRARIES} |
| 107 | ) |
| 108 | add_test(NAME EnumTest COMMAND EnumTest) |
| 109 | |
| 110 | add_executable(TFileTransportTest TFileTransportTest.cpp) |
| 111 | target_link_libraries(TFileTransportTest |
| 112 | testgencpp |
| 113 | ${Boost_LIBRARIES} |
| 114 | ) |
| 115 | add_test(NAME TFileTransportTest COMMAND TFileTransportTest) |
| 116 | |
| 117 | add_executable(TFDTransportTest TFDTransportTest.cpp) |
| 118 | target_link_libraries(TFDTransportTest |
| 119 | thrift |
| 120 | ) |
| 121 | add_test(NAME TFDTransportTest COMMAND TFDTransportTest) |
| 122 | |
| 123 | add_executable(TPipedTransportTest TPipedTransportTest.cpp) |
| 124 | target_link_libraries(TPipedTransportTest |
| 125 | thrift |
| 126 | ) |
| 127 | add_test(NAME TPipedTransportTest COMMAND TPipedTransportTest) |
| 128 | |
| 129 | set(AllProtocolsTest_SOURCES |
| 130 | AllProtocolTests.cpp |
| 131 | AllProtocolTests.tcc |
| 132 | GenericHelpers |
| 133 | ) |
| 134 | |
| 135 | add_executable(AllProtocolsTest ${AllProtocolsTest_SOURCES}) |
| 136 | target_link_libraries(AllProtocolsTest |
| 137 | testgencpp |
| 138 | ) |
| 139 | add_test(NAME AllProtocolsTest COMMAND AllProtocolsTest) |
| 140 | |
| 141 | add_executable(DebugProtoTest DebugProtoTest.cpp) |
| 142 | target_link_libraries(DebugProtoTest |
| 143 | testgencpp |
| 144 | ) |
| 145 | add_test(NAME DebugProtoTest COMMAND DebugProtoTest) |
| 146 | |
| 147 | add_executable(JSONProtoTest JSONProtoTest.cpp) |
| 148 | target_link_libraries(JSONProtoTest |
| 149 | testgencpp |
| 150 | ) |
| 151 | add_test(NAME JSONProtoTest COMMAND JSONProtoTest) |
| 152 | |
| 153 | add_executable(OptionalRequiredTest OptionalRequiredTest.cpp) |
| 154 | target_link_libraries(OptionalRequiredTest |
| 155 | testgencpp |
| 156 | ) |
| 157 | add_test(NAME OptionalRequiredTest COMMAND OptionalRequiredTest) |
| 158 | |
| 159 | add_executable(RecursiveTest RecursiveTest.cpp) |
| 160 | target_link_libraries(RecursiveTest |
| 161 | testgencpp |
| 162 | ) |
| 163 | add_test(NAME RecursiveTest COMMAND RecursiveTest) |
| 164 | |
| 165 | add_executable(SpecializationTest SpecializationTest.cpp) |
| 166 | target_link_libraries(SpecializationTest |
| 167 | testgencpp |
| 168 | ) |
| 169 | add_test(NAME SpecializationTest COMMAND SpecializationTest) |
| 170 | |
| 171 | set(concurrency_test_SOURCES |
| 172 | concurrency/Tests.cpp |
| 173 | concurrency/ThreadFactoryTests.h |
| 174 | concurrency/ThreadManagerTests.h |
| 175 | concurrency/TimerManagerTests.h |
| 176 | ) |
| 177 | add_executable(concurrency_test ${concurrency_test_SOURCES}) |
| 178 | target_link_libraries(concurrency_test |
| 179 | thrift |
| 180 | ) |
| 181 | add_test(NAME concurrency_test COMMAND concurrency_test) |
| 182 | |
| 183 | set(link_test_SOURCES |
| 184 | link/LinkTest.cpp |
| 185 | link/TemplatedService1.cpp |
| 186 | link/TemplatedService2.cpp |
| 187 | gen-cpp/ParentService.h |
| 188 | ) |
| 189 | add_executable(link_test ${link_test_SOURCES}) |
| 190 | add_test(NAME link_test COMMAND link_test) |
| 191 | |
| 192 | if(WITH_LIBEVENT) |
| 193 | set(processor_test_SOURCES |
| 194 | processor/ProcessorTest.cpp |
| 195 | processor/EventLog.cpp |
| 196 | processor/ServerThread.cpp |
| 197 | processor/EventLog.h |
| 198 | processor/Handlers.h |
| 199 | processor/ServerThread.h |
| 200 | ) |
| 201 | add_executable(processor_test ${processor_test_SOURCES}) |
| 202 | target_link_libraries(processor_test |
| 203 | thrift |
| 204 | thriftnb |
| 205 | ${Boost_LIBRARIES} |
| 206 | ) |
| 207 | add_test(NAME processor_test COMMAND processor_test) |
| 208 | endif() |
| 209 | |
| 210 | if(OPENSSL_FOUND AND WITH_OPENSSL) |
| 211 | add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp) |
| 212 | target_link_libraries(OpenSSLManualInitTest |
| 213 | thrift |
| 214 | ${OPENSSL_LIBRARIES} |
| 215 | ${Boost_LIBRARIES} |
| 216 | ) |
| 217 | add_test(NAME OpenSSLManualInitTest COMMAND OpenSSLManualInitTest) |
| 218 | endif() |
| 219 | |
| 220 | # |
| 221 | # Common thrift code generation rules |
| 222 | # |
| 223 | |
| 224 | |
| 225 | add_custom_command(OUTPUT gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h |
| 226 | COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift |
| 227 | ) |
| 228 | |
| 229 | add_custom_command(OUTPUT gen-cpp/EnumTest_types.cpp gen-cpp/EnumTest_types.h |
| 230 | COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/EnumTest.thrift |
| 231 | ) |
| 232 | |
| 233 | add_custom_command(OUTPUT gen-cpp/TypedefTest_types.cpp gen-cpp/TypedefTest_types.h |
| 234 | COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/TypedefTest.thrift |
| 235 | ) |
| 236 | |
| 237 | add_custom_command(OUTPUT gen-cpp/OptionalRequiredTest_types.cpp gen-cpp/OptionalRequiredTest_types.h |
| 238 | COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift |
| 239 | ) |
| 240 | |
| 241 | add_custom_command(OUTPUT gen-cpp/Recursive_types.cpp gen-cpp/Recursive_types.h |
| 242 | COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/Recursive.thrift |
| 243 | ) |
| 244 | |
| 245 | add_custom_command(OUTPUT gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp |
| 246 | COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/StressTest.thrift |
| 247 | ) |
| 248 | |
| 249 | 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 |
| 250 | COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift |
| 251 | ) |
| 252 | |
| 253 | 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 |
| 254 | COMMAND thrift-compiler --gen cpp:templates,cob_style ${CMAKE_CURRENT_SOURCE_DIR}/processor/proc.thrift |
| 255 | ) |