THRIFT-2850 CMake for Apache Thrift
Client: Cpp
Patch: Ben Craig
This closes #534
diff --git a/test/cpp/CMakeLists.txt b/test/cpp/CMakeLists.txt
index 79cc008..2d75f2e 100755
--- a/test/cpp/CMakeLists.txt
+++ b/test/cpp/CMakeLists.txt
@@ -17,10 +17,19 @@
# under the License.
#
+# Contains the thrift specific LINK_AGAINST_THRIFT_LIBRARY
+include(ThriftMacros)
+
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.53.0 REQUIRED COMPONENTS program_options system filesystem)
include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
+find_package(OpenSSL REQUIRED)
+include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
+
+find_package(Libevent REQUIRED) # Libevent comes with CMake support from upstream
+include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
+
#Make sure gen-cpp files can be included
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
include_directories("${CMAKE_CURRENT_BINARY_DIR}/gen-cpp")
@@ -34,28 +43,37 @@
src/ThriftTest_extras.cpp
)
add_library(crosstestgencpp STATIC ${crosstestgencpp_SOURCES})
-target_link_libraries(crosstestgencpp thrift)
+LINK_AGAINST_THRIFT_LIBRARY(crosstestgencpp thrift)
set(crossstressgencpp_SOURCES
gen-cpp/Service.cpp
- gen-cpp/StressTest_types.cpp
+ #gen-cpp/StressTest_types.cpp #basically empty, so omitting
gen-cpp/StressTest_constants.cpp
)
add_library(crossstressgencpp STATIC ${crossstressgencpp_SOURCES})
-target_link_libraries(crossstressgencpp thrift)
+LINK_AGAINST_THRIFT_LIBRARY(crossstressgencpp thrift)
add_executable(TestServer src/TestServer.cpp)
-target_link_libraries(TestServer thrift thriftnb crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
+target_link_libraries(TestServer crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
+LINK_AGAINST_THRIFT_LIBRARY(TestServer thrift)
+LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftnb)
add_executable(TestClient src/TestClient.cpp)
-target_link_libraries(TestClient thrift thriftnb crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
+target_link_libraries(TestClient crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
+LINK_AGAINST_THRIFT_LIBRARY(TestClient thrift)
+LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftnb)
add_executable(StressTest src/StressTest.cpp)
-target_link_libraries(StressTest thrift thriftnb crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
+target_link_libraries(StressTest crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
+LINK_AGAINST_THRIFT_LIBRARY(StressTest thrift)
+LINK_AGAINST_THRIFT_LIBRARY(StressTest thriftnb)
add_test(NAME StressTest COMMAND StressTest)
add_executable(StressTestNonBlocking src/StressTestNonBlocking.cpp)
-target_link_libraries(StressTestNonBlocking thrift thriftz thriftnb crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
+target_link_libraries(StressTestNonBlocking crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
+LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thrift)
+LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftnb)
+LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftz)
add_test(NAME StressTestNonBlocking COMMAND StressTestNonBlocking)
#