答案基本上由以下自动生成的评论给出CMakeLists.txt
:
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS ...
和
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(...
该find_package
命令是常见的 cmake 并且需要加载 catkin 宏并指定对其他 ROS 包的依赖关系。
该catkin_package
命令是这些 catkin 宏之一。它负责包的特定于 ROS 的配置。所以这是区分 ROS 包和普通 cmake 项目的关键部分。我不知道细节,但我猜它负责设置 catkin 工作区的正确构建路径。
当其他 ROS 包依赖于这个时,这里给出的参数(即依赖项)很重要。