Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [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 | |
James E. King III | c9ac8d2 | 2019-01-07 16:46:45 -0500 | [diff] [blame] | 20 | # The test executables still depend on Boost |
| 21 | include(BoostMacros) |
| 22 | REQUIRE_BOOST_HEADERS() |
| 23 | set(BOOST_COMPONENTS filesystem program_options random) |
| 24 | REQUIRE_BOOST_LIBRARIES(BOOST_COMPONENTS) |
| 25 | |
Ben Craig | 7207c22 | 2015-07-06 08:40:35 -0500 | [diff] [blame] | 26 | # Contains the thrift specific LINK_AGAINST_THRIFT_LIBRARY |
| 27 | include(ThriftMacros) |
| 28 | |
Ben Craig | 7207c22 | 2015-07-06 08:40:35 -0500 | [diff] [blame] | 29 | find_package(OpenSSL REQUIRED) |
| 30 | include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") |
| 31 | |
| 32 | find_package(Libevent REQUIRED) # Libevent comes with CMake support from upstream |
| 33 | include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS}) |
| 34 | |
James E. King III | b2b767e | 2018-09-15 20:32:04 +0000 | [diff] [blame] | 35 | find_package(ZLIB REQUIRED) |
| 36 | include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS}) |
| 37 | |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 38 | #Make sure gen-cpp files can be included |
| 39 | include_directories("${CMAKE_CURRENT_BINARY_DIR}") |
| 40 | include_directories("${CMAKE_CURRENT_BINARY_DIR}/gen-cpp") |
| 41 | include_directories("${PROJECT_SOURCE_DIR}/lib/cpp/src") |
| 42 | |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 43 | set(crosstestgencpp_SOURCES |
James E. King, III | 58402ff | 2017-11-17 14:41:46 -0500 | [diff] [blame] | 44 | gen-cpp/SecondService.cpp |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 45 | gen-cpp/ThriftTest.cpp |
| 46 | gen-cpp/ThriftTest_types.cpp |
| 47 | gen-cpp/ThriftTest_constants.cpp |
Marco Molteni | 8349425 | 2015-04-16 13:50:20 +0200 | [diff] [blame] | 48 | src/ThriftTest_extras.cpp |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 49 | ) |
| 50 | add_library(crosstestgencpp STATIC ${crosstestgencpp_SOURCES}) |
Ben Craig | 7207c22 | 2015-07-06 08:40:35 -0500 | [diff] [blame] | 51 | LINK_AGAINST_THRIFT_LIBRARY(crosstestgencpp thrift) |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 52 | |
| 53 | set(crossstressgencpp_SOURCES |
| 54 | gen-cpp/Service.cpp |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 55 | ) |
| 56 | add_library(crossstressgencpp STATIC ${crossstressgencpp_SOURCES}) |
Ben Craig | 7207c22 | 2015-07-06 08:40:35 -0500 | [diff] [blame] | 57 | LINK_AGAINST_THRIFT_LIBRARY(crossstressgencpp thrift) |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 58 | |
Zezeng Wang | 371d92f | 2020-04-28 14:23:15 +0800 | [diff] [blame] | 59 | set(crossspecificnamegencpp_SOURCES |
| 60 | gen-cpp/EchoService.cpp |
| 61 | gen-cpp/SpecificNameTest_types.cpp |
| 62 | ) |
| 63 | add_library(crossspecificnamegencpp STATIC ${crossspecificnamegencpp_SOURCES}) |
| 64 | LINK_AGAINST_THRIFT_LIBRARY(crossspecificnamegencpp thrift) |
| 65 | |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 66 | add_executable(TestServer src/TestServer.cpp) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 67 | target_link_libraries(TestServer crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB}) |
Ben Craig | 7207c22 | 2015-07-06 08:40:35 -0500 | [diff] [blame] | 68 | LINK_AGAINST_THRIFT_LIBRARY(TestServer thrift) |
| 69 | LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftnb) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 70 | LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftz) |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 71 | |
| 72 | add_executable(TestClient src/TestClient.cpp) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 73 | target_link_libraries(TestClient crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB}) |
Ben Craig | 7207c22 | 2015-07-06 08:40:35 -0500 | [diff] [blame] | 74 | LINK_AGAINST_THRIFT_LIBRARY(TestClient thrift) |
| 75 | LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftnb) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 76 | LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftz) |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 77 | |
| 78 | add_executable(StressTest src/StressTest.cpp) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 79 | target_link_libraries(StressTest crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB}) |
Ben Craig | 7207c22 | 2015-07-06 08:40:35 -0500 | [diff] [blame] | 80 | LINK_AGAINST_THRIFT_LIBRARY(StressTest thrift) |
| 81 | LINK_AGAINST_THRIFT_LIBRARY(StressTest thriftnb) |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 82 | add_test(NAME StressTest COMMAND StressTest) |
James E. King III | 4c57be0 | 2019-01-27 11:12:43 -0500 | [diff] [blame] | 83 | add_test(NAME StressTestConcurrent COMMAND StressTest --client-type=concurrent) |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 84 | |
Mario Emmenlauer | 8027936 | 2020-04-24 08:51:37 +0200 | [diff] [blame] | 85 | # As of https://jira.apache.org/jira/browse/THRIFT-4282, StressTestNonBlocking |
| 86 | # is broken on Windows. Contributions welcome. |
| 87 | if (NOT WIN32 AND NOT CYGWIN) |
| 88 | add_executable(StressTestNonBlocking src/StressTestNonBlocking.cpp) |
| 89 | target_link_libraries(StressTestNonBlocking crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB}) |
| 90 | LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thrift) |
| 91 | LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftnb) |
| 92 | LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftz) |
| 93 | add_test(NAME StressTestNonBlocking COMMAND StressTestNonBlocking) |
| 94 | endif() |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 95 | |
Zezeng Wang | 371d92f | 2020-04-28 14:23:15 +0800 | [diff] [blame] | 96 | add_executable(SpecificNameTest src/SpecificNameTest.cpp) |
| 97 | target_link_libraries(SpecificNameTest crossspecificnamegencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB}) |
| 98 | LINK_AGAINST_THRIFT_LIBRARY(SpecificNameTest thrift) |
| 99 | LINK_AGAINST_THRIFT_LIBRARY(SpecificNameTest thriftnb) |
| 100 | add_test(NAME SpecificNameTest COMMAND SpecificNameTest) |
| 101 | |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 102 | # |
| 103 | # Common thrift code generation rules |
| 104 | # |
| 105 | |
James E. King, III | 58402ff | 2017-11-17 14:41:46 -0500 | [diff] [blame] | 106 | add_custom_command(OUTPUT gen-cpp/SecondService.cpp gen-cpp/SecondService.h gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest.h gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants.cpp |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 107 | COMMAND ${THRIFT_COMPILER} --gen cpp:templates,cob_style -r ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 108 | ) |
| 109 | |
zeshuai007 | 57c2507 | 2020-04-09 11:17:05 +0800 | [diff] [blame] | 110 | add_custom_command(OUTPUT gen-cpp/Service.cpp |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 111 | COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/StressTest.thrift |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 112 | ) |
Zezeng Wang | 371d92f | 2020-04-28 14:23:15 +0800 | [diff] [blame] | 113 | |
| 114 | add_custom_command(OUTPUT gen-cpp/EchoService.cpp gen-cpp/SpecificNameTest_types.cpp |
| 115 | COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/SpecificNameTest.thrift |
| 116 | ) |