[BUG]: Python_ADD_LIBRARY: target Python::Module not defined
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with pybind11NewTools.cmake around line 283 and trace its python_add_library call alongside CMake's FindPython.cmake and the reported FindPython/Support.cmake error. Reproduce the ordering of find_package(Python COMPONENTS Interpreter) and find_package(pybind11), then verify that the required Python target is available without depending on the upstream package's call order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp, python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100