-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Revamp nav2_util CMakeLists.txt to use modern idioms. #4393
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,34 +10,41 @@ add_library(${library_name} SHARED | |
| odometry_utils.cpp | ||
| array_parser.cpp | ||
| ) | ||
|
|
||
| ament_target_dependencies(${library_name} | ||
| rclcpp | ||
| nav2_msgs | ||
| tf2 | ||
| tf2_ros | ||
| nav_msgs | ||
| geometry_msgs | ||
| lifecycle_msgs | ||
| rclcpp_lifecycle | ||
| tf2_geometry_msgs | ||
| bondcpp | ||
| target_include_directories(${library_name} | ||
| PUBLIC | ||
| "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>" | ||
| "$<INSTALL_INTERFACE:include/${PROJECT_NAME}>") | ||
| target_link_libraries(${library_name} PUBLIC | ||
| bondcpp::bondcpp | ||
| ${geometry_msgs_TARGETS} | ||
| ${lifecycle_msgs_TARGETS} | ||
| ${nav2_msgs_TARGETS} | ||
| ${nav_msgs_TARGETS} | ||
| ${rcl_interfaces_TARGETS} | ||
| rclcpp::rclcpp | ||
| rclcpp_action::rclcpp_action | ||
| rclcpp_lifecycle::rclcpp_lifecycle | ||
| tf2_ros::tf2_ros | ||
| tf2::tf2 | ||
| ${tf2_geometry_msgs_TARGETS} | ||
| ) | ||
| target_link_libraries(${library_name} PRIVATE | ||
| ${bond_TARGETS} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: why is this one & rclcpp below private? When do we do public vs private?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, good question. So the difference between PUBLIC and PRIVATE is that PUBLIC dependencies are exported to downstream consumers, while PRIVATE ones are not. Marking dependencies as PRIVATE (where they can be) is part of what helps speed up compilation, since the compiler doesn't have to go searching through additional directories for headers and libraries. As for when to use each, there are separate rules for executables and libraries:
As a concrete example for 2, in Does this make sense?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But if that was in the So.. is it worth me at some point doing a review of the stack and moving as much to cpp files to make the dependencies private?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'll preface this by saying I don't completely know how this works, so the below is a bit of speculation. Thinking about it, if you have a symbol that is only ever internal to a library, then no downstream can ever make (direct) reference to it. Thus, the downstream packages don't have to know how to resolve that upstream symbol in order to compile/link. They do have to know how to resolve that symbol at runtime, but I believe that is handled either via RPATH/RUNPATH, or via LD_LIBRARY_PATH.
Yes, exactly.
Moving as much as possible into the |
||
| ) | ||
|
|
||
| add_executable(lifecycle_bringup | ||
| lifecycle_bringup_commandline.cpp | ||
| ) | ||
| target_link_libraries(lifecycle_bringup ${library_name}) | ||
| target_link_libraries(lifecycle_bringup PRIVATE ${library_name} rclcpp::rclcpp) | ||
|
|
||
| add_executable(base_footprint_publisher | ||
| base_footprint_publisher.cpp | ||
| ) | ||
| target_link_libraries(base_footprint_publisher ${library_name}) | ||
|
|
||
| find_package(Boost REQUIRED COMPONENTS program_options) | ||
| target_link_libraries(base_footprint_publisher PRIVATE ${library_name} rclcpp::rclcpp ${tf2_msgs_TARGETS}) | ||
|
|
||
| install(TARGETS | ||
| ${library_name} | ||
| EXPORT ${library_name} | ||
| ARCHIVE DESTINATION lib | ||
| LIBRARY DESTINATION lib | ||
| RUNTIME DESTINATION bin | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.