Ask Your Question

catkin_package(INCLUDE_DIRS include) vs. include_directories(include)

asked 2017-04-04 18:33:10 -0600

2ROS0 gravatar image


What does the catkin_package call do when you specify include as an INCLUDE_DIRS and is that the same as specifying include inside of include_directories?

There is a short explanation on the template CMakeLists.txt file but it doesn't mention anything about the two above methods being the same effectively (if at all they are)? If they are not the same then what is the purpose of each individual one.

Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-04-04 22:47:56 -0600

Wolf gravatar image

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.

edit flag offensive delete link more


So the path entered in INCLUDE_DIRS tag in catkin_package() is relative to _all_ the dependent packages? That seems counterintuitive - what if different dependent packages had their header files in different relative locations?

2ROS0 gravatar image 2ROS0  ( 2017-04-04 23:38:16 -0600 )edit

No, if you add include to catkin_package all dependent packages will user the include sub folder of the package in which you added it. There own (relative) include folder still has to be added using include_directories

Wolf gravatar image Wolf  ( 2017-04-05 00:03:40 -0600 )edit

So if I had two packages A and B such that package B depends on A. Then in the CMakeLists.txt of package A, I should add my INCLUDE_DIRS so that package B can know where to find the files when it's compiling? That means, I should always add INCLUDE_DIRS whenever I have headers?

2ROS0 gravatar image 2ROS0  ( 2017-04-05 17:55:53 -0600 )edit

Yes, assuming the headers are not just internal.

joq gravatar image joq  ( 2017-04-06 11:23:14 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-04-04 18:33:10 -0600

Seen: 2,278 times

Last updated: Apr 04 '17