ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
10

What's the effect of find_package(catkin components ...)?

asked 2012-11-12 08:26:45 -0600

KruseT gravatar image

updated 2012-11-15 04:43:32 -0600

mjcarroll gravatar image

It seems that with catkin in Groovy,

find_package(catkin COMPONENTS roscpp std_msgs)

is equivalent to

find_package(catkin)
find_package(roscpp)
find_package(std_msgs)

Is there any difference?

edit retag flag offensive close merge delete

Comments

Follow up question: How does CMake know to look for the .cmake config files in the /opt/ros/ directory?

2ROS0 gravatar image 2ROS0  ( 2017-04-21 17:28:50 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
11

answered 2012-11-12 09:10:22 -0600

WilliamWoodall gravatar image

As far as I understand they are equivalent.

The only difference is that find_package(catkin COMPONENTS roscpp std_msgs) will consolidate all of the COMPONENTS into the catkin_* CMake variables, for instance catkin_INCLUDE_DIRS will contain roscpp_INCLUDE_DIRS and std_msgs_INCLUDE_DIRS.

edit flag offensive delete link more

Comments

1

I could have checked the docs: http://ros.org/wiki/catkin/CMakeLists.txt

KruseT gravatar image KruseT  ( 2012-11-13 00:31:25 -0600 )edit
7

answered 2012-11-12 11:27:28 -0600

mirzashah gravatar image

updated 2016-06-17 10:02:52 -0600

130s gravatar image

Though it may be obvious from William's response, using the first method is more convenient and actually recommended. the consequence of using the latter is that all of the CMake functions/macros that utilize environment variables generated by find_package() have to have the corresponding variable listed as an argument. For C++ code, this particularly effects include_directories() and target_link_libraries(). Example:

Instead of :

include_directories(${catkin_INCLUDE_DIRS})
add_executable(foo ...)
target_link_libraries(foo ${catkin_LIBRARIES})

You would have:

include_directories(${catkin_INCLUDE_DIRS} ${roscpp_INCLUDE_DIRS} ${std_msgs_INCLUDE_DIRS})
add_executable(foo ...)
target_link_libraries(foo ${catkin_LIBRARIES} ${roscpp_LIBRARIES} ${std_msgs_LIBRARIES})

So save yourself effort and always find catkin packages as components of catkin!

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-11-12 08:26:45 -0600

Seen: 2,363 times

Last updated: Jun 17 '16