ros2 / launch

Tools for launching multiple processes and for writing tests involving multiple processes.
Apache License 2.0
125 stars 139 forks source link

Can't include [launch_testing_ament_cmake] in a launch only package #748

Closed outrider-jhulas closed 9 months ago

outrider-jhulas commented 9 months ago

Bug report

Required Info:

Steps to reproduce issue

I have simple launch package which consists of a CMakeLists.txt, package.xml and a launch folder with a python launch file. I would like to add a launch test to the repo so I add <test_depend>launch_testing_ament_cmake</test_depend> to the package.xml.

Then when building with colcon build I get the following error:

CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
  (Required is at least version "3.5")
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.22/Modules/FindPythonLibs.cmake:310 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  /opt/ros/humble/share/python_cmake_module/cmake/Modules/FindPythonExtra.cmake:140 (find_package)
  /opt/ros/humble/share/launch_testing_ament_cmake/cmake/launch_testing_ament_cmake-extras.cmake:18 (find_package)
  /opt/ros/humble/share/launch_testing_ament_cmake/cmake/launch_testing_ament_cmakeConfig.cmake:41 (include)
  /opt/ros/humble/share/ament_lint_auto/cmake/ament_lint_auto_find_test_dependencies.cmake:36 (find_package)
  CMakeLists.txt:21 (ament_lint_auto_find_test_dependencies)

The contents of package.xml:

  <buildtool_depend>ament_cmake_auto</buildtool_depend>

  <exec_depend>other_pkg</exec_depend>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>
  <test_depend>launch_testing_ament_cmake</test_depend>

CMakeLists.txt:

cmake_minimum_required(VERSION 3.8)
project(test_pkg NONE)

# Explicitly ignore unused CMAKE_EXPORT_COMPILE_COMMANDS warning
set(ignore "${CMAKE_EXPORT_COMPILE_COMMANDS}")

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)

  ament_lint_auto_find_test_dependencies() # Error comes from here
  ament_auto_find_test_dependencies()

  # TODO: add_launch_test() 
endif()

ament_auto_package(INSTALL_TO_SHARE
  launch
)

Expected behavior

I would like to add_launch_test() to the CMakeLists and then add the actual test.

Actual behavior

The python error shown. Same error occurs when doing a find_package(launch_testing_ament_cmake REQUIRED) instead of the ament_auto_find_test_dependencies()

Additional information

This package doesn't contain any other code. I have launch_testing properly installed because other packages in the same workspace use it without any issue.

ros2 humble

outrider-jhulas commented 9 months ago

The issue was NONE in project(test_pkg NONE)