diff --git a/services/tunnelbroker/CMakeLists.txt b/services/tunnelbroker/CMakeLists.txt index 28818758c..341a6c4ec 100644 --- a/services/tunnelbroker/CMakeLists.txt +++ b/services/tunnelbroker/CMakeLists.txt @@ -1,221 +1,216 @@ 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 $) # gRPC building parameters set(gRPC_BUILD_CSHARP_EXT OFF) set(gRPC_SSL_PROVIDER "package" CACHE STRING "SSL library provider") # Disable unused plugins set(gRPC_BUILD_GRPC_PHP_PLUGIN OFF) set(gRPC_BUILD_GRPC_RUBY_PLUGIN OFF) set(gRPC_BUILD_GRPC_PYTHON_PLUGIN OFF) set(gRPC_BUILD_GRPC_CSHARP_PLUGIN OFF) # 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 $) # Find AMQP-CPP installation -set(AMQPCPP_ROOT "/usr/lib/AMQP-CPP") -set(AMQPCPP_INCLUDE_DIR ${AMQPCPP_ROOT}/include) -set(AMQPCPP_LIBRARIES ${AMQPCPP_ROOT}/build/bin/libamqpcpp.so) +find_package(amqpcpp CONFIG REQUIRED) # Find Cryptopp installation -set(CRYPTOPP_ROOT "/usr/lib/cryptopp/build") -set(CRYPTOPP_INCLUDE_DIR ${CRYPTOPP_ROOT}/include) -set(CRYPTOPP_LIBRARIES ${CRYPTOPP_ROOT}/lib/libcryptopp.a) +pkg_check_modules(CRYPTOPP REQUIRED libcryptopp=8.6) # Find Libuv installation -set(LIBUV_ROOT "/usr/lib/libuv") -set(LIBUV_INCLUDE_DIR ${LIBUV_ROOT}/include) -set(LIBUV_LIBRARIES ${LIBUV_ROOT}/build/libuv.so) +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 ./lib/double-conversion ${Boost_INCLUDE_DIR} - ${AMQPCPP_INCLUDE_DIR} - ${CRYPTOPP_INCLUDE_DIR} - ${LIBUV_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} ${_PROTOBUF_LIBPROTOBUF} ${_REFLECTION} ${AWSSDK_LINK_LIBRARIES} - ${AMQPCPP_LIBRARIES} ${CRYPTOPP_LIBRARIES} ${LIBUV_LIBRARIES} ${Boost_LIBRARIES} + amqpcpp OpenSSL::SSL glog::glog ) #SERVER add_executable( tunnelbroker ${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 ${SOURCE_CODE} ${TEST_CODE} ) target_link_libraries( runTests ${LIBS} gtest gtest_main ) add_test( NAME runTests COMMAND runTests ) endif() diff --git a/services/tunnelbroker/docker/install_cryptopp.sh b/services/tunnelbroker/docker/install_cryptopp.sh index 1b4953119..aea4b2c5b 100755 --- a/services/tunnelbroker/docker/install_cryptopp.sh +++ b/services/tunnelbroker/docker/install_cryptopp.sh @@ -1,20 +1,21 @@ #!/bin/bash set -e if [[ -d /usr/lib/cryptopp ]]; then echo "Cryptopp sources already exists, you can try remove this container/image and recreate it." echo "Installation skipped." exit 0 fi pushd /usr/lib git clone --recurse-submodules -b CRYPTOPP_8_6_0 --single-branch https://github.com/weidai11/cryptopp pushd cryptopp mkdir build CXXFLAGS="-DNDEBUG -g2 -O3 -std=c++11" make -make install PREFIX=/usr/lib/cryptopp/build +make libcryptopp.pc +make install popd # cryptopp popd # /usr/lib diff --git a/services/tunnelbroker/docker/install_libuv.sh b/services/tunnelbroker/docker/install_libuv.sh index f62cc279d..02a6863c5 100755 --- a/services/tunnelbroker/docker/install_libuv.sh +++ b/services/tunnelbroker/docker/install_libuv.sh @@ -1,19 +1,21 @@ #!/bin/bash set -e if [[ -d /usr/lib/libuv ]]; then echo "Libuv sources already exists, you can try remove this container/image and recreate it." echo "Installation skipped." exit 0 fi pushd /usr/lib git clone --recurse-submodules -b v1.43.0 --single-branch https://github.com/libuv/libuv.git pushd libuv mkdir build -(cd build && cmake .. -DBUILD_TESTING=OFF) -cmake --build build +cd build +cmake .. -DBUILD_TESTING=OFF +make +make install popd # libuv popd # /usr/lib