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.
master
Holger Rapp 2016-10-11 15:18:59 +02:00 committed by GitHub
parent 8f5fc98188
commit eeb17bf055
13 changed files with 87 additions and 49 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}")

View File

@ -93,11 +93,12 @@ def ExtractUses(source):
uses.add("USES_EIGEN")
if re.match(r"^#include <lua.hpp>", 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 <boost/", line):
uses.add("USES_BOOST")
if re.match(r'^#include "webp/', line):
@ -177,6 +178,16 @@ def main():
name = module_name + "_" + path.basename(path.splitext(c)[0])
AddTarget("google_proto_library", name, directory, [c], [])
mains = set(fn for fn in sources if fn.endswith("_main.cc"))
sources -= mains
for c in sorted(mains):
# Binaries do not get their full subpath appended, but we prepend
# 'cartographer' to distinguish them after installation. So,
# 'io/asset_writer_main.cc' will generate a binary called
# 'cartographer_asset_writer'.
name = 'cartographer_' + path.basename(path.splitext(c)[0][:-5])
AddTarget("google_binary", name, directory, [c], [])
assert (not sources), "Remaining sources without target: %s" % sources
# Write the CMakeLists.txt files.