Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake error with catkin_make #3

Closed
mtourne opened this issue Sep 25, 2013 · 5 comments
Closed

CMake error with catkin_make #3

mtourne opened this issue Sep 25, 2013 · 5 comments

Comments

@mtourne
Copy link

mtourne commented Sep 25, 2013

catkin_make hector_quadrotor yields these errors :

CMake Error at /home/mtourne/catkin_ws/build/hector_quadrotor/hector_uav_msgs/cmake/hector_uav_msgs-genmsg.cmake:155 (add_custom_target):
add_custom_target cannot create target
"hector_uav_msgs_generate_messages_cpp" because another target with the
same name already exists. The existing target is a custom target created
in source directory
"/home/mtourne/catkin_ws/src/hector_localization/hector_pose_estimation".
See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
/opt/ros/hydro/share/genmsg/cmake/genmsg-extras.cmake:287 (include)
hector_quadrotor/hector_uav_msgs/CMakeLists.txt:56 (generate_messages)

hector_uav_msgs_generate_messages_lisp, and hector_uav_msgs_generate_messages_py also generates errors.

@meyerj
Copy link
Member

meyerj commented Sep 25, 2013

hector_pose_estimation uses the hector_uav_msgs package only if it is available at build time (by find_package), without declaring a build dependency in its package.xml file. hector_uav_msgs is optional and hector_pose_estimation should be usable without the hector_quadrotor stack.

It is not possible to declare an optional dependency in package.xml. The CMake error you observed is caused by the fact that catkin wants to build hector_uav_msgs after hector_pose_estimation and both packages generate the hector_uav_msgs_generate_messages_* targets in this case.

I guess there is no simple workaround here (@dirk-thomas?). You could add hector_uav_msgs as a build_depend in hector_pose_estimation/package.xml, which makes catkin sort the packages correctly and everything runs fine, but I am not sure what consequences this would have if the package is not available. I personally build hector_localization and hector_quadrotor in separate catkin workspaces and therefore never had this problem before.

Note that you only need the hector_pose_estimation package if you want to use more realistic estimated pose information for control and tf instead of ground truth. Otherwise you could place a CATKIN_IGNORE marker file in the hector_pose_estimation package folder and omit that package. If you install ros-hydro-message-to-tf binary package from the Ubuntu repos you also could omit the whole hector_localization repo.

@dirk-thomas
Copy link

I don't understand why multiple locations would generate the hector_uav_msgs_generate_messages_* targets. Only the hector_uav_msgs package is supposed to generate that target. Where is the other location where that gets generated?

@meyerj
Copy link
Member

meyerj commented Sep 26, 2013

The cmake configuration file of package hector_uav_msgs in devel/share/hector_uav_msgs/cmake/hector_uav_msgsConfig.cmake generates these custom targets if they do not exist.

If both packages are within the same workspace with proper dependencies, the targets are defined in the message package itself, whose cmake script is parsed first. If the message package belongs to another workspace, the empty custom targets are defined to not break cmake scripts that have a add_depedencies(my_target hector_uav_msgs_generate_messages_cpp) line.

I don't have time to look into this more closely right now. Just use two separate workspaces or use hector_quadrotor without hector_pose_estimation as a workaround, if this is okay for you.

@dirk-thomas
Copy link

catkin_make actually passes for the first invocation since hector_pose_estimation will just not find hector_uav_msgs since it is build before. But on any subsequent configure it will find hector_uav_msgs in the devel space since the CMake config file for it has been generated in the first run.

This conditional finding of hector_uav_msgs results in a non-deterministic behavior of the configure step. I can only highly recommend to not do it in this way. Just the fact that the public API of hector_pose_estimation changes is a strong indicator that this should be addressed differently. I think the right way to do that would be to make the UAV/MAV specific stuff an extension / plugin to the generic pose estimation.

@meyerj
Copy link
Member

meyerj commented Oct 9, 2013

I removed all dependencies to hector_uav_msgs from hector_pose_estimation and created a new package hector_quadrotor_pose_estimation instead (only in the new catkin branch of hector_quadrotor). The catkin_make error should have vanished.

Please comment if you still have problems like this. Obviously you should run the pose_estimation node from the new package for the case you are using it (which is not the default configuration currently).

@meyerj meyerj closed this as completed Oct 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants