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

Creating a .so library that depends on message headers

asked 2014-06-26 23:54:45 -0600

bjem85 gravatar image

updated 2022-01-22 16:16:28 -0600

Evgeny gravatar image

Hi,

I am trying to create a library that depends on header files generated by a call to generate_messages(). The message list is:

project(ros_otp22)

add_message_files( FILES hydraulic_arm.msg valve_command.msg valve_command_info.msg angular_rate_info.msg slope_info.msg accel_info.msg )

The library call is add_library(o22pac src/o22pac/o22pac.cpp). This sometimes works and sometimes doesn't depending on the exact order in which the message header files are generated.

What I need is a list variable that does into the add_library() call that lists the files. Using ${PROJECT_NAME}_generate_message_cpp (such as for add_dependencies()) does NOT work as it does not generate a list of header file names.

I could create my own list of headers, but that seems like a monumental waste of time an effort, source of bugs and misconfiguration and violation of the 'DRY' (don't repeat yourself) principle since catkin_make and cmake should already be aware of what headers the .msg files generate.

Is there a variable generated by catkin that represents a list of the header files by name? My searches of the documentation have found nothing promising.

Thanks, Bart

edit retag flag offensive close merge delete

Comments

http://answers.ros.org/question/52744/how-to-specify-dependencies-with-foo_msgs-catkin-packages/?answer=54418#post-id-54418

bvbdort gravatar image bvbdort  ( 2014-06-27 03:08:37 -0600 )edit

I did see this answer, but it is talking about adding executables, not adding libraries.

bjem85 gravatar image bjem85  ( 2014-06-29 17:20:26 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-06-29 17:24:13 -0600

bjem85 gravatar image

The answer is that you have to add the add_dependencies() call after the add_library() call.

Unfortunately a lot of frustration was caused by the fact that neither the documentation at: http://wiki.ros.org/catkin/CMakeLists... or http://www.cmake.org/cmake/help/v3.0/... states this explicitly.

edit flag offensive delete link more

Comments

I may be biased here, but doesn't that just 'make sense'? It seems logical to me that you can only configure dependencies for a target that has already been declared, similar to how one can only assign a value to a variable that has been declared before (in C++) fi.

gvdhoorn gravatar image gvdhoorn  ( 2014-06-30 02:04:56 -0600 )edit

You're not wrong, but it depends on what you consider to make sense. Note that order of declaration of targets and dependencies doesn't matter in this way in all build systems, in particular `make`: you can declare targets and dependencies in any order in the `Makefile` and `make` will work it out.

bjem85 gravatar image bjem85  ( 2014-06-30 05:16:47 -0600 )edit

True. Perhaps the documentation could be improved. Have you considered submitting an issue to the catkin Github repository? Also, @joq could perhaps add a note to his -- excellent -- catkin tutorials?

gvdhoorn gravatar image gvdhoorn  ( 2014-06-30 06:31:52 -0600 )edit

I agree that the docs should not assume everyone knowns CMake well. If you can suggest where information should be added, I will make the update. Here, perhaps? http://docs.ros.org/api/catkin/html/howto/format2/cpp_msg_dependencies.html ?

joq gravatar image joq  ( 2014-06-30 09:47:26 -0600 )edit
joq gravatar image joq  ( 2014-06-30 09:50:15 -0600 )edit

@joq: seems it is indeed. Perhaps the wording of the text could be improved a bit by emphasizing the importance of the order of the statements?

gvdhoorn gravatar image gvdhoorn  ( 2014-06-30 14:48:18 -0600 )edit

Yes. Just wanted to make sure adding it there would resolve this problem.

joq gravatar image joq  ( 2014-06-30 15:46:41 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-06-26 23:54:45 -0600

Seen: 700 times

Last updated: Jun 29 '14