diff --git a/services/tunnelbroker/CMakeLists.txt b/services/tunnelbroker/CMakeLists.txt deleted file mode 100644 --- a/services/tunnelbroker/CMakeLists.txt +++ /dev/null @@ -1,162 +0,0 @@ -PROJECT(tunnelbroker C CXX) - -cmake_minimum_required(VERSION 3.16) - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin) - -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - -set(CMAKE_CXX_STANDARD 17) - -# For C++17 on MacOS, we must set minimum target to 10.14+ -set(CMAKE_OSX_DEPLOYMENT_TARGET 10.14) - -find_package(PkgConfig REQUIRED) - -find_package(double-conversion REQUIRED) -find_package(Folly REQUIRED) -find_package(Protobuf CONFIG REQUIRED) -find_package(gRPC CONFIG REQUIRED) - -# Find AMQP-CPP installation -find_package(amqpcpp CONFIG REQUIRED) - -# Find Cryptopp installation -pkg_check_modules(CRYPTOPP - REQUIRED - IMPORTED_TARGET - libcryptopp=8.6 -) - -# Find Libuv installation -pkg_check_modules(LIBUV - REQUIRED - IMPORTED_TARGET - libuv>=1.43 -) - -if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL "/transferred/tunnelbroker") - # Inside the docker build contex - set(_proto_path "grpc") - set(_shared_path "../shared") -else() - # Inside repo - set(_shared_path "../../shared") - set(_proto_path "../../shared/protos") -endif() - -# Shared Comm protos -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${_proto_path} - ${CMAKE_CURRENT_BINARY_DIR}/protos - EXCLUDE_FROM_ALL -) - -# Shared services code -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../lib/src - ${CMAKE_CURRENT_BINARY_DIR}/common - EXCLUDE_FROM_ALL -) - -find_package(AWSSDK REQUIRED COMPONENTS core dynamodb) -find_package(Boost 1.40 - COMPONENTS program_options thread system context filesystem regex - REQUIRED -) -find_package(OpenSSL REQUIRED) -find_package(glog) - -# Corrosion and CXX Rust integration -find_package(Corrosion REQUIRED) -include(${_shared_path}/cmake/corrosion-cxx.cmake) -add_library_rust(PATH rust-lib NAMESPACE rust) - -file(GLOB_RECURSE SOURCE_CODE "./src/*.cpp") - -set( - LIBS - - comm-services-common - comm-tunnelbroker-grpc - - gRPC::grpc++_reflection - gRPC::grpc++ - ${AWSSDK_LINK_LIBRARIES} - PkgConfig::CRYPTOPP - PkgConfig::LIBUV - ${Boost_LIBRARIES} - ${RUST_LIBS} - amqpcpp - OpenSSL::SSL - glog::glog - double-conversion::double-conversion - Folly::folly - rust::rust-lib -) - -# SERVER -add_executable( - tunnelbroker - - ${SOURCE_CODE} -) - -target_include_directories(tunnelbroker - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ${CMAKE_CURRENT_SOURCE_DIR}/src/Database - ${CMAKE_CURRENT_SOURCE_DIR}/src/DeliveryBroker - ${CMAKE_CURRENT_SOURCE_DIR}/src/Service - ${CMAKE_CURRENT_SOURCE_DIR}/src/Tools - ${CMAKE_CURRENT_SOURCE_DIR}/src/Amqp -) - -target_link_libraries( - tunnelbroker - - ${LIBS} -) - -install( - TARGETS tunnelbroker - RUNTIME DESTINATION bin/ -) - -# TEST -option(BUILD_TESTING "Build test suite" ON) -option(WITH_GFLAGS "Turn on GFLAGS" ON) - -if(BUILD_TESTING) - file(GLOB TEST_CODE "./test/*.cpp") - list(FILTER SOURCE_CODE EXCLUDE REGEX "./src/server.cpp") - enable_testing() - - find_package(GTest CONFIG REQUIRED) - - add_executable( - runTests - - ${SOURCE_CODE} - ${TEST_CODE} - ) - target_link_libraries( - runTests - - ${LIBS} - GTest::gtest_main - ) - - target_include_directories(runTests - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ${CMAKE_CURRENT_SOURCE_DIR}/src/Database - ${CMAKE_CURRENT_SOURCE_DIR}/src/DeliveryBroker - ${CMAKE_CURRENT_SOURCE_DIR}/src/Service - ${CMAKE_CURRENT_SOURCE_DIR}/src/Tools - ${CMAKE_CURRENT_SOURCE_DIR}/src/Amqp - ) - - include(GoogleTest) - gtest_discover_tests(runTests) -endif() diff --git a/services/tunnelbroker/src/libcpp/test/CMakeLists.txt b/services/tunnelbroker/src/libcpp/test/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/services/tunnelbroker/src/libcpp/test/CMakeLists.txt @@ -0,0 +1,110 @@ +PROJECT(tunnelbroker-libcpp C CXX) + +cmake_minimum_required(VERSION 3.16) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin) + +# To fix full path libraries linking we are using the CMP0003 policy +# https://cmake.org/cmake/help/latest/policy/CMP0003.html +if(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) +endif(COMMAND cmake_policy) + +set(CMAKE_CXX_STANDARD 17) + +# For C++17 on MacOS, we must set minimum target to 10.14+ +set(CMAKE_OSX_DEPLOYMENT_TARGET 10.14) + +option(BUILD_TESTING "Build test suite" ON) +option(WITH_GFLAGS "Turn on GFLAGS" ON) +enable_testing() + +find_package(PkgConfig REQUIRED) +find_package(double-conversion REQUIRED) +find_package(Folly REQUIRED) +find_package(amqpcpp CONFIG REQUIRED) +find_package(AWSSDK REQUIRED COMPONENTS + core + dynamodb +) +find_package(Boost 1.40 REQUIRED COMPONENTS + system + program_options + context + filesystem + regex + thread +) +find_package(OpenSSL REQUIRED) +find_package(glog REQUIRED) +find_package(GTest REQUIRED) + +# Find Cryptopp installation +pkg_check_modules(CRYPTOPP + REQUIRED + IMPORTED_TARGET + libcryptopp=8.6 +) + +# Find Libuv installation +pkg_check_modules(LIBUV + REQUIRED + IMPORTED_TARGET + libuv>=1.43 +) + +file(GLOB_RECURSE SHARED_CODE "../../../../lib/src/*.cpp") +file(GLOB_RECURSE SOURCE_CODE "../src/*.cpp") +file(GLOB TEST_CODE "*.cpp") + +set(SHARED_INCLUDE_DIRS ../../../../lib/src) +set( + INCLUDE_DIRS + + ../src + ../src/Database + ../src/DeliveryBroker + ../src/Service + ../src/Tools + ../src/Amqp +) + +set( + LIBS + + ${AWSSDK_LINK_LIBRARIES} + ${Boost_LIBRARIES} + PkgConfig::CRYPTOPP + PkgConfig::LIBUV + amqpcpp + OpenSSL::SSL + glog::glog + double-conversion::double-conversion + Folly::folly +) + +add_executable( + runTests + + ${SHARED_CODE} + ${SOURCE_CODE} + ${TEST_CODE} +) +target_link_libraries( + runTests + + ${LIBS} + gtest + gtest_main +) + +target_include_directories( + runTests + PUBLIC + + ${INCLUDE_DIRS} + ${SHARED_INCLUDE_DIRS} +) + +include(GoogleTest) +gtest_discover_tests(runTests)