diff --git a/CMakeLists.txt b/CMakeLists.txt index 03f5236..5c97f25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ set(CARTOGRAPHER_PATCH_VERSION 0) set(CARTOGRAPHER_VERSION ${CARTOGRAPHER_MAJOR_VERSION}.${CARTOGRAPHER_MINOR_VERSION}.${CARTOGRAPHER_PATCH_VERSION}) set(CARTOGRAPHER_SOVERSION ${CARTOGRAPHER_MAJOR_VERSION}.${CARTOGRAPHER_MINOR_VERSION}) option(BUILD_GRPC "build Cartographer gRPC support" false) +option(BUILD_PROMETHEUS "build Prometheus monitoring support" false) include("${PROJECT_SOURCE_DIR}/cmake/functions.cmake") google_initialize_cartographer_project() @@ -153,6 +154,10 @@ if(${BUILD_GRPC}) SRCS cartographer_grpc/map_builder_server_main.cc ) + target_link_libraries(cartographer_grpc_server PUBLIC grpc++) + if(${BUILD_PROMETHEUS}) + target_link_libraries(cartographer_grpc_server PUBLIC prometheus-cpp) + endif() endif() foreach(ABS_FIL ${ALL_TESTS}) @@ -165,6 +170,9 @@ foreach(ABS_FIL ${ALL_TESTS}) if(${BUILD_GRPC}) target_link_libraries("${TEST_TARGET_NAME}" PUBLIC grpc++) endif() + if(${BUILD_PROMETHEUS}) + target_link_libraries(${PROJECT_NAME} PUBLIC prometheus-cpp) + endif() endforeach() target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC @@ -199,6 +207,10 @@ target_link_libraries(${PROJECT_NAME} PUBLIC ${PROTOBUF_LIBRARY} pthread) if(${BUILD_GRPC}) target_link_libraries(${PROJECT_NAME} PUBLIC grpc++) endif() +if(${BUILD_PROMETHEUS}) + target_link_libraries(${PROJECT_NAME} PUBLIC prometheus-cpp) + target_compile_definitions(${PROJECT_NAME} PRIVATE USE_PROMETHEUS=1) +endif() # Add the binary directory first, so that port.h is included after it has # been generated. diff --git a/Dockerfile.trusty b/Dockerfile.trusty index b80ba0e..afd68bd 100644 --- a/Dockerfile.trusty +++ b/Dockerfile.trusty @@ -21,5 +21,7 @@ COPY scripts/install_proto3.sh cartographer/scripts/ RUN cartographer/scripts/install_proto3.sh && rm -rf protobuf COPY scripts/install_grpc.sh cartographer/scripts/ RUN cartographer/scripts/install_grpc.sh && rm -rf grpc +COPY scripts/install_prometheus_cpp.sh cartographer/scripts/ +RUN cartographer/scripts/install_prometheus_cpp.sh && rm -rf prometheus-cpp COPY . cartographer RUN cartographer/scripts/install_cartographer_cmake_with_grpc.sh && rm -rf cartographer diff --git a/scripts/install_cartographer_cmake_with_grpc.sh b/scripts/install_cartographer_cmake_with_grpc.sh index 0d1797e..c73af23 100755 --- a/scripts/install_cartographer_cmake_with_grpc.sh +++ b/scripts/install_cartographer_cmake_with_grpc.sh @@ -21,7 +21,7 @@ set -o verbose cd cartographer mkdir build cd build -cmake .. -DBUILD_GRPC=ON -G Ninja +cmake .. -DBUILD_GRPC=ON -DBUILD_PROMETHEUS=ON -G Ninja ninja CTEST_OUTPUT_ON_FAILURE=1 ninja test sudo ninja install diff --git a/scripts/install_prometheus_cpp.sh b/scripts/install_prometheus_cpp.sh new file mode 100755 index 0000000..d4ab9e9 --- /dev/null +++ b/scripts/install_prometheus_cpp.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# Copyright 2018 The Cartographer Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o verbose + +VERSION="v0.2" +# Digest: a5d981dab82ad6b90f78141eb189694d69c3fe0f + +git clone --branch ${VERSION} --depth 1 https://github.com/jupp0r/prometheus-cpp.git +cd prometheus-cpp +git submodule update --init +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make +sudo make install