Skip to content

Commit c87aa57

Browse files
Update Pluginlib.rst (ros2#5894)
Signed-off-by: Christoph Fröhlich <[email protected]>
1 parent 01ec8ed commit c87aa57

File tree

1 file changed

+20
-32
lines changed

1 file changed

+20
-32
lines changed

source/Tutorials/Beginner-Client-Libraries/Pluginlib.rst

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -73,43 +73,17 @@ The code above creates an abstract class called ``RegularPolygon``.
7373
One thing to notice is the presence of the initialize method.
7474
With ``pluginlib``, a constructor without parameters is required, so if any parameters to the class are needed, we use the initialize method to pass them to the object.
7575

76-
We need to make this header available to other classes, so open ``~/ros2_ws/src/polygon_base/CMakeLists.txt`` for editing.
77-
Add the following lines after the ``target_link_libraries`` command:
78-
79-
.. code-block:: cmake
80-
81-
install(
82-
DIRECTORY include/
83-
DESTINATION include
84-
)
85-
86-
And add this command before the ``ament_package`` command:
87-
88-
.. code-block:: cmake
89-
90-
# Export old-style CMake variables
91-
ament_export_include_directories(
92-
include
93-
)
94-
ament_export_libraries(
95-
${PROJECT_NAME}
96-
)
97-
98-
# Export modern CMake targets
99-
ament_export_targets(
100-
export_${PROJECT_NAME}
101-
)
102-
103-
We need to make this library available to other packages, so open ``~/ros2_ws/src/polygon_base/CMakeLists.txt`` for editing.
104-
Add the following lines after the ``find_package(pluginlib REQUIRED)`` command:
76+
We need to make this header available to other classes by exporting it as an interface library.
77+
To do so, open ``~/ros2_ws/src/polygon_base/CMakeLists.txt`` for editing
78+
and add the following lines after the ``find_package(pluginlib REQUIRED)`` command:
10579

10680
.. code-block:: cmake
10781
10882
# Library (this will be used as the base class for plugins)
109-
add_library(${PROJECT_NAME} SHARED src/area_node.cpp)
83+
add_library(${PROJECT_NAME} INTERFACE)
11084
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
111-
target_compile_features(${PROJECT_NAME} PUBLIC c_std_99 cxx_std_17)
112-
target_include_directories(${PROJECT_NAME} PUBLIC
85+
target_compile_features(${PROJECT_NAME} INTERFACE c_std_99 cxx_std_17)
86+
target_include_directories(${PROJECT_NAME} INTERFACE
11387
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
11488
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
11589
)
@@ -132,6 +106,20 @@ Add the following lines after the ``find_package(pluginlib REQUIRED)`` command:
132106
DESTINATION share/${PROJECT_NAME}/cmake
133107
)
134108
109+
And add this commands before the ``ament_package`` command:
110+
111+
.. code-block:: cmake
112+
113+
# Export old-style CMake variables
114+
ament_export_include_directories(
115+
include
116+
)
117+
118+
# Export modern CMake targets
119+
ament_export_targets(
120+
export_${PROJECT_NAME}
121+
)
122+
135123
We will return to this package later to write our test node.
136124

137125
2 Create the Plugin Package

0 commit comments

Comments
 (0)