blob: 90af7826c10f2a9e2c5a816b690c0e42050a7a10 [file] [log] [blame]
Roger Meier26593812015-04-12 16:10:35 +02001#
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 IIIc9ac8d22019-01-07 16:46:45 -050020# The test executables still depend on Boost
21include(BoostMacros)
22REQUIRE_BOOST_HEADERS()
23set(BOOST_COMPONENTS filesystem program_options random)
24REQUIRE_BOOST_LIBRARIES(BOOST_COMPONENTS)
25
Ben Craig7207c222015-07-06 08:40:35 -050026# Contains the thrift specific LINK_AGAINST_THRIFT_LIBRARY
27include(ThriftMacros)
28
Ben Craig7207c222015-07-06 08:40:35 -050029find_package(OpenSSL REQUIRED)
30include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
31
32find_package(Libevent REQUIRED) # Libevent comes with CMake support from upstream
33include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
34
James E. King IIIb2b767e2018-09-15 20:32:04 +000035find_package(ZLIB REQUIRED)
36include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
37
Roger Meier26593812015-04-12 16:10:35 +020038#Make sure gen-cpp files can be included
39include_directories("${CMAKE_CURRENT_BINARY_DIR}")
40include_directories("${CMAKE_CURRENT_BINARY_DIR}/gen-cpp")
41include_directories("${PROJECT_SOURCE_DIR}/lib/cpp/src")
42
Roger Meier26593812015-04-12 16:10:35 +020043set(crosstestgencpp_SOURCES
James E. King, III58402ff2017-11-17 14:41:46 -050044 gen-cpp/SecondService.cpp
Roger Meier26593812015-04-12 16:10:35 +020045 gen-cpp/ThriftTest.cpp
46 gen-cpp/ThriftTest_types.cpp
47 gen-cpp/ThriftTest_constants.cpp
Marco Molteni83494252015-04-16 13:50:20 +020048 src/ThriftTest_extras.cpp
Roger Meier26593812015-04-12 16:10:35 +020049)
50add_library(crosstestgencpp STATIC ${crosstestgencpp_SOURCES})
Ben Craig7207c222015-07-06 08:40:35 -050051LINK_AGAINST_THRIFT_LIBRARY(crosstestgencpp thrift)
Roger Meier26593812015-04-12 16:10:35 +020052
53set(crossstressgencpp_SOURCES
54 gen-cpp/Service.cpp
James E. King, III58402ff2017-11-17 14:41:46 -050055 gen-cpp/StressTest_types.cpp
Roger Meier26593812015-04-12 16:10:35 +020056 gen-cpp/StressTest_constants.cpp
57)
58add_library(crossstressgencpp STATIC ${crossstressgencpp_SOURCES})
Ben Craig7207c222015-07-06 08:40:35 -050059LINK_AGAINST_THRIFT_LIBRARY(crossstressgencpp thrift)
Roger Meier26593812015-04-12 16:10:35 +020060
61add_executable(TestServer src/TestServer.cpp)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090062target_link_libraries(TestServer crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
Ben Craig7207c222015-07-06 08:40:35 -050063LINK_AGAINST_THRIFT_LIBRARY(TestServer thrift)
64LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftnb)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090065LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftz)
Roger Meier26593812015-04-12 16:10:35 +020066
67add_executable(TestClient src/TestClient.cpp)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090068target_link_libraries(TestClient crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
Ben Craig7207c222015-07-06 08:40:35 -050069LINK_AGAINST_THRIFT_LIBRARY(TestClient thrift)
70LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftnb)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090071LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftz)
Roger Meier26593812015-04-12 16:10:35 +020072
73add_executable(StressTest src/StressTest.cpp)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090074target_link_libraries(StressTest crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
Ben Craig7207c222015-07-06 08:40:35 -050075LINK_AGAINST_THRIFT_LIBRARY(StressTest thrift)
76LINK_AGAINST_THRIFT_LIBRARY(StressTest thriftnb)
Roger Meier26593812015-04-12 16:10:35 +020077add_test(NAME StressTest COMMAND StressTest)
James E. King III4c57be02019-01-27 11:12:43 -050078add_test(NAME StressTestConcurrent COMMAND StressTest --client-type=concurrent)
Roger Meier26593812015-04-12 16:10:35 +020079
80add_executable(StressTestNonBlocking src/StressTestNonBlocking.cpp)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090081target_link_libraries(StressTestNonBlocking crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
Ben Craig7207c222015-07-06 08:40:35 -050082LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thrift)
83LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftnb)
84LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftz)
Roger Meier26593812015-04-12 16:10:35 +020085add_test(NAME StressTestNonBlocking COMMAND StressTestNonBlocking)
86
87#
88# Common thrift code generation rules
89#
90
James E. King, III58402ff2017-11-17 14:41:46 -050091add_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 Sukegawaca939362015-11-14 00:23:40 +090092 COMMAND ${THRIFT_COMPILER} --gen cpp:templates,cob_style -r ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
Roger Meier26593812015-04-12 16:10:35 +020093)
94
95add_custom_command(OUTPUT gen-cpp/StressTest_types.cpp gen-cpp/StressTest_constants.cpp gen-cpp/Service.cpp
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090096 COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/StressTest.thrift
Roger Meier26593812015-04-12 16:10:35 +020097)