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

What is the use of CATKIN_DEPENDS in catkin_package (CMakeLists.txt)?

asked 2016-06-18 12:10:11 -0500

khatribharat gravatar image

CATKIN_DEPENDS parameter for the catkin_package function reads "a list of catkin projects which this project depends on".

Isn't this information already available in package.xml?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2016-06-18 13:52:18 -0500

ahendrix gravatar image

The catkin_package macro is specifically for building C++ code; the CATKIN_DEPENDS (and DEPENDS) parameters to it specify the packages that are needed (via their include directories, flags, and libraries) for other packages to compile against this package.

There is some overlap with the dependencies listed in package.xml, but package.xml also includes dependencies for all languages, and run-time as well as build dependencies. The dependencies listed with CATKIN_DEPENDS are always a subset of these dependencies, but frequently are not everything that is listed in package.xml.

edit flag offensive delete link more

Comments

B depends on A & C depends on B. B find_package-s, build_depend-s & run_depend-s A. C find_package-s, build_depend-s & run_depend-s B. Installing B gets B's runtime dependencies & find_package-ing B find_package-s A, so C gets A's headers & libraries as well. So B CATKIN_DEPEND-ing A isn't required.

khatribharat gravatar image khatribharat  ( 2016-06-18 15:24:43 -0500 )edit

False. In the example that you give, if B provides a header that depends on a header in A, and C uses that header, C will fail to compile if B does not specify a CATKIN_DEPENDS on A. (particularly if building a three packages from source)

ahendrix gravatar image ahendrix  ( 2016-06-18 21:32:59 -0500 )edit
2

C does not get A's headers and libraries included in the B_INCLUDE_DIRS and B_LIBRARIES unless B explicitly lists them in CATKIN_DEPENDS (most times this goes unnoticed if A and B are installed from binaries and their includes are installed in the same directory)

ahendrix gravatar image ahendrix  ( 2016-06-18 21:34:45 -0500 )edit

@^ Can you update the answer with this example? This'll be really helpful for others who visit the page.

khatribharat gravatar image khatribharat  ( 2016-06-19 02:44:28 -0500 )edit

@ahendrix One more question, dependencies tagged using <build_export_depend> in package.xml, and dependencies tagged using CATKIN_DEPENDS and DEPENDS in catkin_package in CMakeLists.txt would always be the same set, right? So including them just in package.xml should suffice.

khatribharat gravatar image khatribharat  ( 2016-06-19 13:59:09 -0500 )edit

No. package.xml defines WHEN dependencies should be installed (which circumstances, such as build or run), and CMakeLists.txt and the catkin_package function define HOW to use those dependencies in C++. (catkin_package does not apply to Python, for example)

ahendrix gravatar image ahendrix  ( 2016-06-20 02:26:54 -0500 )edit

Got the WHEN and HOW. I wanted to confirm that dependencies tagged with <build_export_depend> in package.xml, & dependencies tagged with CATKIN_DEPENDS, & DEPENDS in CMakelists.txt are the same set. Thought catkin could automatically populate CMakelists.txt with this info from package.xml

khatribharat gravatar image khatribharat  ( 2016-06-20 04:04:35 -0500 )edit

Obviously you don't get it or you wouldn't still be trying to contradict my answer. catkin does not automatically populate any of that information in the CMakeLists.txt from the package.xml

ahendrix gravatar image ahendrix  ( 2016-06-20 11:23:12 -0500 )edit

Question Tools

4 followers

Stats

Asked: 2016-06-18 12:10:11 -0500

Seen: 1,107 times

Last updated: Jun 18 '16