ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In my case I wanted to reuse "test_helpers" file of package A in another package B. I resided to the following setup:

  1. packageA/CMakeLists.txt: ament_package(CONFIG_EXTRAS cmake/extra.cmake.in)

  2. packageA/cmake/extra.cmake: get_filename_component(@PROJECT_NAME@_TEST_DIR @PROJECT_SOURCE_DIR@/test ABSOLUTE)

  3. packageB/CMakeLists.txt: find_package(packageA), include_directories(${packageA_TEST_DIR})

  4. Then just use the file that's under the test dir in your cpp/hpp files of package B: include "filename-relative to *_TEST_DIR"

In my case I wanted to reuse "test_helpers" a unittests-related file of package A in another package B. I resided to the following setup:

  1. packageA/CMakeLists.txt: ament_package(CONFIG_EXTRAS cmake/extra.cmake.in)

  2. packageA/cmake/extra.cmake: get_filename_component(@PROJECT_NAME@_TEST_DIR @PROJECT_SOURCE_DIR@/test ABSOLUTE)

  3. packageB/CMakeLists.txt: find_package(packageA), include_directories(${packageA_TEST_DIR})

  4. Then just use the file that's under the test dir in your cpp/hpp files of package B: include "filename-relative to *_TEST_DIR"

In my case I wanted to reuse a unittests-related file of package A in another package B. I resided to the following setup:

  1. packageA/CMakeLists.txt: ament_package(CONFIG_EXTRAS cmake/extra.cmake.in)

  2. packageA/cmake/extra.cmake: get_filename_component(@PROJECT_NAME@_TEST_DIR @PROJECT_SOURCE_DIR@/test ABSOLUTE)

  3. packageB/CMakeLists.txt: find_package(packageA), include_directories(${packageA_TEST_DIR})

  4. Then just use the file that's under the test dir in your cpp/hpp files of package B: include #include "filename-relative to *_TEST_DIR"