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

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

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

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:

virtual_camera_msgs/CMakeLists.txt:

make_minimum_required(VERSION 2.8.3)
project(virtual_camera_msgs)

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)

virtual_camera/CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(virtual_camera)

set(THIS_PROJECT_DEPS
  ...
  virtual_camera_msgs
)

find_package(catkin REQUIRED COMPONENTS
  ${THIS_PROJECT_DEPS}
)

catkin_package(CATKIN_DEPENDS ${THIS_PROJECT_DEPS})

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

Comments

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

1 Answer

Sort by ยป oldest newest most voted
0

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

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

Comments

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 -0600 )edit

Question Tools

3 followers

Stats

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

Seen: 4,490 times

Last updated: May 26 '16