From eeb17bf055c6b09d8149280837ab84d5e7822dbb Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Tue, 11 Oct 2016 15:18:59 +0200 Subject: [PATCH] Adds google_binary to create installable binaries. (#43) - Do not link in Ceres if gflags or glog is used, but still rely on ceres to find those libraries for us. - Update CMakeLists with new settings. --- cartographer/common/CMakeLists.txt | 12 +++++----- cartographer/kalman_filter/CMakeLists.txt | 4 ++-- cartographer/mapping/CMakeLists.txt | 14 +++++------ cartographer/mapping_2d/CMakeLists.txt | 12 +++++----- .../mapping_2d/scan_matching/CMakeLists.txt | 7 +++--- .../sparse_pose_graph/CMakeLists.txt | 3 ++- cartographer/mapping_3d/CMakeLists.txt | 20 ++++++++-------- .../mapping_3d/scan_matching/CMakeLists.txt | 7 +++--- .../sparse_pose_graph/CMakeLists.txt | 5 ++-- cartographer/sensor/CMakeLists.txt | 6 ++--- cartographer/transform/CMakeLists.txt | 4 ++-- cmake/functions.cmake | 23 +++++++++++++++++++ scripts/update_cmakelists.py | 19 +++++++++++---- 13 files changed, 87 insertions(+), 49 deletions(-) diff --git a/cartographer/common/CMakeLists.txt b/cartographer/common/CMakeLists.txt index aaf9bd4..2e2cb45 100644 --- a/cartographer/common/CMakeLists.txt +++ b/cartographer/common/CMakeLists.txt @@ -19,7 +19,7 @@ configure_file ( ${CMAKE_CURRENT_BINARY_DIR}/config.h) google_library(common_blocking_queue - USES_CERES + USES_GLOG HDRS blocking_queue.h DEPENDS @@ -45,7 +45,7 @@ google_library(common_config ) google_library(common_configuration_file_resolver - USES_CERES + USES_GLOG SRCS configuration_file_resolver.cc HDRS @@ -66,7 +66,7 @@ google_library(common_fixed_ratio_sampler ) google_library(common_histogram - USES_CERES + USES_GLOG SRCS histogram.cc HDRS @@ -82,7 +82,7 @@ google_library(common_lua ) google_library(common_lua_parameter_dictionary - USES_CERES + USES_GLOG SRCS lua_parameter_dictionary.cc HDRS @@ -93,7 +93,7 @@ google_library(common_lua_parameter_dictionary ) google_library(common_lua_parameter_dictionary_test_helpers - USES_CERES + USES_GLOG HDRS lua_parameter_dictionary_test_helpers.h DEPENDS @@ -148,7 +148,7 @@ google_library(common_rate_timer ) google_library(common_thread_pool - USES_CERES + USES_GLOG SRCS thread_pool.cc HDRS diff --git a/cartographer/kalman_filter/CMakeLists.txt b/cartographer/kalman_filter/CMakeLists.txt index 0c3f085..7ae17c4 100644 --- a/cartographer/kalman_filter/CMakeLists.txt +++ b/cartographer/kalman_filter/CMakeLists.txt @@ -31,8 +31,8 @@ google_library(kalman_filter_odometry_state_tracker ) google_library(kalman_filter_pose_tracker - USES_CERES USES_EIGEN + USES_GLOG SRCS pose_tracker.cc HDRS @@ -51,8 +51,8 @@ google_library(kalman_filter_pose_tracker ) google_library(kalman_filter_unscented_kalman_filter - USES_CERES USES_EIGEN + USES_GLOG HDRS unscented_kalman_filter.h DEPENDS diff --git a/cartographer/mapping/CMakeLists.txt b/cartographer/mapping/CMakeLists.txt index 5a6f333..6989025 100644 --- a/cartographer/mapping/CMakeLists.txt +++ b/cartographer/mapping/CMakeLists.txt @@ -29,8 +29,8 @@ google_library(mapping_global_trajectory_builder_interface ) google_library(mapping_map_builder - USES_CERES USES_EIGEN + USES_GLOG SRCS map_builder.cc HDRS @@ -58,7 +58,7 @@ google_library(mapping_map_builder ) google_library(mapping_probability_values - USES_CERES + USES_GLOG SRCS probability_values.cc HDRS @@ -69,8 +69,8 @@ google_library(mapping_probability_values ) google_library(mapping_sensor_collator - USES_CERES USES_EIGEN + USES_GLOG HDRS sensor_collator.h DEPENDS @@ -81,7 +81,7 @@ google_library(mapping_sensor_collator ) google_library(mapping_sparse_pose_graph - USES_CERES + USES_GLOG SRCS sparse_pose_graph.cc HDRS @@ -98,8 +98,8 @@ google_library(mapping_sparse_pose_graph ) google_library(mapping_submaps - USES_CERES USES_EIGEN + USES_GLOG SRCS submaps.cc HDRS @@ -115,7 +115,7 @@ google_library(mapping_submaps ) google_library(mapping_trajectory_connectivity - USES_CERES + USES_GLOG SRCS trajectory_connectivity.cc HDRS @@ -155,7 +155,7 @@ google_test(mapping_sensor_collator_test ) google_test(mapping_sparse_pose_graph_test - USES_CERES + USES_GLOG SRCS sparse_pose_graph_test.cc DEPENDS diff --git a/cartographer/mapping_2d/CMakeLists.txt b/cartographer/mapping_2d/CMakeLists.txt index c930f89..54fcfd9 100644 --- a/cartographer/mapping_2d/CMakeLists.txt +++ b/cartographer/mapping_2d/CMakeLists.txt @@ -28,8 +28,8 @@ google_library(mapping_2d_global_trajectory_builder ) google_library(mapping_2d_laser_fan_inserter - USES_CERES USES_EIGEN + USES_GLOG SRCS laser_fan_inserter.cc HDRS @@ -68,8 +68,8 @@ google_library(mapping_2d_local_trajectory_builder ) google_library(mapping_2d_map_limits - USES_CERES USES_EIGEN + USES_GLOG HDRS map_limits.h DEPENDS @@ -83,7 +83,7 @@ google_library(mapping_2d_map_limits ) google_library(mapping_2d_probability_grid - USES_CERES + USES_GLOG HDRS probability_grid.h DEPENDS @@ -108,8 +108,8 @@ google_library(mapping_2d_ray_casting ) google_library(mapping_2d_sparse_pose_graph - USES_CERES USES_EIGEN + USES_GLOG SRCS sparse_pose_graph.cc HDRS @@ -135,8 +135,8 @@ google_library(mapping_2d_sparse_pose_graph ) google_library(mapping_2d_submaps - USES_CERES USES_EIGEN + USES_GLOG USES_WEBP SRCS submaps.cc @@ -158,8 +158,8 @@ google_library(mapping_2d_submaps ) google_library(mapping_2d_xy_index - USES_CERES USES_EIGEN + USES_GLOG HDRS xy_index.h DEPENDS diff --git a/cartographer/mapping_2d/scan_matching/CMakeLists.txt b/cartographer/mapping_2d/scan_matching/CMakeLists.txt index 92ed70c..eaf7943 100644 --- a/cartographer/mapping_2d/scan_matching/CMakeLists.txt +++ b/cartographer/mapping_2d/scan_matching/CMakeLists.txt @@ -17,6 +17,7 @@ add_subdirectory("proto") google_library(mapping_2d_scan_matching_ceres_scan_matcher USES_CERES USES_EIGEN + USES_GLOG SRCS ceres_scan_matcher.cc HDRS @@ -49,8 +50,8 @@ google_library(mapping_2d_scan_matching_correlative_scan_matcher ) google_library(mapping_2d_scan_matching_fast_correlative_scan_matcher - USES_CERES USES_EIGEN + USES_GLOG SRCS fast_correlative_scan_matcher.cc HDRS @@ -66,8 +67,8 @@ google_library(mapping_2d_scan_matching_fast_correlative_scan_matcher ) google_library(mapping_2d_scan_matching_fast_global_localizer - USES_CERES USES_EIGEN + USES_GLOG SRCS fast_global_localizer.cc HDRS @@ -88,8 +89,8 @@ google_library(mapping_2d_scan_matching_occupied_space_cost_functor ) google_library(mapping_2d_scan_matching_real_time_correlative_scan_matcher - USES_CERES USES_EIGEN + USES_GLOG SRCS real_time_correlative_scan_matcher.cc HDRS diff --git a/cartographer/mapping_2d/sparse_pose_graph/CMakeLists.txt b/cartographer/mapping_2d/sparse_pose_graph/CMakeLists.txt index 8ef4f39..6da6c6f 100644 --- a/cartographer/mapping_2d/sparse_pose_graph/CMakeLists.txt +++ b/cartographer/mapping_2d/sparse_pose_graph/CMakeLists.txt @@ -13,8 +13,8 @@ # limitations under the License. google_library(mapping_2d_sparse_pose_graph_constraint_builder - USES_CERES USES_EIGEN + USES_GLOG SRCS constraint_builder.cc HDRS @@ -45,6 +45,7 @@ google_library(mapping_2d_sparse_pose_graph_constraint_builder google_library(mapping_2d_sparse_pose_graph_optimization_problem USES_CERES USES_EIGEN + USES_GLOG SRCS optimization_problem.cc HDRS diff --git a/cartographer/mapping_3d/CMakeLists.txt b/cartographer/mapping_3d/CMakeLists.txt index 394f63a..f854264 100644 --- a/cartographer/mapping_3d/CMakeLists.txt +++ b/cartographer/mapping_3d/CMakeLists.txt @@ -46,8 +46,8 @@ google_library(mapping_3d_global_trajectory_builder ) google_library(mapping_3d_hybrid_grid - USES_CERES USES_EIGEN + USES_GLOG HDRS hybrid_grid.h DEPENDS @@ -58,8 +58,8 @@ google_library(mapping_3d_hybrid_grid ) google_library(mapping_3d_imu_integration - USES_CERES USES_EIGEN + USES_GLOG SRCS imu_integration.cc HDRS @@ -70,7 +70,7 @@ google_library(mapping_3d_imu_integration ) google_library(mapping_3d_kalman_local_trajectory_builder - USES_CERES + USES_GLOG SRCS kalman_local_trajectory_builder.cc HDRS @@ -107,8 +107,8 @@ google_library(mapping_3d_kalman_local_trajectory_builder_options ) google_library(mapping_3d_laser_fan_inserter - USES_CERES USES_EIGEN + USES_GLOG SRCS laser_fan_inserter.cc HDRS @@ -146,7 +146,7 @@ google_library(mapping_3d_local_trajectory_builder_interface ) google_library(mapping_3d_local_trajectory_builder_options - USES_CERES + USES_GLOG SRCS local_trajectory_builder_options.cc HDRS @@ -163,7 +163,7 @@ google_library(mapping_3d_local_trajectory_builder_options ) google_library(mapping_3d_motion_filter - USES_CERES + USES_GLOG SRCS motion_filter.cc HDRS @@ -177,7 +177,7 @@ google_library(mapping_3d_motion_filter ) google_library(mapping_3d_optimizing_local_trajectory_builder - USES_CERES + USES_GLOG SRCS optimizing_local_trajectory_builder.cc HDRS @@ -223,8 +223,8 @@ google_library(mapping_3d_rotation_cost_function ) google_library(mapping_3d_sparse_pose_graph - USES_CERES USES_EIGEN + USES_GLOG SRCS sparse_pose_graph.cc HDRS @@ -251,8 +251,8 @@ google_library(mapping_3d_sparse_pose_graph ) google_library(mapping_3d_submaps - USES_CERES USES_EIGEN + USES_GLOG SRCS submaps.cc HDRS @@ -285,8 +285,8 @@ google_test(mapping_3d_hybrid_grid_test ) google_test(mapping_3d_kalman_local_trajectory_builder_test - USES_CERES USES_EIGEN + USES_GLOG SRCS kalman_local_trajectory_builder_test.cc DEPENDS diff --git a/cartographer/mapping_3d/scan_matching/CMakeLists.txt b/cartographer/mapping_3d/scan_matching/CMakeLists.txt index b0d3534..1449c39 100644 --- a/cartographer/mapping_3d/scan_matching/CMakeLists.txt +++ b/cartographer/mapping_3d/scan_matching/CMakeLists.txt @@ -17,6 +17,7 @@ add_subdirectory("proto") google_library(mapping_3d_scan_matching_ceres_scan_matcher USES_CERES USES_EIGEN + USES_GLOG SRCS ceres_scan_matcher.cc HDRS @@ -38,8 +39,8 @@ google_library(mapping_3d_scan_matching_ceres_scan_matcher ) google_library(mapping_3d_scan_matching_fast_correlative_scan_matcher - USES_CERES USES_EIGEN + USES_GLOG SRCS fast_correlative_scan_matcher.cc HDRS @@ -78,8 +79,8 @@ google_library(mapping_3d_scan_matching_occupied_space_cost_functor ) google_library(mapping_3d_scan_matching_precomputation_grid - USES_CERES USES_EIGEN + USES_GLOG SRCS precomputation_grid.cc HDRS @@ -91,8 +92,8 @@ google_library(mapping_3d_scan_matching_precomputation_grid ) google_library(mapping_3d_scan_matching_real_time_correlative_scan_matcher - USES_CERES USES_EIGEN + USES_GLOG SRCS real_time_correlative_scan_matcher.cc HDRS diff --git a/cartographer/mapping_3d/sparse_pose_graph/CMakeLists.txt b/cartographer/mapping_3d/sparse_pose_graph/CMakeLists.txt index 88c847e..5e10133 100644 --- a/cartographer/mapping_3d/sparse_pose_graph/CMakeLists.txt +++ b/cartographer/mapping_3d/sparse_pose_graph/CMakeLists.txt @@ -13,8 +13,8 @@ # limitations under the License. google_library(mapping_3d_sparse_pose_graph_constraint_builder - USES_CERES USES_EIGEN + USES_GLOG SRCS constraint_builder.cc HDRS @@ -46,6 +46,7 @@ google_library(mapping_3d_sparse_pose_graph_constraint_builder google_library(mapping_3d_sparse_pose_graph_optimization_problem USES_CERES USES_EIGEN + USES_GLOG SRCS optimization_problem.cc HDRS @@ -67,8 +68,8 @@ google_library(mapping_3d_sparse_pose_graph_optimization_problem ) google_test(mapping_3d_sparse_pose_graph_optimization_problem_test - USES_CERES USES_EIGEN + USES_GLOG SRCS optimization_problem_test.cc DEPENDS diff --git a/cartographer/sensor/CMakeLists.txt b/cartographer/sensor/CMakeLists.txt index d48880e..000b0b0 100644 --- a/cartographer/sensor/CMakeLists.txt +++ b/cartographer/sensor/CMakeLists.txt @@ -29,8 +29,8 @@ google_library(sensor_compressed_point_cloud ) google_library(sensor_configuration - USES_CERES USES_EIGEN + USES_GLOG SRCS configuration.cc HDRS @@ -57,8 +57,8 @@ google_library(sensor_laser ) google_library(sensor_point_cloud - USES_CERES USES_EIGEN + USES_GLOG SRCS point_cloud.cc HDRS @@ -70,7 +70,7 @@ google_library(sensor_point_cloud ) google_library(sensor_sensor_packet_period_histogram_builder - USES_CERES + USES_GLOG SRCS sensor_packet_period_histogram_builder.cc HDRS diff --git a/cartographer/transform/CMakeLists.txt b/cartographer/transform/CMakeLists.txt index 22e623a..d3dd39d 100644 --- a/cartographer/transform/CMakeLists.txt +++ b/cartographer/transform/CMakeLists.txt @@ -15,8 +15,8 @@ add_subdirectory("proto") google_library(transform_rigid_transform - USES_CERES USES_EIGEN + USES_GLOG SRCS rigid_transform.cc HDRS @@ -49,8 +49,8 @@ google_library(transform_transform ) google_library(transform_transform_interpolation_buffer - USES_CERES USES_EIGEN + USES_GLOG SRCS transform_interpolation_buffer.cc HDRS diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 25a4aca..4e116b5 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -22,6 +22,8 @@ macro(_parse_arguments ARGS) USES_LUA USES_BOOST USES_WEBP + USES_GLOG + USES_GFLAGS ) set(ONE_VALUE_ARG ) set(MULTI_VALUE_ARGS SRCS HDRS DEPENDS) @@ -62,6 +64,15 @@ macro(_common_compile_stuff VISIBILITY) target_link_libraries("${NAME}" webp) endif() + # We rely on Ceres to find glog and gflags for us. + if(ARG_USES_GLOG) + target_link_libraries("${NAME}" glog) + endif() + + if(ARG_USES_GFLAGS) + target_link_libraries("${NAME}" gflags) + endif() + # Add the binary directory first, so that port.h is included after it has # been generated. target_include_directories("${NAME}" ${VISIBILITY} "${CMAKE_BINARY_DIR}") @@ -186,6 +197,18 @@ function(google_test NAME) add_test(${NAME} ${NAME}) endfunction() +function(google_binary NAME) + _parse_arguments("${ARGN}") + + add_executable(${NAME} + ${ARG_SRCS} ${ARG_HDRS} + ) + + _common_compile_stuff("PRIVATE") + + install(TARGETS "${NAME}" RUNTIME DESTINATION bin) +endfunction() + function(google_library NAME) _parse_arguments("${ARGN}") diff --git a/scripts/update_cmakelists.py b/scripts/update_cmakelists.py index 6eeacc0..9313aa0 100755 --- a/scripts/update_cmakelists.py +++ b/scripts/update_cmakelists.py @@ -93,11 +93,12 @@ def ExtractUses(source): uses.add("USES_EIGEN") if re.match(r"^#include ", line): uses.add("USES_LUA") - if re.match(r'^#include "(ceres|glog)/', line): - # We abuse Ceres CFLAGS for other Google libraries that we all depend on. - # The alternative is to ship and maintain our own Find*.cmake files which - # is not appealing. + if re.match(r'^#include "ceres/', line): uses.add("USES_CERES") + if re.match(r'^#include "glog/', line): + uses.add("USES_GLOG") + if re.match(r'^#include "gflags/', line): + uses.add("USES_GFLAGS") if re.match(r"^#include