Skip to content

[BUG]: Python_ADD_LIBRARY: target Python::Module not defined #5813

@rhaschke

Description

@rhaschke

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

3.0.0

Problem description

When using find_package(Python COMPONENTS Interpreter) before using find_package(pybind11), I get the following error:

CMake Error at /usr/share/cmake-3.28/Modules/FindPython/Support.cmake:4064 (message):
  Python_ADD_LIBRARY: dependent target 'Python::Module' is not defined.

     Did you miss to request COMPONENT 'Development.Module'?
Call Stack (most recent call first):
  /usr/share/cmake-3.28/Modules/FindPython.cmake:635 (__Python_add_library)
  /opt/ros/one/share/pybind11_catkin/cmake/pybind11NewTools.cmake:283 (python_add_library)

Obviously, the first call to find_package(Python) should include the Development component.
However, I don't have control about this find_package call as it occurs in another upstream software package.
IMHO, pybind11 needs to ensure itself that all required components are find_packaged.

This issue is related to #3996, which identified an order dependency of find_package calls too.

Reproducible example code


Is this a regression? Put the last known working version here if it is.

Not a regression

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew bug, unverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions