# CMakeLists.txt ## Overview `CMakeLists.txt` is the CMake build definition for the `cartographer_ros_msgs` package. It declares the message and service files, registers them with the ROS 2 interface generator, and sets up lint tests. ## Details - **Minimum CMake version**: 3.5, set via `cmake_minimum_required(VERSION 3.5)`. - **Project name**: `cartographer_ros_msgs`. - **C++ standard**: Defaults to C++14 via `CMAKE_CXX_STANDARD` when not already set. - **Compiler flags**: For GCC and Clang, `-Wall`, `-Wextra`, and `-Wpedantic` are added to `CMAKE_CXX_FLAGS`. The `pedantic` option is deliberately not used in this message package because the generated Python C extensions do not comply with it. ## Message and Service Registration The `msg_files` variable lists all 13 message definitions under `msg/`: ```cmake set(msg_files "msg/BagfileProgress.msg" "msg/HistogramBucket.msg" "msg/LandmarkEntry.msg" "msg/LandmarkList.msg" "msg/MetricFamily.msg" "msg/MetricLabel.msg" "msg/Metric.msg" "msg/StatusCode.msg" "msg/StatusResponse.msg" "msg/SubmapEntry.msg" "msg/SubmapList.msg" "msg/SubmapTexture.msg" "msg/TrajectoryStates.msg" ) ``` The `srv_files` variable lists all 7 service definitions under `srv/`: ```cmake set(srv_files "srv/FinishTrajectory.srv" "srv/GetTrajectoryStates.srv" "srv/ReadMetrics.srv" "srv/StartTrajectory.srv" "srv/TrajectoryQuery.srv" "srv/SubmapQuery.srv" "srv/WriteState.srv" ) ``` ## Interface Generation `rosidl_generate_interfaces` is invoked with the project name and both file lists: ```cmake rosidl_generate_interfaces(${PROJECT_NAME} ${msg_files} ${srv_files} DEPENDENCIES builtin_interfaces geometry_msgs std_msgs ADD_LINTER_TESTS ) ``` - `DEPENDENCIES` declares the other interface packages whose types are referenced by the definitions. - `ADD_LINTER_TESTS` enables lint tests on the generated interfaces. ## Package Finalization - `ament_export_dependencies(rosidl_default_runtime)` exports the runtime dependency on `rosidl_default_runtime`. - `ament_package()` finalizes the ament package. ## Prerequisites The file requires the following CMake packages to be found: - `ament_cmake` - `rosidl_default_generators` - `builtin_interfaces` - `geometry_msgs` - `std_msgs`