ros2_target_depends.cmake 1.1 KB

1234567891011121314151617181920212223242526
  1. # Copyright (c) Contributors to the Open 3D Engine Project.
  2. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  3. #
  4. # SPDX-License-Identifier: Apache-2.0 OR MIT
  5. function(target_depends_on_ros2_package TARGET_NAME)
  6. list(GET ARGN 0 _package)
  7. find_package(${ARGN})
  8. if (${${_package}_FOUND})
  9. include(${${_package}_DIR}/${_package}Config.cmake OPTIONAL)
  10. if (${${_package}_FOUND_AMENT_PACKAGE})
  11. message(DEBUG "Package ${_package} was found (${${_package}_DIR}) version ${${_package}_VERSION} targets : ${${_package}_TARGETS}")
  12. target_link_libraries(${TARGET_NAME} PUBLIC ${${_package}_TARGETS})
  13. else ()
  14. message(FATAL_ERROR "Package ${_package} was found (${${_package}_DIR}), but package is not an Ament package.")
  15. endif ()
  16. else ()
  17. message(DEBUG "Package ${_package} was not found.")
  18. endif ()
  19. endfunction()
  20. function(target_depends_on_ros2_packages TARGET_NAME)
  21. foreach (_package IN LISTS ARGN)
  22. target_depends_on_ros2_package(${TARGET_NAME} ${_package} REQUIRED)
  23. endforeach ()
  24. endfunction()