Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
Signed-off-by: Shane Loretz <shane.loretz@gmail.com>
  • Loading branch information
sloretz committed Sep 29, 2024
1 parent c31a35e commit 81944b0
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -844,24 +844,25 @@ Add a call to ``ament_package()`` at the bottom of the ``CMakeLists.txt``.
ament_package()
Use ``target_link_libraries`` to make the ``talker`` target depend on the modern CMake targets provided by ``rclcpp`` and ``std_msgs``.

.. code-block:: cmake
target_link_libraries(talker PUBLIC
rclcpp::rclcpp
${std_msgs_TARGETS})
Delete the call to ``include_directories()``.
Replace it with a call to ``target_include_directories()`` for your package's ``include`` directory.
Don't add other package's ``*_INCLUDE_DIRS`` variables, those will be handled by depending on modern CMake targets.
Don't pass variables like ``rclcpp_INCLUDE_DIRS`` into ``target_include_directories()``.
The include directories were already handled by calling ``target_link_libraries()`` with modern CMake targets.

.. code-block:: cmake
target_include_directories(target PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
Use ``target_link_libraries`` to make the ``talker`` target depend on the modern CMake targets provided by ``rclcpp`` and ``std_msgs``.

.. code-block:: cmake
target_link_libraries(talker PUBLIC
rclcpp::rclcpp
${std_msgs_TARGETS})
Install the ``talker`` executable into a project specific directory so that it is discoverable by tools like ``ros2 run``.

.. code-block:: cmake
Expand Down

0 comments on commit 81944b0

Please sign in to comment.