Ask Your Question

add_dependencies(*_generate_messages_cpp) needed when depending on own message package?

asked 2016-05-23 13:18:12 -0500

peci1 gravatar image

Hello, we've faced a really strange problem. We're moving message/service definitions into standalone packages, and we've faced this:


make_minimum_required(VERSION 2.8.3)

find_package(catkin REQUIRED COMPONENTS message_generation std_msgs)

add_message_files(FILES AddRealCamera.msg VirtualCameraParameters.msg)
generate_messages(DEPENDENCIES std_msgs)

catkin_package(CATKIN_DEPENDS message_runtime std_msgs)


cmake_minimum_required(VERSION 2.8.3)


find_package(catkin REQUIRED COMPONENTS


include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(keyboard_teleop src/keyboard_teleop.cpp)
target_link_libraries(keyboard_teleop ${catkin_LIBRARIES})

I was almost sure it is not needed to add add_dependencies(keyboard_teleop virtual_camera_msgs_generate_messages_cpp), since CATKIN_DEPENDS on the whole virtual_camera_msgs package should automatically build all of its targets before continuing to the package that includes it.

However, if I don't add the add_dependencies clause, the build fails not finding virtual_camera_msgs/AddRealCamera.h, which should be built by the message package.

Do you know why the generate_messages_cpp target is not run before building the dependent package?

Using catkin_make --use-ninja, I've tried removing build and devel and sourcing the setup.bashs again.

edit retag flag offensive close merge delete


peci1 gravatar image peci1  ( 2016-05-25 08:26:07 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-05-26 04:19:26 -0500

peci1 gravatar image

Got an answer in the issue. It is said to be a technical limitation of catkin. You should indeed add add_dependencies(target catkin_EXPORTED_TARGETS) to every target that uses (any) ROS messages or other autogenerated code.

edit flag offensive delete link more


It is said to be a technical limitation of catkin

I think this is actually a CMake limitation, not necessarily catkin.

gvdhoorn gravatar image gvdhoorn  ( 2016-05-26 04:35:38 -0500 )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



Asked: 2016-05-23 13:18:12 -0500

Seen: 3,235 times

Last updated: May 26 '16