CMakeLists.txt

The CMakeLists.txt file configures the cartographer_rviz package for the ament_cmake build system. It requires CMake 3.5 or newer and defaults the C++ standard to C++17, turning on -Wall -Wextra for GCC and Clang. CMAKE_AUTOMOC is enabled so that the Qt meta-object compiler processes the plugin classes.

Dependencies

The build imports several packages:

  • ament_cmake, cartographer (which provides $CARTOGRAPHER_CMAKE_DIR/functions.cmake), absl, cartographer_ros, cartographer_ros_msgs, Eigen3, pluginlib, rclcpp, rviz_common, rviz_ogre_vendor, rviz_rendering, and Threads.

  • BUILD_SHARED_LIBS is set to OFF and an option BUILD_GRPC (default false) is declared, both forwarded to the Cartographer project initialization helper google_initialize_cartographer_project().

Plugin library

The rviz_plugins_headers_to_moc list names the three public headers that must be run through the Qt MOC (drawable_submap.h, ogre_slice.h, submaps_display.h).

A shared library cartographer_rviz is built from:

  • src/drawable_submap.cpp

  • src/ogre_slice.cpp

  • src/submaps_display.cpp

  • plus the MOC’d headers

Public include directories are the source and build-time include/ tree, and the library links publicly against absl::synchronization, cartographer, cartographer_ros::cartographer_ros, Eigen3::Eigen, rclcpp, rviz_common, rviz_rendering, and tf2_ros; pluginlib is a private dependency.

Plugin and resource registration

  • pluginlib_export_plugin_description_file(rviz_common rviz_plugin_description.xml) exports the plugin manifest so RViz can load SubmapsDisplay.

  • register_rviz_ogre_media_exports(...) registers the ogre_media/materials/glsl120 and ogre_media/materials/scripts directories as OGRE media resources.

Install and export

The library target and the include/ tree are installed under include/${PROJECT_NAME}. The package exports its include directories, library, build targets, and ament dependencies (absl, cartographer, cartographer_ros, eigen, rclcpp, rviz_common, rviz_rendering, tf2_ros) via ament_export_*(), then calls ament_package().