Add absl to CMake and Bazel builds. (#1301)

master
Alexander Belyaev 2018-07-26 06:49:37 +02:00 committed by GitHub
parent 926b8540f6
commit e3a7f39889
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 87 additions and 2 deletions

View File

@ -29,6 +29,7 @@ include("${PROJECT_SOURCE_DIR}/cmake/functions.cmake")
google_initialize_cartographer_project()
google_enable_testing()
find_package(Abseil REQUIRED)
find_package(Boost REQUIRED COMPONENTS iostreams)
find_package(Ceres REQUIRED COMPONENTS SuiteSparse)
find_package(Eigen3 REQUIRED)
@ -225,7 +226,7 @@ target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
${PROTOBUF_INCLUDE_DIR})
# TODO(hrapp): This should not explicitly list pthread and use
# PROTOBUF_LIBRARIES, but that failed on first try.
target_link_libraries(${PROJECT_NAME} PUBLIC ${PROTOBUF_LIBRARY} pthread)
target_link_libraries(${PROJECT_NAME} PUBLIC ${PROTOBUF_LIBRARY} pthread standalone_absl)
if(${BUILD_GRPC})
target_link_libraries(${PROJECT_NAME} PUBLIC grpc++)
target_link_libraries(${PROJECT_NAME} PUBLIC async_grpc)

View File

@ -233,7 +233,13 @@ def cartographer_repositories():
"https://github.com/googlecartographer/async_grpc/archive/ed8e3b31bdd46a74f0c47b4c53a47e0c0f21141b.tar.gz",
],
)
_maybe(native.http_archive,
name = "com_google_absl",
sha256 = "387cf016ab1ab8530d1cea8975276ce8d8bff355133776129bdc400d05519eb6",
strip_prefix = "abseil-cpp-44aa275286baf97fc13529aca547a88b180beb08",
urls = ["https://github.com/abseil/abseil-cpp/archive/44aa275286baf97fc13529aca547a88b180beb08.tar.gz"],
)
# TODO(rodrigoq): remove these binds once grpc#14140 has been merged, as well
# as removing `use_external` in cartographer_grpc/BUILD.bazel.
# https://github.com/grpc/grpc/pull/14140

View File

@ -100,6 +100,7 @@ cc_library(
"@org_ceres_solver_ceres_solver//:ceres",
"@org_lua_lua//:lua",
"@org_tuxfamily_eigen//:eigen",
"@com_google_absl//absl/strings",
],
)

View File

@ -0,0 +1,77 @@
# 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.
cmake_minimum_required(VERSION 3.2)
if(NOT TARGET standalone_absl)
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
set(ABSEIL_PROJECT_NAME abseil)
set(ABSEIL_PROJECT_SRC_DIR
${CMAKE_CURRENT_BINARY_DIR}/${ABSEIL_PROJECT_NAME}/src/${ABSEIL_PROJECT_NAME})
set(ABSEIL_PROJECT_BUILD_DIR
${CMAKE_CURRENT_BINARY_DIR}/${ABSEIL_PROJECT_NAME}/src/${ABSEIL_PROJECT_NAME}-build)
set(ABSEIL_INCLUDE_DIRS ${ABSEIL_PROJECT_SRC_DIR})
set(ABSEIL_LIBRARY_PATH
"${ABSEIL_PROJECT_BUILD_DIR}/absl/synchronization/libabsl_synchronization.a")
set(ABSEIL_DEPENDENT_LIBRARIES
"${ABSEIL_PROJECT_BUILD_DIR}/absl/algorithm/libabsl_algorithm.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/base/libabsl_base.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/base/libabsl_dynamic_annotations.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/base/libabsl_malloc_internal.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/base/libabsl_spinlock_wait.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/base/libabsl_throw_delegate.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/container/libabsl_container.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/container/libtest_instance_tracker_lib.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/debugging/libabsl_debugging.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/debugging/libabsl_examine_stack.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/debugging/libabsl_failure_signal_handler.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/debugging/libabsl_leak_check.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/debugging/libabsl_stack_consumption.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/debugging/libabsl_stacktrace.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/debugging/libabsl_symbolize.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/memory/libabsl_memory.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/meta/libabsl_meta.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/numeric/libabsl_int128.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/numeric/libabsl_numeric.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/strings/libabsl_strings.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/time/libabsl_time.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/types/libabsl_any.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/types/libabsl_bad_any_cast.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/types/libabsl_bad_optional_access.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/types/libabsl_optional.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/types/libabsl_span.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/types/libabsl_variant.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/utility/libabsl_utility.a"
)
ExternalProject_Add(${ABSEIL_PROJECT_NAME}
PREFIX ${ABSEIL_PROJECT_NAME}
GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git
GIT_TAG 44aa275286baf97fc13529aca547a88b180beb08
INSTALL_COMMAND ""
CMAKE_CACHE_ARGS "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON;-DBUILD_TESTING:BOOL=OFF;-DCMAKE_BUILD_TYPE:STRING=Release"
BUILD_BYPRODUCTS "${ABSEIL_LIBRARY_PATH};${ABSEIL_DEPENDENT_LIBRARIES}"
)
add_library(standalone_absl STATIC IMPORTED)
set_target_properties(standalone_absl
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
${ABSEIL_INCLUDE_DIRS}
)
set_target_properties(standalone_absl
PROPERTIES IMPORTED_LOCATION
${ABSEIL_LIBRARY_PATH}
INTERFACE_LINK_LIBRARIES
"${ABSEIL_DEPENDENT_LIBRARIES}"
)
add_dependencies(standalone_absl ${ABSEIL_PROJECT_NAME})
endif()