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

Update CMakeLists.txt and package.xml #404

Merged
merged 20 commits into from
Jan 14, 2020

Conversation

matthew-reynolds
Copy link
Member

@matthew-reynolds matthew-reynolds commented Dec 29, 2019

Various fixes and formatting for CMakeLists.txt and package.xml files, including fixes suggested by catkin_lint.


Apply consistent format to CMakeLists.txt and package.xml files

The format is largely based on the existing files. The most important change is that this PR corrects the order of commands in the CMakeLists.txt.

I'm not at all attached to the format used in the CMakeLists.txt, happy to gut out the comments or make other stylistic changes as desired. I would mostly just like them to be consistent, as it makes it much easier to identify issues and to maintain.


Beyond stylistic changes, the following changes were made:

combined_robot_hw:

  • Remove unnecessary boost library dependency

combined_robot_hw_tests:

  • Remove unnecessary boost library dependency
  • Add missing ${catkin_EXPORTED_TARGETS} dependency
  • Gut the catkin_package() and install() commands
  • Move all targets into the if(CATKIN_ENABLE_TESTING) block
  • Update package description
  • Add missing dependencies to package.xml

controller_interface:

  • Remove rosunit dependency (See note at bottom)
  • Remove unneeded pluginlib dependency

controller_manager:

  • Add missing roscpp dependency
  • Add missing ${catkin_EXPORTED_TARGETS} dependency
  • Add missing exec_depends for python scripts

controller_manager_msgs:

  • Add missing exec_depends for python scripts

controller_manager_tests:

  • Remove unnecessary boost include_dir dependency
  • Add missing hardware_interface and roscpp dependencies
  • Add missing ${catkin_EXPORTED_TARGETS} dependency
  • Gut the catkin_package() and install() commands
  • Move all targets into the if(CATKIN_ENABLE_TESTING) block
  • Update package description
  • Update dependencies in package.xml

hardware_interface:

  • Add missing find_package(Boost REQUIRED) for header-only library dependency ptr_container
  • Add missing boost depend in package.xml
  • Remove redundant rosconsole dependency (Already included via roscpp)
  • Remove unused rostest test_depend
  • Remove rosunit dependency (See note at bottom)

joint_limits_interface:

rqt_controller_manager:

  • Install python scripts with catkin_install_python() rather than the default cmake install()
  • Update package description
  • Add missing dependencies

transmission_interface:


Notes:

I was unable to find up-to-date documentation on rosunit and the corresponding catkin_add_gtest/catkin_add_gmock. In particular, I don't know if it is necessary to find_package(rosunit) or <test_depend>rosunit</test_depend>. I believe the find_package is unecessary. I think the test_depend is required, but I'm not sure.

For header-only Boost libraries, I used find_package(Boost REQUIRED) and include_directories(${Boost_INCLUDE_DIRS}). I was not able to find any other examples of this use in large ROS packages, so I just wanted to highlight it here in case there's a better approach.


TODO:

Couple things I just want to look through before changing this from a draft to a normal PR:

  • Make sure add_dependencies(${catkin_EXPORTED_TARGETS}) is used everywhere it's required Done in fa93166
  • Make sure roscpp is depended upon directly everywhere that it's required Done in 79b504c
  • Investigate the urdf/liburdf-dev situation, and see if things can be simplified Done in 7ca25ab

@bmagyar bmagyar self-requested a review January 5, 2020 08:53
combined_robot_hw/CMakeLists.txt Show resolved Hide resolved
combined_robot_hw_tests/CMakeLists.txt Outdated Show resolved Hide resolved
combined_robot_hw_tests/CMakeLists.txt Show resolved Hide resolved
controller_manager_tests/CMakeLists.txt Outdated Show resolved Hide resolved
hardware_interface/package.xml Outdated Show resolved Hide resolved
joint_limits_interface/package.xml Outdated Show resolved Hide resolved
transmission_interface/package.xml Show resolved Hide resolved
transmission_interface/package.xml Show resolved Hide resolved
@bmagyar
Copy link
Member

bmagyar commented Jan 7, 2020

@matthew-reynolds is there anything else you'd add apart from the outstanding review points? (The PR is still in draft mode)

@matthew-reynolds
Copy link
Member Author

Been quite busy the last 2 weeks, my apologies. Other than the outstanding review points, I just want to double check those last couple points in the initial PR message (that we're not missing and roscpp or ${catkin_EXPORTED_TARGETS} dependencies). I'll try to get through this in the next couple days :)

@matthew-reynolds
Copy link
Member Author

matthew-reynolds commented Jan 9, 2020

While finding missing roscpp & rospy deps, I found a couple additional missing package dependencies (some msgs, pluginlib in some tests, etc). Will do another thorough pass to fix all of those.

Still need to double check we're not missing any ${catkin_EXPORTED_TARGETS} cmake dependencies, and go over the urdf & tinyxml situation again.

@matthew-reynolds matthew-reynolds marked this pull request as ready for review January 11, 2020 22:26
hardware_interface/package.xml Outdated Show resolved Hide resolved
transmission_interface/package.xml Outdated Show resolved Hide resolved
@matthew-reynolds
Copy link
Member Author

Follow-up issues all opened. Ready for final review of this PR.

Would you like me to reference #410 in the comment I left in the two _tests CMakeLists.txt?

BTW, came across these while working on this PR: #117 and #157 both look like old issues that have long been resolved. I think they should be closed.

@bmagyar
Copy link
Member

bmagyar commented Jan 12, 2020

Thanks very much for sticking through this long review.
No worries, we are fine without that comment, the issue is open here.
I've closed those two outdated ones, thanks for bringing it to my attention!

@bmagyar bmagyar self-assigned this Jan 12, 2020
@bmagyar
Copy link
Member

bmagyar commented Jan 12, 2020

Apologies for the abrupt "merge branch..." solution, I dared to resolve the conflict using github's interface, please feel free to squash that with any of your commits.

 - Dependencies needed to compile are <build_depend>
 - Dependencies used in public headers are <build_export_depend>
 - Dependencies needed to link or run are <exec_depend>
@bmagyar
Copy link
Member

bmagyar commented Jan 14, 2020

Thanks @matthew-reynolds for the great for and @gavanderhoorn for the additional review, I am merging this now!

@bmagyar bmagyar merged commit 59e65b8 into ros-controls:melodic-devel Jan 14, 2020
@matthew-reynolds matthew-reynolds deleted the catkin-lint branch January 14, 2020 13:03
)
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})

add_executable(dummy_app EXCLUDE_FROM_ALL src/dummy_app.cpp)
Copy link
Contributor

Choose a reason for hiding this comment

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

Where did EXCLUDE_FROM_ALL come from?

Copy link
Member Author

Choose a reason for hiding this comment

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

When looking at the targets in all the test packages in https://github.com/ros/ros_comm/tree/melodic-devel/test as an example, I saw they marked targets intended for tests as EXCLUDE_FROM_ALL. Similarly, targets generated by catkin_add_gtest() and catkin_add_gmock() enable the property.

I admit, I don't fully understand why this is required, since the test targets are already wrapped in the if(CATKIN_ENABLE_TESTING). I have the impression it was to cover an edge-case with catkin_make (as opposed to catkin_make_isolated or catkin_tools), something to do with the single CMake invocation over the entire workspace, but instead of properly researching and understanding it, I just used those packages as examples and mimicked.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Or use add_rostest_gtest, which would automate most of the steps.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think you have to add the targets to tests manually

Ah, I think you're right, that makes sense. Since those targets are only depended on by targets in add_rostest, not add_rostest_gtest, they aren't directly or transitively depended on by the tests target, and since I added the EXCLUDE_FROM_ALL property, they aren't part of the all target either. Sounds like this may be the cause of the colcon failure you mentioned.

I will re-add the add_dependencies(tests target_name) for executable targets used in tests. What are your and @bmagyar's thoughts on also adding library targets as dependencies? Back to the ros_comm test package examples, they seem to only mark executables as deps, and rely on libraries being pulled in transitively.

Copy link
Contributor

Choose a reason for hiding this comment

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

rely on libraries being pulled in transitively.

This is sufficient. Add direct dependencies only.

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.

4 participants