Skip to content

Commit

Permalink
Remove all uses of ament_target_dependencies. (#159)
Browse files Browse the repository at this point in the history
Instead we can just rely on target_link_libraries.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette authored Nov 22, 2023
1 parent fd1321c commit 1cf5178
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 21 deletions.
53 changes: 34 additions & 19 deletions turtlesim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ find_package(ament_cmake REQUIRED)
find_package(ament_index_cpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Widgets)
find_package(rcl_interfaces REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rosidl_default_generators REQUIRED)
Expand All @@ -32,35 +33,49 @@ rosidl_generate_interfaces(${PROJECT_NAME}
"srv/TeleportAbsolute.srv"
"srv/TeleportRelative.srv")

set(dependencies "ament_index_cpp" "geometry_msgs" "rclcpp" "rclcpp_action" "std_msgs" "std_srvs")
qt5_wrap_cpp(turtlesim_node_MOCS include/turtlesim/turtle_frame.hpp)

set(turtlesim_node_SRCS
rosidl_get_typesupport_target(cpp_typesupport_target "${PROJECT_NAME}" "rosidl_typesupport_cpp")

add_executable(turtlesim_node
src/turtlesim.cpp
src/turtle.cpp
src/turtle_frame.cpp
${turtlesim_node_MOCS}
)
set(turtlesim_node_HDRS
include/turtlesim/turtle_frame.hpp
target_link_libraries(turtlesim_node PRIVATE
ament_index_cpp::ament_index_cpp
${cpp_typesupport_target}
${geometry_msgs_TARGETS}
Qt5::Widgets
${rcl_interfaces_TARGETS}
rclcpp::rclcpp
rclcpp_action::rclcpp_action
${std_srvs_TARGETS}
)

qt5_wrap_cpp(turtlesim_node_MOCS ${turtlesim_node_HDRS})

rosidl_get_typesupport_target(cpp_typesupport_target "${PROJECT_NAME}" "rosidl_typesupport_cpp")

add_executable(turtlesim_node ${turtlesim_node_SRCS} ${turtlesim_node_MOCS})
target_link_libraries(turtlesim_node Qt5::Widgets)
ament_target_dependencies(turtlesim_node ${dependencies})
target_link_libraries(turtlesim_node "${cpp_typesupport_target}")

add_executable(turtle_teleop_key tutorials/teleop_turtle_key.cpp)
ament_target_dependencies(turtle_teleop_key ${dependencies})
target_link_libraries(turtle_teleop_key "${cpp_typesupport_target}")
target_link_libraries(turtle_teleop_key PRIVATE
"${cpp_typesupport_target}"
${geometry_msgs_TARGETS}
rclcpp::rclcpp
rclcpp_action::rclcpp_action
)

add_executable(draw_square tutorials/draw_square.cpp)
ament_target_dependencies(draw_square ${dependencies})
target_link_libraries(draw_square "${cpp_typesupport_target}")
target_link_libraries(draw_square PRIVATE
"${cpp_typesupport_target}"
${geometry_msgs_TARGETS}
rclcpp::rclcpp
${std_srvs_TARGETS}
)

add_executable(mimic tutorials/mimic.cpp)
ament_target_dependencies(mimic ${dependencies})
target_link_libraries(mimic "${cpp_typesupport_target}")
target_link_libraries(mimic PRIVATE
"${cpp_typesupport_target}"
${geometry_msgs_TARGETS}
rclcpp::rclcpp
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
Expand Down
1 change: 1 addition & 0 deletions turtlesim/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<depend>ament_index_cpp</depend>
<depend>geometry_msgs</depend>
<depend>rcl_interfaces</depend>
<depend>rclcpp</depend>
<depend>rclcpp_action</depend>
<depend>std_msgs</depend>
Expand Down
16 changes: 14 additions & 2 deletions turtlesim/src/turtle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,23 @@

#include "turtlesim/turtle.hpp"

#include <math.h>

#include <QColor>
#include <QRgb>

#include <cmath>
#include <functional>
#include <string>

#include "geometry_msgs/msg/twist.hpp"
#include "rclcpp/rclcpp.hpp"

#include "turtlesim/action/rotate_absolute.hpp"
#include "turtlesim/msg/pose.hpp"
#include "turtlesim/msg/color.hpp"
#include "turtlesim/srv/set_pen.hpp"
#include "turtlesim/srv/teleport_absolute.hpp"
#include "turtlesim/srv/teleport_relative.hpp"

#define DEFAULT_PEN_R 0xb3
#define DEFAULT_PEN_G 0xb8
#define DEFAULT_PEN_B 0xff
Expand Down
11 changes: 11 additions & 0 deletions turtlesim/src/turtle_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@

#include <cstdlib>
#include <ctime>
#include <functional>
#include <string>

#include "rcl_interfaces/msg/integer_range.hpp"
#include "rcl_interfaces/msg/parameter_descriptor.hpp"
#include "rcl_interfaces/msg/parameter_event.hpp"
#include "rclcpp/rclcpp.hpp"
#include "std_srvs/srv/empty.hpp"

#include "turtlesim/srv/kill.hpp"
#include "turtlesim/srv/spawn.hpp"

#define DEFAULT_BG_R 0x45
#define DEFAULT_BG_G 0x56
Expand Down

0 comments on commit 1cf5178

Please sign in to comment.