2016-08-03 18:48:29 +08:00
|
|
|
# Copyright 2016 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.
|
|
|
|
|
2018-07-26 03:40:06 +08:00
|
|
|
cmake_minimum_required(VERSION 3.2)
|
2016-08-03 18:48:29 +08:00
|
|
|
|
|
|
|
project(cartographer)
|
2016-12-20 18:24:08 +08:00
|
|
|
|
2016-08-03 18:48:29 +08:00
|
|
|
set(CARTOGRAPHER_MAJOR_VERSION 1)
|
|
|
|
set(CARTOGRAPHER_MINOR_VERSION 0)
|
|
|
|
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})
|
2017-11-22 23:29:01 +08:00
|
|
|
option(BUILD_GRPC "build Cartographer gRPC support" false)
|
2018-07-09 19:11:51 +08:00
|
|
|
set(CARTOGRAPHER_HAS_GRPC ${BUILD_GRPC})
|
2018-02-19 22:54:10 +08:00
|
|
|
option(BUILD_PROMETHEUS "build Prometheus monitoring support" false)
|
2016-08-03 18:48:29 +08:00
|
|
|
|
2017-02-09 22:57:54 +08:00
|
|
|
include("${PROJECT_SOURCE_DIR}/cmake/functions.cmake")
|
2016-10-12 19:39:03 +08:00
|
|
|
google_initialize_cartographer_project()
|
2016-10-12 21:38:12 +08:00
|
|
|
google_enable_testing()
|
2016-08-03 18:48:29 +08:00
|
|
|
|
2020-06-24 16:53:03 +08:00
|
|
|
find_package(absl REQUIRED)
|
2018-12-17 00:04:23 +08:00
|
|
|
set(BOOST_COMPONENTS iostreams)
|
|
|
|
if(WIN32)
|
|
|
|
list(APPEND BOOST_COMPONENTS zlib)
|
|
|
|
set(Boost_USE_STATIC_LIBS FALSE)
|
|
|
|
endif()
|
|
|
|
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
2018-03-09 17:24:19 +08:00
|
|
|
find_package(Ceres REQUIRED COMPONENTS SuiteSparse)
|
2016-08-03 18:48:29 +08:00
|
|
|
find_package(Eigen3 REQUIRED)
|
|
|
|
find_package(LuaGoogle REQUIRED)
|
2019-03-08 18:43:07 +08:00
|
|
|
if(WIN32)
|
|
|
|
# On Windows, Protobuf is incorrectly found by the bundled CMake module, so prefer native CMake config.
|
|
|
|
set(protobuf_MODULE_COMPATIBLE TRUE CACHE INTERNAL "")
|
|
|
|
find_package(Protobuf 3.0.0 CONFIG)
|
|
|
|
else()
|
2018-12-17 00:04:23 +08:00
|
|
|
find_package(Protobuf 3.0.0 REQUIRED)
|
|
|
|
endif()
|
2016-12-20 18:24:08 +08:00
|
|
|
|
2018-03-23 17:52:48 +08:00
|
|
|
if (${BUILD_GRPC})
|
|
|
|
find_package(async_grpc REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2018-12-18 21:19:29 +08:00
|
|
|
if(${BUILD_PROMETHEUS})
|
|
|
|
find_package( ZLIB REQUIRED )
|
|
|
|
endif()
|
|
|
|
|
2016-12-20 18:24:08 +08:00
|
|
|
include(FindPkgConfig)
|
2018-12-17 00:04:23 +08:00
|
|
|
if (NOT WIN32)
|
|
|
|
PKG_SEARCH_MODULE(CAIRO REQUIRED cairo>=1.12.16)
|
|
|
|
else()
|
|
|
|
find_library(CAIRO_LIBRARIES cairo)
|
|
|
|
endif()
|
2016-08-03 18:48:29 +08:00
|
|
|
|
|
|
|
# Only build the documentation if we can find Sphinx.
|
|
|
|
find_package(Sphinx)
|
|
|
|
if(SPHINX_FOUND)
|
2016-08-23 23:22:04 +08:00
|
|
|
add_subdirectory("docs")
|
2016-08-03 18:48:29 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Install catkin package.xml
|
|
|
|
install(FILES package.xml DESTINATION share/cartographer)
|
|
|
|
|
2017-02-09 22:57:54 +08:00
|
|
|
set(CARTOGRAPHER_CONFIGURATION_FILES_DIRECTORY ${CMAKE_INSTALL_PREFIX}/share/cartographer/configuration_files
|
|
|
|
CACHE PATH ".lua configuration files directory")
|
|
|
|
|
2016-08-03 18:48:29 +08:00
|
|
|
install(DIRECTORY configuration_files DESTINATION share/cartographer/)
|
|
|
|
|
2016-10-12 19:39:03 +08:00
|
|
|
install(DIRECTORY cmake DESTINATION share/cartographer/)
|
|
|
|
|
2018-04-10 21:14:59 +08:00
|
|
|
file(GLOB_RECURSE ALL_LIBRARY_HDRS "cartographer/*.h")
|
|
|
|
file(GLOB_RECURSE ALL_LIBRARY_SRCS "cartographer/*.cc")
|
2018-05-01 00:02:54 +08:00
|
|
|
file(GLOB_RECURSE TEST_LIBRARY_HDRS "cartographer/fake_*.h" "cartographer/*test_helpers*.h" "cartographer/mock_*.h")
|
|
|
|
file(GLOB_RECURSE TEST_LIBRARY_SRCS "cartographer/fake_*.cc" "cartographer/*test_helpers*.cc" "cartographer/mock_*.cc")
|
2018-04-10 21:14:59 +08:00
|
|
|
file(GLOB_RECURSE ALL_TESTS "cartographer/*_test.cc")
|
|
|
|
file(GLOB_RECURSE ALL_EXECUTABLES "cartographer/*_main.cc")
|
2018-03-07 01:39:46 +08:00
|
|
|
|
|
|
|
# Remove dotfiles/-folders that could potentially pollute the build.
|
|
|
|
file(GLOB_RECURSE ALL_DOTFILES ".*/*")
|
|
|
|
if (ALL_DOTFILES)
|
|
|
|
list(REMOVE_ITEM ALL_LIBRARY_HDRS ${ALL_DOTFILES})
|
|
|
|
list(REMOVE_ITEM ALL_LIBRARY_SRCS ${ALL_DOTFILES})
|
2018-05-01 00:02:54 +08:00
|
|
|
list(REMOVE_ITEM TEST_LIBRARY_HDRS ${ALL_DOTFILES})
|
|
|
|
list(REMOVE_ITEM TEST_LIBRARY_SRCS ${ALL_DOTFILES})
|
2018-03-07 01:39:46 +08:00
|
|
|
list(REMOVE_ITEM ALL_TESTS ${ALL_DOTFILES})
|
|
|
|
list(REMOVE_ITEM ALL_EXECUTABLES ${ALL_DOTFILES})
|
|
|
|
endif()
|
2017-12-07 03:34:07 +08:00
|
|
|
list(REMOVE_ITEM ALL_LIBRARY_SRCS ${ALL_EXECUTABLES})
|
2018-05-01 00:02:54 +08:00
|
|
|
list(REMOVE_ITEM ALL_LIBRARY_SRCS ${ALL_TESTS})
|
|
|
|
list(REMOVE_ITEM ALL_LIBRARY_HDRS ${TEST_LIBRARY_HDRS})
|
|
|
|
list(REMOVE_ITEM ALL_LIBRARY_SRCS ${TEST_LIBRARY_SRCS})
|
2018-03-05 19:41:38 +08:00
|
|
|
file(GLOB_RECURSE ALL_GRPC_FILES "cartographer/cloud/*")
|
|
|
|
file(GLOB_RECURSE ALL_PROMETHEUS_FILES "cartographer/cloud/metrics/prometheus/*")
|
2018-02-20 01:11:59 +08:00
|
|
|
list(REMOVE_ITEM ALL_GRPC_FILES ${ALL_PROMETHEUS_FILES})
|
2017-11-22 23:29:01 +08:00
|
|
|
if (NOT ${BUILD_GRPC})
|
2017-12-07 03:34:07 +08:00
|
|
|
list(REMOVE_ITEM ALL_LIBRARY_HDRS ${ALL_GRPC_FILES})
|
|
|
|
list(REMOVE_ITEM ALL_LIBRARY_SRCS ${ALL_GRPC_FILES})
|
2018-05-01 00:02:54 +08:00
|
|
|
list(REMOVE_ITEM TEST_LIBRARY_HDRS ${ALL_GRPC_FILES})
|
|
|
|
list(REMOVE_ITEM TEST_LIBRARY_SRCS ${ALL_GRPC_FILES})
|
2017-12-07 03:34:07 +08:00
|
|
|
list(REMOVE_ITEM ALL_TESTS ${ALL_GRPC_FILES})
|
|
|
|
list(REMOVE_ITEM ALL_EXECUTABLES ${ALL_GRPC_FILES})
|
2017-11-22 23:29:01 +08:00
|
|
|
endif()
|
2018-02-20 01:11:59 +08:00
|
|
|
if (NOT ${BUILD_PROMETHEUS})
|
|
|
|
list(REMOVE_ITEM ALL_LIBRARY_HDRS ${ALL_PROMETHEUS_FILES})
|
|
|
|
list(REMOVE_ITEM ALL_LIBRARY_SRCS ${ALL_PROMETHEUS_FILES})
|
2018-05-01 00:02:54 +08:00
|
|
|
list(REMOVE_ITEM TEST_LIBRARY_HDRS ${ALL_PROMETHEUS_FILES})
|
|
|
|
list(REMOVE_ITEM TEST_LIBRARY_SRCS ${ALL_PROMETHEUS_FILES})
|
2018-02-20 01:11:59 +08:00
|
|
|
list(REMOVE_ITEM ALL_TESTS ${ALL_PROMETHEUS_FILES})
|
|
|
|
list(REMOVE_ITEM ALL_EXECUTABLES ${ALL_PROMETHEUS_FILES})
|
|
|
|
endif()
|
2018-05-02 22:39:55 +08:00
|
|
|
set(INSTALL_SOURCE_HDRS ${ALL_LIBRARY_HDRS} ${TEST_LIBRARY_HDRS})
|
2018-02-27 23:25:53 +08:00
|
|
|
file(GLOB_RECURSE INTERNAL_HDRS "cartographer/*/internal/*.h")
|
2017-12-07 03:34:07 +08:00
|
|
|
list(REMOVE_ITEM INSTALL_SOURCE_HDRS ${INTERNAL_HDRS})
|
2016-12-20 18:24:08 +08:00
|
|
|
|
2018-04-10 21:14:59 +08:00
|
|
|
file(GLOB_RECURSE ALL_PROTOS "cartographer/*.proto")
|
|
|
|
file(GLOB_RECURSE ALL_GRPC_SERVICES "cartographer/*_service.proto")
|
2017-11-22 23:29:01 +08:00
|
|
|
list(REMOVE_ITEM ALL_PROTOS ALL_GRPC_SERVICES)
|
|
|
|
if (NOT ${BUILD_GRPC})
|
2017-12-07 03:34:07 +08:00
|
|
|
list(REMOVE_ITEM ALL_PROTOS ${ALL_GRPC_FILES})
|
2017-11-22 23:29:01 +08:00
|
|
|
endif()
|
|
|
|
|
2017-11-28 17:50:30 +08:00
|
|
|
# TODO(cschuet): Move proto compilation to separate function.
|
2016-12-20 18:24:08 +08:00
|
|
|
set(ALL_PROTO_SRCS)
|
|
|
|
set(ALL_PROTO_HDRS)
|
|
|
|
foreach(ABS_FIL ${ALL_PROTOS})
|
2017-02-09 22:57:54 +08:00
|
|
|
file(RELATIVE_PATH REL_FIL ${PROJECT_SOURCE_DIR} ${ABS_FIL})
|
2016-12-20 18:24:08 +08:00
|
|
|
get_filename_component(DIR ${REL_FIL} DIRECTORY)
|
|
|
|
get_filename_component(FIL_WE ${REL_FIL} NAME_WE)
|
|
|
|
|
2017-02-09 22:57:54 +08:00
|
|
|
list(APPEND ALL_PROTO_SRCS "${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.cc")
|
|
|
|
list(APPEND ALL_PROTO_HDRS "${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.h")
|
2016-12-20 18:24:08 +08:00
|
|
|
|
|
|
|
add_custom_command(
|
2017-02-09 22:57:54 +08:00
|
|
|
OUTPUT "${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.cc"
|
|
|
|
"${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.h"
|
2019-01-03 16:19:00 +08:00
|
|
|
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
|
2017-02-09 22:57:54 +08:00
|
|
|
ARGS --cpp_out ${PROJECT_BINARY_DIR} -I
|
|
|
|
${PROJECT_SOURCE_DIR} ${ABS_FIL}
|
2016-12-20 18:24:08 +08:00
|
|
|
DEPENDS ${ABS_FIL}
|
|
|
|
COMMENT "Running C++ protocol buffer compiler on ${ABS_FIL}"
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
set_source_files_properties(${ALL_PROTO_SRCS} ${ALL_PROTO_HDRS} PROPERTIES GENERATED TRUE)
|
2017-12-07 03:34:07 +08:00
|
|
|
list(APPEND ALL_LIBRARY_HDRS ${ALL_PROTO_HDRS})
|
|
|
|
list(APPEND ALL_LIBRARY_SRCS ${ALL_PROTO_SRCS})
|
2016-12-20 18:24:08 +08:00
|
|
|
|
2017-11-22 23:29:01 +08:00
|
|
|
if(${BUILD_GRPC})
|
|
|
|
set(ALL_GRPC_SERVICE_SRCS)
|
|
|
|
set(ALL_GRPC_SERVICE_HDRS)
|
|
|
|
foreach(ABS_FIL ${ALL_GRPC_SERVICES})
|
|
|
|
file(RELATIVE_PATH REL_FIL ${PROJECT_SOURCE_DIR} ${ABS_FIL})
|
|
|
|
get_filename_component(DIR ${REL_FIL} DIRECTORY)
|
|
|
|
get_filename_component(FIL_WE ${REL_FIL} NAME_WE)
|
|
|
|
|
|
|
|
list(APPEND ALL_GRPC_SERVICE_SRCS "${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.cc")
|
|
|
|
list(APPEND ALL_GRPC_SERVICE_HDRS "${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.h")
|
|
|
|
|
|
|
|
add_custom_command(
|
2018-02-03 04:04:34 +08:00
|
|
|
OUTPUT "${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.cc"
|
|
|
|
"${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.h"
|
2019-01-03 16:19:00 +08:00
|
|
|
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
|
2018-02-03 04:04:34 +08:00
|
|
|
ARGS --cpp_out ${PROJECT_BINARY_DIR}
|
2017-11-22 23:29:01 +08:00
|
|
|
-I ${PROJECT_SOURCE_DIR}
|
|
|
|
${ABS_FIL}
|
|
|
|
DEPENDS ${ABS_FIL}
|
2018-02-03 04:04:34 +08:00
|
|
|
COMMENT "Running C++ protocol buffer compiler on ${ABS_FIL}"
|
2017-11-22 23:29:01 +08:00
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
set_source_files_properties(${ALL_GRPC_SERVICE_SRCS} ${ALL_GRPC_SERVICE_HDRS} PROPERTIES GENERATED TRUE)
|
2017-12-07 03:34:07 +08:00
|
|
|
list(APPEND ALL_LIBRARY_HDRS ${ALL_GRPC_SERVICE_HDRS})
|
|
|
|
list(APPEND ALL_LIBRARY_SRCS ${ALL_GRPC_SERVICE_SRCS})
|
2017-11-22 23:29:01 +08:00
|
|
|
endif()
|
2017-12-20 21:40:33 +08:00
|
|
|
set(INSTALL_GENERATED_HDRS ${ALL_PROTO_HDRS} ${ALL_GRPC_SERVICE_HDRS})
|
2017-11-22 23:29:01 +08:00
|
|
|
|
2018-12-17 00:04:23 +08:00
|
|
|
add_library(${PROJECT_NAME} STATIC ${ALL_LIBRARY_HDRS} ${ALL_LIBRARY_SRCS})
|
2017-05-08 21:29:13 +08:00
|
|
|
|
|
|
|
configure_file(
|
|
|
|
${PROJECT_SOURCE_DIR}/cartographer/common/config.h.cmake
|
|
|
|
${PROJECT_BINARY_DIR}/cartographer/common/config.h)
|
|
|
|
|
2017-06-16 23:38:13 +08:00
|
|
|
google_binary(cartographer_autogenerate_ground_truth
|
|
|
|
SRCS
|
|
|
|
cartographer/ground_truth/autogenerate_ground_truth_main.cc
|
|
|
|
)
|
|
|
|
|
2017-05-08 21:29:13 +08:00
|
|
|
google_binary(cartographer_compute_relations_metrics
|
|
|
|
SRCS
|
|
|
|
cartographer/ground_truth/compute_relations_metrics_main.cc
|
|
|
|
)
|
2016-08-03 18:48:29 +08:00
|
|
|
|
2018-07-24 21:48:34 +08:00
|
|
|
google_binary(cartographer_pbstream
|
2018-05-29 22:56:18 +08:00
|
|
|
SRCS
|
2018-07-24 21:48:34 +08:00
|
|
|
cartographer/io/pbstream_main.cc
|
2018-07-23 17:34:37 +08:00
|
|
|
)
|
|
|
|
|
2019-03-07 01:39:25 +08:00
|
|
|
google_binary(cartographer_print_configuration
|
|
|
|
SRCS
|
|
|
|
cartographer/common/print_configuration_main.cc
|
|
|
|
)
|
|
|
|
|
2017-12-12 02:09:52 +08:00
|
|
|
if(${BUILD_GRPC})
|
|
|
|
google_binary(cartographer_grpc_server
|
|
|
|
SRCS
|
2018-03-05 19:41:38 +08:00
|
|
|
cartographer/cloud/map_builder_server_main.cc
|
2017-12-12 02:09:52 +08:00
|
|
|
)
|
2018-02-19 22:54:10 +08:00
|
|
|
target_link_libraries(cartographer_grpc_server PUBLIC grpc++)
|
2018-03-23 17:52:48 +08:00
|
|
|
target_link_libraries(cartographer_grpc_server PUBLIC async_grpc)
|
2018-02-19 22:54:10 +08:00
|
|
|
if(${BUILD_PROMETHEUS})
|
2018-12-18 21:19:29 +08:00
|
|
|
target_link_libraries(cartographer_grpc_server PUBLIC ${ZLIB_LIBRARIES})
|
|
|
|
target_link_libraries(cartographer_grpc_server PUBLIC prometheus-cpp-core)
|
|
|
|
target_link_libraries(cartographer_grpc_server PUBLIC prometheus-cpp-pull)
|
2018-02-19 22:54:10 +08:00
|
|
|
endif()
|
2017-12-12 02:09:52 +08:00
|
|
|
endif()
|
|
|
|
|
2017-01-09 20:49:21 +08:00
|
|
|
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
|
2016-12-20 18:24:08 +08:00
|
|
|
"${EIGEN3_INCLUDE_DIR}")
|
2017-01-09 20:49:21 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${EIGEN3_LIBRARIES})
|
2016-12-20 18:24:08 +08:00
|
|
|
|
2017-01-09 20:49:21 +08:00
|
|
|
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
|
2016-12-20 18:24:08 +08:00
|
|
|
"${CERES_INCLUDE_DIRS}")
|
2017-01-09 20:49:21 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${CERES_LIBRARIES})
|
2016-12-20 18:24:08 +08:00
|
|
|
|
2017-01-09 20:49:21 +08:00
|
|
|
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
|
2016-12-20 18:24:08 +08:00
|
|
|
"${LUA_INCLUDE_DIR}")
|
2017-01-09 20:49:21 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${LUA_LIBRARIES})
|
2016-12-20 18:24:08 +08:00
|
|
|
|
2017-01-09 20:49:21 +08:00
|
|
|
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
|
2016-12-20 18:24:08 +08:00
|
|
|
"${Boost_INCLUDE_DIRS}")
|
2017-01-09 20:49:21 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_LIBRARIES})
|
2016-12-20 18:24:08 +08:00
|
|
|
|
2018-12-17 00:04:23 +08:00
|
|
|
if (WIN32)
|
|
|
|
find_package(glog REQUIRED)
|
|
|
|
set(GLOG_LIBRARY glog::glog)
|
|
|
|
else()
|
|
|
|
set(GLOG_LIBRARY glog)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${GLOG_LIBRARY})
|
2017-01-09 20:49:21 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC gflags)
|
2018-12-17 00:04:23 +08:00
|
|
|
if(WIN32)
|
|
|
|
# Needed to fix conflict with MSVC's error macro.
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC -DGLOG_NO_ABBREVIATED_SEVERITIES)
|
|
|
|
endif()
|
|
|
|
if(MSVC)
|
|
|
|
# Needed for VS 2017 5.8
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_USE_MATH_DEFINES)
|
|
|
|
endif()
|
2016-12-20 18:24:08 +08:00
|
|
|
|
2018-12-17 00:04:23 +08:00
|
|
|
if("${CAIRO_INCLUDE_DIRS}")
|
|
|
|
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
|
|
|
|
"${CAIRO_INCLUDE_DIRS}")
|
|
|
|
endif()
|
2017-01-09 20:49:21 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${CAIRO_LIBRARIES})
|
2016-12-20 18:24:08 +08:00
|
|
|
|
2017-01-09 20:49:21 +08:00
|
|
|
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
|
2016-12-20 18:24:08 +08:00
|
|
|
${PROTOBUF_INCLUDE_DIR})
|
|
|
|
# TODO(hrapp): This should not explicitly list pthread and use
|
|
|
|
# PROTOBUF_LIBRARIES, but that failed on first try.
|
2020-06-24 16:53:03 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${PROTOBUF_LIBRARY}
|
|
|
|
absl::algorithm
|
|
|
|
absl::base
|
|
|
|
absl::debugging
|
|
|
|
absl::flat_hash_map
|
|
|
|
absl::memory
|
|
|
|
absl::meta
|
|
|
|
absl::numeric
|
|
|
|
absl::str_format
|
|
|
|
absl::strings
|
|
|
|
absl::synchronization
|
|
|
|
absl::time
|
|
|
|
absl::utility
|
|
|
|
)
|
2018-12-17 00:04:23 +08:00
|
|
|
if (NOT WIN32)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC pthread)
|
|
|
|
endif()
|
2017-12-12 02:09:52 +08:00
|
|
|
if(${BUILD_GRPC})
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC grpc++)
|
2018-03-23 17:52:48 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC async_grpc)
|
2017-12-12 02:09:52 +08:00
|
|
|
endif()
|
2018-02-19 22:54:10 +08:00
|
|
|
if(${BUILD_PROMETHEUS})
|
2018-12-18 21:19:29 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${ZLIB_LIBRARIES})
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC prometheus-cpp-core)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC prometheus-cpp-pull)
|
2018-02-22 01:52:57 +08:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_PROMETHEUS=1)
|
2018-02-19 22:54:10 +08:00
|
|
|
endif()
|
2016-12-20 18:24:08 +08:00
|
|
|
|
2018-05-01 00:02:54 +08:00
|
|
|
set(TARGET_COMPILE_FLAGS "${TARGET_COMPILE_FLAGS} ${GOOG_CXX_FLAGS}")
|
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
|
|
|
COMPILE_FLAGS ${TARGET_COMPILE_FLAGS})
|
|
|
|
|
|
|
|
set(TEST_LIB
|
|
|
|
cartographer_test_library
|
|
|
|
)
|
|
|
|
add_library(${TEST_LIB} ${TEST_LIBRARY_HDRS} ${TEST_LIBRARY_SRCS})
|
|
|
|
target_include_directories(${TEST_LIB} SYSTEM PRIVATE
|
|
|
|
"${GMOCK_INCLUDE_DIRS}")
|
2018-12-17 00:04:23 +08:00
|
|
|
# Needed for dynamically linked GTest on Windows.
|
|
|
|
if (WIN32)
|
|
|
|
target_compile_definitions(${TEST_LIB} PUBLIC -DGTEST_LINKED_AS_SHARED_LIBRARY)
|
|
|
|
endif()
|
2018-05-01 00:02:54 +08:00
|
|
|
target_link_libraries(${TEST_LIB} PUBLIC ${GMOCK_LIBRARY})
|
|
|
|
target_link_libraries(${TEST_LIB} PUBLIC ${PROJECT_NAME})
|
|
|
|
set_target_properties(${TEST_LIB} PROPERTIES
|
|
|
|
COMPILE_FLAGS ${TARGET_COMPILE_FLAGS})
|
|
|
|
|
|
|
|
foreach(ABS_FIL ${ALL_TESTS})
|
|
|
|
file(RELATIVE_PATH REL_FIL ${PROJECT_SOURCE_DIR} ${ABS_FIL})
|
|
|
|
get_filename_component(DIR ${REL_FIL} DIRECTORY)
|
|
|
|
get_filename_component(FIL_WE ${REL_FIL} NAME_WE)
|
|
|
|
# Replace slashes as required for CMP0037.
|
|
|
|
string(REPLACE "/" "." TEST_TARGET_NAME "${DIR}/${FIL_WE}")
|
|
|
|
google_test("${TEST_TARGET_NAME}" ${ABS_FIL})
|
|
|
|
if(${BUILD_GRPC})
|
|
|
|
target_link_libraries("${TEST_TARGET_NAME}" PUBLIC grpc++)
|
|
|
|
target_link_libraries("${TEST_TARGET_NAME}" PUBLIC async_grpc)
|
|
|
|
endif()
|
|
|
|
if(${BUILD_PROMETHEUS})
|
2018-12-18 21:19:29 +08:00
|
|
|
target_link_libraries("${TEST_TARGET_NAME}" PUBLIC ${ZLIB_LIBRARIES})
|
|
|
|
target_link_libraries("${TEST_TARGET_NAME}" PUBLIC prometheus-cpp-core)
|
|
|
|
target_link_libraries("${TEST_TARGET_NAME}" PUBLIC prometheus-cpp-pull)
|
2018-05-01 00:02:54 +08:00
|
|
|
endif()
|
|
|
|
target_link_libraries("${TEST_TARGET_NAME}" PUBLIC ${TEST_LIB})
|
|
|
|
endforeach()
|
|
|
|
|
2016-12-20 18:24:08 +08:00
|
|
|
# Add the binary directory first, so that port.h is included after it has
|
|
|
|
# been generated.
|
2017-01-09 20:49:21 +08:00
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
2017-02-09 22:57:54 +08:00
|
|
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
2016-12-20 18:24:08 +08:00
|
|
|
$<INSTALL_INTERFACE:include>
|
2016-08-03 18:48:29 +08:00
|
|
|
)
|
|
|
|
|
2017-01-09 20:49:21 +08:00
|
|
|
install(
|
|
|
|
TARGETS ${PROJECT_NAME}
|
|
|
|
EXPORT CartographerExport
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
)
|
2016-12-20 18:24:08 +08:00
|
|
|
|
2017-12-07 03:34:07 +08:00
|
|
|
foreach(HDR ${INSTALL_SOURCE_HDRS})
|
2017-02-09 22:57:54 +08:00
|
|
|
file(RELATIVE_PATH REL_FIL ${PROJECT_SOURCE_DIR} ${HDR})
|
2016-12-20 18:24:08 +08:00
|
|
|
get_filename_component(DIR ${REL_FIL} DIRECTORY)
|
|
|
|
install(
|
2017-12-07 03:34:07 +08:00
|
|
|
FILES ${HDR}
|
|
|
|
DESTINATION include/${DIR}
|
2016-12-20 18:24:08 +08:00
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
|
2017-12-07 03:34:07 +08:00
|
|
|
foreach(HDR ${INSTALL_GENERATED_HDRS})
|
2017-02-09 22:57:54 +08:00
|
|
|
file(RELATIVE_PATH REL_FIL ${PROJECT_BINARY_DIR} ${HDR})
|
2016-12-20 18:24:08 +08:00
|
|
|
get_filename_component(DIR ${REL_FIL} DIRECTORY)
|
|
|
|
install(
|
2017-12-07 03:34:07 +08:00
|
|
|
FILES ${HDR}
|
|
|
|
DESTINATION include/${DIR}
|
2016-12-20 18:24:08 +08:00
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
|
2017-01-09 20:49:21 +08:00
|
|
|
set(CARTOGRAPHER_CMAKE_DIR share/cartographer/cmake)
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
configure_package_config_file(
|
2016-08-03 18:48:29 +08:00
|
|
|
cartographer-config.cmake.in
|
2017-02-09 22:57:54 +08:00
|
|
|
${PROJECT_BINARY_DIR}/cmake/cartographer/cartographer-config.cmake
|
2017-01-09 20:49:21 +08:00
|
|
|
PATH_VARS CARTOGRAPHER_CMAKE_DIR
|
2016-08-03 18:48:29 +08:00
|
|
|
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cartographer
|
|
|
|
)
|
|
|
|
|
|
|
|
install(
|
2017-01-09 20:49:21 +08:00
|
|
|
EXPORT CartographerExport
|
|
|
|
DESTINATION share/cartographer/cmake/
|
|
|
|
FILE CartographerTargets.cmake
|
|
|
|
)
|
|
|
|
|
|
|
|
install(
|
2017-02-09 22:57:54 +08:00
|
|
|
FILES ${PROJECT_BINARY_DIR}/cmake/cartographer/cartographer-config.cmake
|
2017-01-09 20:49:21 +08:00
|
|
|
DESTINATION share/cartographer/
|
2016-08-03 18:48:29 +08:00
|
|
|
)
|