diff --git a/services/tunnelbroker/CMakeLists.txt b/services/tunnelbroker/CMakeLists.txt index 54baa24c3..faaee42d2 100644 --- a/services/tunnelbroker/CMakeLists.txt +++ b/services/tunnelbroker/CMakeLists.txt @@ -1,207 +1,150 @@ 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) find_package(PkgConfig REQUIRED) # FIND LIBS -set(protobuf_MODULE_COMPATIBLE TRUE) -find_package(Protobuf CONFIG REQUIRED) -message(STATUS "Using protobuf ${Protobuf_VERSION}") - -set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) -set(_REFLECTION gRPC::grpc++_reflection) -set(_PROTOBUF_PROTOC $) - -# Find gRPC installation -# Looks for gRPCConfig.cmake file installed by gRPC's cmake installation. -find_package(gRPC CONFIG REQUIRED) -message(STATUS "Using gRPC ${gRPC_VERSION}") - -set(_GRPC_GRPCPP gRPC::grpc++) -set(_GRPC_CPP_PLUGIN_EXECUTABLE $) +include(./cmake-components/grpc.cmake) +include(./cmake-components/folly.cmake) # Find AMQP-CPP installation find_package(amqpcpp CONFIG REQUIRED) # Find Cryptopp installation pkg_check_modules(CRYPTOPP REQUIRED libcryptopp=8.6) # Find Libuv installation pkg_check_modules(LIBUV REQUIRED libuv=1.43.0) set(BUILD_TESTING OFF CACHE BOOL "Turn off tests" FORCE) set(WITH_GFLAGS OFF CACHE BOOL "Turn off gflags" FORCE) find_package(AWSSDK REQUIRED COMPONENTS core dynamodb) find_package(Boost 1.40 COMPONENTS program_options thread system REQUIRED) find_package(OpenSSL REQUIRED) add_subdirectory(./lib/glog) # Generated sources get_filename_component(proto "protos/tunnelbroker.proto" ABSOLUTE) get_filename_component(proto_path "${proto}" PATH) set(GENERATED_BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/gen") set(GENERATED_CODE_DIR "${GENERATED_BASE_DIR}/_generated") file(MAKE_DIRECTORY ${GENERATED_CODE_DIR}) set(proto_srcs "${GENERATED_CODE_DIR}/tunnelbroker.pb.cc") set(proto_hdrs "${GENERATED_CODE_DIR}/tunnelbroker.pb.h") set(grpc_srcs "${GENERATED_CODE_DIR}/tunnelbroker.grpc.pb.cc") set(grpc_hdrs "${GENERATED_CODE_DIR}/tunnelbroker.grpc.pb.h") add_custom_command( OUTPUT "${proto_srcs}" "${proto_hdrs}" "${grpc_srcs}" "${grpc_hdrs}" COMMAND ${_PROTOBUF_PROTOC} ARGS --grpc_out "${GENERATED_CODE_DIR}" --cpp_out "${GENERATED_CODE_DIR}" -I "${proto_path}" --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}" "${proto}" DEPENDS "${proto}" ) file(GLOB SOURCE_CODE "./src/*.cpp" "./src/**/*.cpp") set(GENERATED_CODE ${proto_srcs} ${proto_hdrs} ${grpc_srcs} ${grpc_hdrs}) file(GLOB DOUBLE_CONVERSION_SOURCES "./lib/double-conversion/double-conversion/*.cc") -add_definitions( - -DFOLLY_NO_CONFIG=1 - -DFOLLY_HAVE_CLOCK_GETTIME=1 - -DFOLLY_HAVE_MEMRCHR=1 - -DFOLLY_USE_LIBCPP=0 - -DFOLLY_MOBILE=0 -) - include_directories( ./src ./src/Database ./src/DeliveryBroker ./src/Service ./src/Tools ./src/Amqp ${GENERATED_BASE_DIR} - ./lib/folly + ${FOLLY_INCLUDES} ./lib/double-conversion ${Boost_INCLUDE_DIR} ${CRYPTOPP_INCLUDE_DIRS} ${LIBUV_INCLUDE_DIRS} ) set( SOURCE_CODE - # folly - ./lib/folly/folly/detail/Futex.cpp - ./lib/folly/folly/synchronization/ParkingLot.cpp - ./lib/folly/folly/lang/SafeAssert.cpp - ./lib/folly/folly/FileUtil.cpp - ./lib/folly/folly/Subprocess.cpp - ./lib/folly/folly/File.cpp - ./lib/folly/folly/Format.cpp - ./lib/folly/folly/Conv.cpp - ./lib/folly/folly/io/IOBuf.cpp - ./lib/folly/folly/memory/detail/MallocImpl.cpp - ./lib/folly/folly/ScopeGuard.cpp - ./lib/folly/folly/hash/SpookyHashV2.cpp - ./lib/folly/folly/io/IOBufQueue.cpp - ./lib/folly/folly/lang/Assume.cpp - ./lib/folly/folly/String.cpp - ./lib/folly/folly/portability/SysUio.cpp - ./lib/folly/folly/net/NetOps.cpp - ./lib/folly/folly/synchronization/Hazptr.cpp - ./lib/folly/folly/detail/ThreadLocalDetail.cpp - ./lib/folly/folly/SharedMutex.cpp - ./lib/folly/folly/concurrency/CacheLocality.cpp - ./lib/folly/folly/detail/StaticSingletonManager.cpp - ./lib/folly/folly/executors/ThreadPoolExecutor.cpp - ./lib/folly/folly/executors/GlobalThreadPoolList.cpp - ./lib/folly/folly/Demangle.cpp - ./lib/folly/folly/synchronization/AsymmetricMemoryBarrier.cpp - ./lib/folly/folly/io/async/Request.cpp - ./lib/folly/folly/detail/MemoryIdler.cpp - ./lib/folly/folly/detail/AtFork.cpp - ./lib/folly/folly/Executor.cpp - ./lib/folly/folly/lang/CString.cpp - ./lib/folly/folly/portability/SysMembarrier.cpp - ./lib/folly/folly/container/detail/F14Table.cpp - ./lib/folly/folly/detail/UniqueInstance.cpp - ./lib/folly/folly/executors/QueuedImmediateExecutor.cpp - ./lib/folly/folly/memory/MallctlHelper.cpp - ${DOUBLE_CONVERSION_SOURCES} ${GENERATED_CODE} ${SOURCE_CODE} ) set( LIBS - ${_GRPC_GRPCPP} + ${GRPC_LIBS} ${_PROTOBUF_LIBPROTOBUF} ${_REFLECTION} ${AWSSDK_LINK_LIBRARIES} ${CRYPTOPP_LIBRARIES} ${LIBUV_LIBRARIES} ${Boost_LIBRARIES} amqpcpp OpenSSL::SSL glog::glog ) #SERVER add_executable( tunnelbroker + ${FOLLY_SOURCES} ${GENERATED_CODE} ${SOURCE_CODE} ) target_link_libraries( tunnelbroker ${LIBS} ) install( TARGETS tunnelbroker RUNTIME DESTINATION bin/ ) # TEST if ($ENV{COMM_TEST_SERVICES} MATCHES 1) file(GLOB TEST_CODE "./test/*.cpp") list(FILTER SOURCE_CODE EXCLUDE REGEX "./src/server.cpp") enable_testing() find_package(GTest REQUIRED) include_directories(${GTEST_INCLUDE_DIR}) add_executable( runTests + ${FOLLY_SOURCES} ${SOURCE_CODE} ${TEST_CODE} ) target_link_libraries( runTests ${LIBS} gtest gtest_main ) add_test( NAME runTests COMMAND runTests ) endif() diff --git a/services/tunnelbroker/cmake-components/folly.cmake b/services/tunnelbroker/cmake-components/folly.cmake new file mode 100644 index 000000000..ad9387051 --- /dev/null +++ b/services/tunnelbroker/cmake-components/folly.cmake @@ -0,0 +1,54 @@ +add_definitions( + -DFOLLY_NO_CONFIG=1 + -DFOLLY_HAVE_CLOCK_GETTIME=1 + -DFOLLY_HAVE_MEMRCHR=1 + -DFOLLY_USE_LIBCPP=0 + -DFOLLY_MOBILE=0 +) + +set( + FOLLY_SOURCES + + ./lib/folly/folly/detail/Futex.cpp + ./lib/folly/folly/synchronization/ParkingLot.cpp + ./lib/folly/folly/lang/SafeAssert.cpp + ./lib/folly/folly/FileUtil.cpp + ./lib/folly/folly/Subprocess.cpp + ./lib/folly/folly/File.cpp + ./lib/folly/folly/Format.cpp + ./lib/folly/folly/Conv.cpp + ./lib/folly/folly/io/IOBuf.cpp + ./lib/folly/folly/memory/detail/MallocImpl.cpp + ./lib/folly/folly/ScopeGuard.cpp + ./lib/folly/folly/hash/SpookyHashV2.cpp + ./lib/folly/folly/io/IOBufQueue.cpp + ./lib/folly/folly/lang/Assume.cpp + ./lib/folly/folly/String.cpp + ./lib/folly/folly/portability/SysUio.cpp + ./lib/folly/folly/net/NetOps.cpp + ./lib/folly/folly/synchronization/Hazptr.cpp + ./lib/folly/folly/detail/ThreadLocalDetail.cpp + ./lib/folly/folly/SharedMutex.cpp + ./lib/folly/folly/concurrency/CacheLocality.cpp + ./lib/folly/folly/detail/StaticSingletonManager.cpp + ./lib/folly/folly/executors/ThreadPoolExecutor.cpp + ./lib/folly/folly/executors/GlobalThreadPoolList.cpp + ./lib/folly/folly/Demangle.cpp + ./lib/folly/folly/synchronization/AsymmetricMemoryBarrier.cpp + ./lib/folly/folly/io/async/Request.cpp + ./lib/folly/folly/detail/MemoryIdler.cpp + ./lib/folly/folly/detail/AtFork.cpp + ./lib/folly/folly/Executor.cpp + ./lib/folly/folly/lang/CString.cpp + ./lib/folly/folly/portability/SysMembarrier.cpp + ./lib/folly/folly/container/detail/F14Table.cpp + ./lib/folly/folly/detail/UniqueInstance.cpp + ./lib/folly/folly/executors/QueuedImmediateExecutor.cpp + ./lib/folly/folly/memory/MallctlHelper.cpp +) + +set( + FOLLY_INCLUDES + + ./lib/folly +) diff --git a/services/tunnelbroker/cmake-components/grpc.cmake b/services/tunnelbroker/cmake-components/grpc.cmake new file mode 100644 index 000000000..c64424fbd --- /dev/null +++ b/services/tunnelbroker/cmake-components/grpc.cmake @@ -0,0 +1,22 @@ +# protobuf +set(protobuf_MODULE_COMPATIBLE TRUE) +find_package(Protobuf CONFIG REQUIRED) +message(STATUS "Using protobuf ${Protobuf_VERSION}") + +set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) +set(_PROTOBUF_PROTOC $) + +# Find gRPC installation +find_package(gRPC CONFIG REQUIRED) +message(STATUS "Using gRPC ${gRPC_VERSION}") + +set(_GRPC_GRPCPP gRPC::grpc++) +set(_GRPC_CPP_PLUGIN_EXECUTABLE $) + +set( + GRPC_LIBS + + ${_GRPC_GRPCPP} + ${_PROTOBUF_LIBPROTOBUF} + gRPC::grpc++_reflection +)