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

Cleanup CMakeLists target dependencies #228

Merged
merged 2 commits into from
Jul 18, 2020

Conversation

henningkayser
Copy link
Member

@henningkayser henningkayser commented Jun 25, 2020

Started looking into dependency issues with the Foxy branch and ended up cleaning up most of the dependencies.

@codecov
Copy link

codecov bot commented Jun 25, 2020

Codecov Report

Merging #228 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #228   +/-   ##
=======================================
  Coverage   47.35%   47.35%           
=======================================
  Files         143      143           
  Lines       13347    13347           
=======================================
  Hits         6321     6321           
  Misses       7026     7026           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9382ede...1525b39. Read the comment docs.

Copy link
Contributor

@v4hn v4hn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just looked through it once, commenting what I didn't immediately understand.

moveit_core/CMakeLists.txt Show resolved Hide resolved
${urdfdom_LIBRARIES}
${urdfdom_headers_LIBRARIES}
${rclcpp_headers_LIBRARIES}
${geometric_shapes_LIBRARIES}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are none of these needed anymore?

the test does use, e.g., moveit_constraint_samplers for all that I can see.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moveit_constraint_samplers is ${MOVEIT_LIB_NAME}. All other targets are provided with $MOVEIT_LIB_NAME so I didn't specify the same deps again for the test.

urdfdom
urdfdom_headers
octomap_msgs
OCTOMAP
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added public target includes for octomap before so that other libs linking with moveit_planning_scene automatically include the octomap headers. Does ament_target_dependencies automagically add the correct target includes as public/interface/private? How would it differentiate between private and non-private includes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not PUBLIC in MoveIt 1, so I removed it. We can specify octomap PUBLIC with ament_target_dependencies though.

ament_target_dependencies(test_planning_scene
ament_index_cpp
geometric_shapes
srdfdom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

urdf_parser is included, but not listed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provided by ${MOVEIT_LIB_NAME}

${MOVEIT_LIB_NAME}
${urdfdom_LIBRARIES}
${urdfdom_headers_LIBRARIES})
target_link_libraries(test_multi_threaded moveit_test_utils ${MOVEIT_LIB_NAME})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

robot_state, robot_model and collision_detection are included, but not listed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

${MOVEIT_LIB_NAME}
${geometric_shapes_LIBRARIES}
resource_retriever::resource_retriever
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

robot_state, robot_model, and robot_trajectory are included but not listed here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@henningkayser
Copy link
Member Author

henningkayser commented Jun 26, 2020

@v4hn thanks for reviewing this. My goal was to remove all the very generic (and often redundant) target_link_libraries() deps and includes and use ament_target_dependencies() more consistently. A lot of the removed includes were added in Crystal/Dashing where this wouldn't work like it does now. The "missing" dependencies should only be with test targets that really get all dependencies from a library which is specified in the same CMakeLists file. I found that this just makes sense and is less redundant than specifying the same target dependencies again and again. Considering the circular dependencies in moveit_core, it wouldn't even be possible to always cover all included targets anyway.

@v4hn
Copy link
Contributor

v4hn commented Jun 26, 2020

My goal was to remove all the very generic (and often redundant) target_link_libraries() deps

Now this is somewhat a matter of build-system philosophy (if such a term exists 😎). The consistent approach to header includes and linking definitions is to include and link what you use, whether or not you also depend on it transitively. This is because (1) you can syntactically identify all places depending on a package and (2) if the transitive dependency at some point vanishes, the code might still work. I tend to use this approach in my projects, but I do see the benefits of leaving them out.

I will leave it to someone else to accept this as I would not do it that way myself.

@henningkayser
Copy link
Member Author

My goal was to remove all the very generic (and often redundant) target_link_libraries() deps

Now this is somewhat a matter of build-system philosophy (if such a term exists ). The consistent approach to header includes and linking definitions is to include and link what you use, whether or not you also depend on it transitively. This is because (1) you can syntactically identify all places depending on a package and (2) if the transitive dependency at some point vanishes, the code might still work. I tend to use this approach in my projects, but I do see the benefits of leaving them out.

I will leave it to someone else to accept this as I would not do it that way myself.

I totally see your point. But then again, I only applied this "cleanup" to test executables that don't have any downstream dependencies. All other exported targets also define and export their dependencies explicitly (instead of using global includes and library lists as before). So for me it's just a question of linking/including transitive dependencies to tests which are provided by a target in the same CMakeLists file. It probably is really a matter of style/convention at some point, similar to moveit/moveit#2170.

Copy link
Member

@tylerjw tylerjw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity I ran catkin_lint on this PR and these are the only cmake errors:

moveit_planners_chomp: CMakeLists.txt(16): error: duplicate find_package(catkin)
moveit_ros_robot_interaction: CMakeLists.txt(54): error: missing test_depend on 'rosunit'
moveit_setup_assistant: CMakeLists.txt(166): error: missing test_depend on 'rosunit'

I'm not sure if these matter, but they might be worth fixing while you are refactoring some of the cmake files. I looked through these changes and they seem to make sense to me. I'll approve it as I don't have anything against these changes.

@henningkayser
Copy link
Member Author

Out of curiosity I ran catkin_lint on this PR and these are the only cmake errors:

moveit_planners_chomp: CMakeLists.txt(16): error: duplicate find_package(catkin)
moveit_ros_robot_interaction: CMakeLists.txt(54): error: missing test_depend on 'rosunit'
moveit_setup_assistant: CMakeLists.txt(166): error: missing test_depend on 'rosunit'

I'm not sure if these matter, but they might be worth fixing while you are refactoring some of the cmake files. I looked through these changes and they seem to make sense to me. I'll approve it as I don't have anything against these changes.

@tylerjw Thanks for reviewing and testing catkin_lint on this. The failing packages have not been ported yet and have therefore not been checked by ament_lint_cmake. The reported errors should be addressed with migration - fixes are automatically enforced by CI in that case. But maybe it would make sense to enable catkin_lint in MoveIt 1.

@henningkayser henningkayser merged commit 6477cd5 into moveit:master Jul 18, 2020
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

Successfully merging this pull request may close these issues.

3 participants