ROS CMakeLists.txt中catkin_package和INCLUDE_DIRS的区别

CMakeLists.txt中
catkin_package(INCLUDE_DIRS include …)
这里代表的是catkin的构建选项,INCLUDE_DIRS表示将使用INCLUDE_DIRS后面的内部目录include 的头文件

include_directories指定包含目录的选项,如果设置为${catkin_INCLUDE_DIRS}将引用每一个功能包中的include目录的头文件

区别是什么呢?
来源
The include_directories command will let the Compiler search For headers in the respective folder when compiling Files in the package the CMakeLists.txt belongs to.

The INCLUDE tag in command catkin_package will let the Compiler search for headers in the respective folder when compiling other catkin packages that depend in the package in which you added this to CMakeLists.txt.

我的理解:
编译器在编译每一个包的时候会去CMakeLists.txt中查看include_directories命令,并且根据这个命令查找包中的头文件
catkin_package中的INCLUDE tag会让编译器在编译其他包的时候,如果其他包依赖你这个包,那么会这个包中的catkin_package的INCLUDE 依赖头文件
反正我经常看到catkin_package 中的INCLUDE 是包下的include文件夹
include_directories(${catkin_INCLUDE_DIRS})

百度翻译:
当编译CMakeLists.txt所属包中的文件时,include_directories命令将允许编译器在相应文件夹中搜索头文件。
catkin_package中的INCLUDE标记将允许编译器在编译其他catkin包时搜索相应文件夹中的头文件,这些catkin包依赖于将其添加到CMakeLists.txt的包。

你可能感兴趣的:(Robot,ROS)