From 58069b003347e636c8ac064ed76e97db1e6eedbc Mon Sep 17 00:00:00 2001 From: Damon Kohler Date: Tue, 20 Dec 2016 16:20:27 +0100 Subject: [PATCH] Remove use of google_library and google_test. (#234) * Fixes Dockerfile.indigo copying. --- .travis.yml | 5 +- Dockerfile.indigo | 6 +- cartographer_ros/CMakeLists.txt | 104 +++++++++- .../cartographer_ros/CMakeLists.txt | 194 ++---------------- cartographer_rviz/CMakeLists.txt | 49 +++-- .../cartographer_rviz/CMakeLists.txt | 18 -- cartographer_rviz/rviz_plugin_description.xml | 2 +- 7 files changed, 148 insertions(+), 230 deletions(-) delete mode 100644 cartographer_rviz/cartographer_rviz/CMakeLists.txt diff --git a/.travis.yml b/.travis.yml index 73b061d..40f02d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,9 +22,8 @@ cache: - /home/travis/docker/ env: - matrix: - - ROS_RELEASE=indigo DOCKER_CACHE_FILE=/home/travis/docker/indigo-cache.tar.gz - - ROS_RELEASE=kinetic DOCKER_CACHE_FILE=/home/travis/docker/kinetic-cache.tar.gz + - ROS_RELEASE=indigo DOCKER_CACHE_FILE=/home/travis/docker/indigo-cache.tar.gz + - ROS_RELEASE=kinetic DOCKER_CACHE_FILE=/home/travis/docker/kinetic-cache.tar.gz before_install: scripts/load_docker_cache.sh diff --git a/Dockerfile.indigo b/Dockerfile.indigo index ec5f6c5..320a895 100644 --- a/Dockerfile.indigo +++ b/Dockerfile.indigo @@ -46,19 +46,19 @@ RUN cartographer_ros/scripts/install.sh --pkg ceres-solver RUN cartographer_ros/scripts/install.sh --pkg cartographer && \ cartographer_ros/scripts/install.sh --pkg cartographer --make-args test -COPY cartographer_ros_msgs catkin_ws/src/cartographer_ros/ +COPY cartographer_ros_msgs catkin_ws/src/cartographer_ros/cartographer_ros_msgs/ RUN cartographer_ros/scripts/install.sh --pkg cartographer_ros_msgs && \ cartographer_ros/scripts/install.sh --pkg cartographer_ros_msgs \ --catkin-make-args run_tests && \ cartographer_ros/scripts/catkin_test_results.sh build_isolated/cartographer_ros_msgs -COPY cartographer_ros catkin_ws/src/cartographer_ros/ +COPY cartographer_ros catkin_ws/src/cartographer_ros/cartographer_ros/ RUN cartographer_ros/scripts/install.sh --pkg cartographer_ros && \ cartographer_ros/scripts/install.sh --pkg cartographer_ros \ --catkin-make-args run_tests && \ cartographer_ros/scripts/catkin_test_results.sh build_isolated/cartographer_ros -COPY cartographer_rviz catkin_ws/src/cartographer_ros/ +COPY cartographer_rviz catkin_ws/src/cartographer_ros/cartographer_rviz/ RUN cartographer_ros/scripts/install.sh --pkg cartographer_rviz && \ cartographer_ros/scripts/install.sh --pkg cartographer_rviz \ --catkin-make-args run_tests && \ diff --git a/cartographer_ros/CMakeLists.txt b/cartographer_ros/CMakeLists.txt index f449178..b65c20c 100644 --- a/cartographer_ros/CMakeLists.txt +++ b/cartographer_ros/CMakeLists.txt @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 2.8.12) # Ships with Ubuntu 14.04 (Trusty) project(cartographer_ros) @@ -44,6 +44,7 @@ find_package(catkin REQUIRED COMPONENTS ${PACKAGE_DEPENDENCIES}) include(FindPkgConfig) pkg_search_module(YAMLCPP REQUIRED yaml-cpp>=0.5.1) +find_package(LuaGoogle REQUIRED) find_package(PCL REQUIRED COMPONENTS common io) find_package(Eigen3 REQUIRED) find_package(Boost REQUIRED COMPONENTS system iostreams) @@ -59,10 +60,18 @@ include_directories( ${urdfdom_headers_INCLUDE_DIRS} ) +# Override Catkin's GTest configuration to use GMock. +set(GTEST_FOUND TRUE) +set(GTEST_INCLUDE_DIRS ${GMOCK_INCLUDE_DIRS}) +set(GTEST_LIBRARIES ${GMOCK_LIBRARIES}) + catkin_package( CATKIN_DEPENDS ${PACKAGE_DEPENDENCIES} DEPENDS + # TODO(damonkohler): This should be here but causes Catkin to abort because + # protobuf specifies a library '-lpthread' instead of just 'pthread'. + # CARTOGRAPHER YAMLCPP PCL EIGEN3 @@ -72,14 +81,86 @@ catkin_package( LIBRARIES ${PROJECT_NAME} ) -SET(ALL_LIBRARIES "" CACHE INTERNAL "ALL_LIBRARIES") - +file(GLOB_RECURSE ALL_SRCS "*.cc" "*.h") +file(GLOB_RECURSE ALL_TESTS "*_test.cc") +file(GLOB_RECURSE ALL_EXECUTABLES "*_main.cc") +list(REMOVE_ITEM ALL_SRCS ${ALL_TESTS}) +list(REMOVE_ITEM ALL_SRCS ${ALL_EXECUTABLES}) +add_library(${PROJECT_NAME} ${ALL_SRCS}) add_subdirectory("cartographer_ros") -google_combined_library(${PROJECT_NAME} - SRCS "${ALL_LIBRARIES}" +target_include_directories(${PROJECT_NAME} PUBLIC ${CARTOGRAPHER_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${CARTOGRAPHER_LIBRARIES}) + +# YAML +target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${YAMLCPP_INCLUDE_DIRS}") +target_link_libraries(${PROJECT_NAME} PUBLIC ${YAMLCPP_LIBRARIES}) + +# Lua +target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${LUA_INCLUDE_DIR}) + +# PCL +target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC + "${PCL_INCLUDE_DIRS}") +target_link_libraries(${PROJECT_NAME} PUBLIC ${PCL_LIBRARIES}) +foreach(DEFINITION ${PCL_DEFINITIONS}) + set(TARGET_COMPILE_FLAGS "${TARGET_COMPILE_FLAGS} ${DEFINITION}") +endforeach() + +# Eigen +target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC + "${EIGEN3_INCLUDE_DIR}") + +# Boost +target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC + "${Boost_INCLUDE_DIRS}") +target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_LIBRARIES}) + +# Catkin +target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${catkin_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${catkin_LIBRARIES}) +add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS}) + +# Add the binary directory first, so that port.h is included after it has +# been generated. +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ + $ ) +set(TARGET_COMPILE_FLAGS "${TARGET_COMPILE_FLAGS} ${GOOG_CXX_FLAGS}") +set_target_properties(${PROJECT_NAME} PROPERTIES + COMPILE_FLAGS ${TARGET_COMPILE_FLAGS}) + +if (CATKIN_ENABLE_TESTING) + catkin_add_gtest(configuration_files_test "cartographer_ros/configuration_files_test.cc") + # catkin_add_gtest uses a plain (i.e. no PUBLIC/PRIVATE/INTERFACE) call to + # target_link_libraries. That forces us to do the same. + target_include_directories(configuration_files_test SYSTEM PUBLIC ${LUA_INCLUDE_DIR}) + target_link_libraries(configuration_files_test ${LUA_LIBRARIES}) + target_include_directories(configuration_files_test SYSTEM PUBLIC ${catkin_INCLUDE_DIRS}) + target_link_libraries(configuration_files_test ${catkin_LIBRARIES}) + add_dependencies(configuration_files_test ${catkin_EXPORTED_TARGETS}) + target_include_directories(configuration_files_test SYSTEM PUBLIC ${CARTOGRAPHER_INCLUDE_DIRS}) + target_link_libraries(configuration_files_test ${CARTOGRAPHER_LIBRARIES}) + target_link_libraries(configuration_files_test ${PROJECT_NAME}) + set_target_properties(configuration_files_test PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS}) + + catkin_add_gtest(time_conversion_test "cartographer_ros/time_conversion_test.cc") + # catkin_add_gtest uses a plain (i.e. no PUBLIC/PRIVATE/INTERFACE) call to + # target_link_libraries. That forces us to do the same. + target_include_directories(time_conversion_test SYSTEM PUBLIC ${LUA_INCLUDE_DIR}) + target_link_libraries(time_conversion_test ${LUA_LIBRARIES}) + target_include_directories(time_conversion_test SYSTEM PUBLIC ${catkin_INCLUDE_DIRS}) + target_link_libraries(time_conversion_test ${catkin_LIBRARIES}) + add_dependencies(time_conversion_test ${catkin_EXPORTED_TARGETS}) + target_include_directories(time_conversion_test SYSTEM PUBLIC ${CARTOGRAPHER_INCLUDE_DIRS}) + target_link_libraries(time_conversion_test ${CARTOGRAPHER_LIBRARIES}) + target_link_libraries(time_conversion_test ${PROJECT_NAME}) + set_target_properties(time_conversion_test PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS}) +endif() + install(DIRECTORY launch urdf configuration_files DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} ) @@ -93,3 +174,16 @@ install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} ) + +# Install source headers. +file(GLOB_RECURSE hdrs "*.h") +foreach(HDR ${hdrs}) + file(RELATIVE_PATH REL_FIL ${CMAKE_SOURCE_DIR} ${HDR}) + get_filename_component(INSTALL_DIR ${REL_FIL} DIRECTORY) + install( + FILES + ${HDR} + DESTINATION + include/${INSTALL_DIR} + ) +endforeach() diff --git a/cartographer_ros/cartographer_ros/CMakeLists.txt b/cartographer_ros/cartographer_ros/CMakeLists.txt index afb335d..cd1203b 100644 --- a/cartographer_ros/cartographer_ros/CMakeLists.txt +++ b/cartographer_ros/cartographer_ros/CMakeLists.txt @@ -1,186 +1,25 @@ -google_library(assets_writer - USES_CARTOGRAPHER - SRCS - assets_writer.cc - HDRS - assets_writer.h - DEPENDS - map_writer - node_options - occupancy_grid -) - -google_library(bag_reader - USES_CARTOGRAPHER - USES_GLOG - SRCS - bag_reader.cc - HDRS - bag_reader.h -) - -google_library(map_builder_bridge - USES_CARTOGRAPHER - SRCS - map_builder_bridge.cc - HDRS - map_builder_bridge.h - DEPENDS - assets_writer - msg_conversion - node_options - occupancy_grid - sensor_bridge - tf_bridge -) - -google_library(map_writer - USES_GLOG - USES_YAMLCPP - SRCS - map_writer.cc - HDRS - map_writer.h -) - -google_library(msg_conversion - USES_CARTOGRAPHER - USES_GLOG - USES_PCL - SRCS - msg_conversion.cc - HDRS - msg_conversion.h - DEPENDS - time_conversion -) - -google_library(node - USES_CARTOGRAPHER - USES_EIGEN - USES_GLOG - SRCS - node.cc - HDRS - node.h - DEPENDS - map_builder_bridge - msg_conversion - node_options - sensor_bridge - tf_bridge - time_conversion -) - -google_library(node_options - USES_CARTOGRAPHER - USES_GLOG - SRCS - node_options.cc - HDRS - node_options.h - DEPENDS - sensor_bridge -) - -google_library(occupancy_grid - USES_CARTOGRAPHER - USES_GLOG - SRCS - occupancy_grid.cc - HDRS - occupancy_grid.h - DEPENDS - node_options - time_conversion -) - -google_library(ros_log_sink - USES_GLOG - SRCS - ros_log_sink.cc - HDRS - ros_log_sink.h -) - -google_library(sensor_bridge - USES_CARTOGRAPHER - SRCS - sensor_bridge.cc - HDRS - sensor_bridge.h - DEPENDS - msg_conversion - tf_bridge - time_conversion -) - -google_library(tf_bridge - USES_CARTOGRAPHER - SRCS - tf_bridge.cc - HDRS - tf_bridge.h - DEPENDS - msg_conversion - time_conversion -) - -google_library(time_conversion - USES_CARTOGRAPHER - SRCS - time_conversion.cc - HDRS - time_conversion.h -) - -google_library(urdf_reader - USES_CARTOGRAPHER - SRCS - urdf_reader.cc - HDRS - urdf_reader.h - DEPENDS - msg_conversion -) - -google_test(configuration_files_test - USES_CARTOGRAPHER - SRCS - configuration_files_test.cc - DEPENDS - node_options -) - -google_test(time_conversion_test - USES_CARTOGRAPHER - SRCS - time_conversion_test.cc - DEPENDS - time_conversion -) +# 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. google_binary(cartographer_assets_writer - USES_CARTOGRAPHER - USES_GFLAGS - USES_GLOG SRCS assets_writer_main.cc - DEPENDS - bag_reader - msg_conversion - time_conversion - urdf_reader ) google_binary(cartographer_node - USES_CARTOGRAPHER - USES_GFLAGS SRCS node_main.cc - DEPENDS - node - ros_log_sink ) install(TARGETS cartographer_node @@ -196,15 +35,8 @@ install(TARGETS cartographer_assets_writer ) google_binary(cartographer_offline_node - USES_CARTOGRAPHER - USES_GFLAGS SRCS offline_node_main.cc - DEPENDS - bag_reader - node - ros_log_sink - urdf_reader ) install(TARGETS cartographer_offline_node diff --git a/cartographer_rviz/CMakeLists.txt b/cartographer_rviz/CMakeLists.txt index 5fd90b6..8bb22cb 100644 --- a/cartographer_rviz/CMakeLists.txt +++ b/cartographer_rviz/CMakeLists.txt @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12) # Ships with Ubuntu 14.04 (Trusty) project(cartographer_rviz) @@ -29,6 +29,7 @@ find_package(cartographer REQUIRED) include("${CARTOGRAPHER_CMAKE_DIR}/functions.cmake") google_initialize_cartographer_project() +find_package(Eigen3 REQUIRED) find_package(Boost REQUIRED COMPONENTS system iostreams) find_package(catkin REQUIRED COMPONENTS ${PACKAGE_DEPENDENCIES}) @@ -39,6 +40,11 @@ catkin_package( INCLUDE_DIRS "." ) +file(GLOB_RECURSE ALL_SRCS "*.cc" "*.h") +message(${ALL_SRCS}) +add_library(${PROJECT_NAME} ${ALL_SRCS}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${QT_LIBRARIES}) + set(CMAKE_AUTOMOC ON) if(rviz_QT_VERSION VERSION_LESS "5") message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}") @@ -55,26 +61,31 @@ else() endif() add_definitions(-DQT_NO_KEYWORDS) -SET(ALL_LIBRARIES "" CACHE INTERNAL "ALL_LIBRARIES") - -add_subdirectory("cartographer_rviz") - -# Create an empty file for the shared library we require for RViz. -set(DUMMY_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/empty.cc) -add_custom_command( - OUTPUT ${DUMMY_SOURCE} - COMMAND cmake -E touch ${DUMMY_SOURCE} - DEPENDS ${ARG_SRCS} -) -add_library(cartographer_rviz_submaps_visualization ${DUMMY_SOURCE}) -target_link_libraries(cartographer_rviz_submaps_visualization - ${QT_LIBRARIES} - "-Wl,--whole-archive" - ${ALL_LIBRARIES} - "-Wl,--no-whole-archive" +# Add the binary directory first, so that port.h is included after it has +# been generated. +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ + $ ) -install(TARGETS cartographer_rviz_submaps_visualization +target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC + "${EIGEN3_INCLUDE_DIR}") +target_link_libraries(${PROJECT_NAME} PUBLIC ${EIGEN3_LIBRARIES}) + +target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC + "${Boost_INCLUDE_DIRS}") +target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_LIBRARIES}) + +target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${catkin_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${catkin_LIBRARIES}) +add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS}) + +set(TARGET_COMPILE_FLAGS "${TARGET_COMPILE_FLAGS} ${GOOG_CXX_FLAGS}") +set_target_properties(${PROJECT_NAME} PROPERTIES + COMPILE_FLAGS ${TARGET_COMPILE_FLAGS}) + +install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} diff --git a/cartographer_rviz/cartographer_rviz/CMakeLists.txt b/cartographer_rviz/cartographer_rviz/CMakeLists.txt deleted file mode 100644 index 386e6ef..0000000 --- a/cartographer_rviz/cartographer_rviz/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -google_library(drawable_submap - USES_CARTOGRAPHER - USES_EIGEN - SRCS - drawable_submap.cc - HDRS - drawable_submap.h -) - -google_library(submaps_display - USES_CARTOGRAPHER - SRCS - submaps_display.cc - HDRS - submaps_display.h - DEPENDS - drawable_submap -) diff --git a/cartographer_rviz/rviz_plugin_description.xml b/cartographer_rviz/rviz_plugin_description.xml index 6ad7179..833b601 100644 --- a/cartographer_rviz/rviz_plugin_description.xml +++ b/cartographer_rviz/rviz_plugin_description.xml @@ -14,7 +14,7 @@ limitations under the License. --> - +