blob: cdd63dbf0db63eafe15083ce73cbeaffa3c4ba68 [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
Ben Craig7207c222015-07-06 08:40:35 -050020# Contains the thrift specific LINK_AGAINST_THRIFT_LIBRARY
21include(ThriftMacros)
22
Roger Meier26593812015-04-12 16:10:35 +020023include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
24
Ben Craig7207c222015-07-06 08:40:35 -050025find_package(OpenSSL REQUIRED)
26include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
27
28find_package(Libevent REQUIRED) # Libevent comes with CMake support from upstream
29include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
30
Roger Meier26593812015-04-12 16:10:35 +020031#Make sure gen-cpp files can be included
32include_directories("${CMAKE_CURRENT_BINARY_DIR}")
33include_directories("${CMAKE_CURRENT_BINARY_DIR}/gen-cpp")
34include_directories("${PROJECT_SOURCE_DIR}/lib/cpp/src")
35
Roger Meier26593812015-04-12 16:10:35 +020036set(crosstestgencpp_SOURCES
James E. King, III58402ff2017-11-17 14:41:46 -050037 gen-cpp/SecondService.cpp
Roger Meier26593812015-04-12 16:10:35 +020038 gen-cpp/ThriftTest.cpp
39 gen-cpp/ThriftTest_types.cpp
40 gen-cpp/ThriftTest_constants.cpp
Marco Molteni83494252015-04-16 13:50:20 +020041 src/ThriftTest_extras.cpp
Roger Meier26593812015-04-12 16:10:35 +020042)
43add_library(crosstestgencpp STATIC ${crosstestgencpp_SOURCES})
Ben Craig7207c222015-07-06 08:40:35 -050044LINK_AGAINST_THRIFT_LIBRARY(crosstestgencpp thrift)
Roger Meier26593812015-04-12 16:10:35 +020045
46set(crossstressgencpp_SOURCES
47 gen-cpp/Service.cpp
James E. King, III58402ff2017-11-17 14:41:46 -050048 gen-cpp/StressTest_types.cpp
Roger Meier26593812015-04-12 16:10:35 +020049 gen-cpp/StressTest_constants.cpp
50)
51add_library(crossstressgencpp STATIC ${crossstressgencpp_SOURCES})
Ben Craig7207c222015-07-06 08:40:35 -050052LINK_AGAINST_THRIFT_LIBRARY(crossstressgencpp thrift)
Roger Meier26593812015-04-12 16:10:35 +020053
54add_executable(TestServer src/TestServer.cpp)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090055target_link_libraries(TestServer crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
Ben Craig7207c222015-07-06 08:40:35 -050056LINK_AGAINST_THRIFT_LIBRARY(TestServer thrift)
57LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftnb)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090058LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftz)
Roger Meier26593812015-04-12 16:10:35 +020059
60add_executable(TestClient src/TestClient.cpp)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090061target_link_libraries(TestClient crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
Ben Craig7207c222015-07-06 08:40:35 -050062LINK_AGAINST_THRIFT_LIBRARY(TestClient thrift)
63LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftnb)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090064LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftz)
Roger Meier26593812015-04-12 16:10:35 +020065
66add_executable(StressTest src/StressTest.cpp)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090067target_link_libraries(StressTest crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
Ben Craig7207c222015-07-06 08:40:35 -050068LINK_AGAINST_THRIFT_LIBRARY(StressTest thrift)
69LINK_AGAINST_THRIFT_LIBRARY(StressTest thriftnb)
Roger Meier26593812015-04-12 16:10:35 +020070add_test(NAME StressTest COMMAND StressTest)
71
72add_executable(StressTestNonBlocking src/StressTestNonBlocking.cpp)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090073target_link_libraries(StressTestNonBlocking crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
Ben Craig7207c222015-07-06 08:40:35 -050074LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thrift)
75LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftnb)
76LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftz)
Roger Meier26593812015-04-12 16:10:35 +020077add_test(NAME StressTestNonBlocking COMMAND StressTestNonBlocking)
78
79#
80# Common thrift code generation rules
81#
82
James E. King, III58402ff2017-11-17 14:41:46 -050083add_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 +090084 COMMAND ${THRIFT_COMPILER} --gen cpp:templates,cob_style -r ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
Roger Meier26593812015-04-12 16:10:35 +020085)
86
87add_custom_command(OUTPUT gen-cpp/StressTest_types.cpp gen-cpp/StressTest_constants.cpp gen-cpp/Service.cpp
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090088 COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/StressTest.thrift
Roger Meier26593812015-04-12 16:10:35 +020089)