pybind / pybind/pybind11

[BUG]: Unknown CMake command "python_add_library" in pybind11NewTools.cmake

Open
#5,472 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triage
Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

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

2.9.1, master

Problem description

Using the new FindPython mode but the old pybind11_add_module, I get the following error:

Errors     << py_binding_tools:cmake /homes/rhaschke/src/ros/logs/py_binding_tools/build.cmake.000.log                                                                                                                                                                         
CMake Error at /usr/lib/cmake/pybind11/pybind11NewTools.cmake:205 (python_add_library):
  Unknown CMake command "python_add_library".
Call Stack (most recent call first):
  /opt/ros/one/share/pybind11_catkin/cmake/pybind11_catkin.cmake:27 (pybind11_add_module)
  CMakeLists.txt:44 (pybind_add_module)

The cmake function python_add_library was renamed to Python_add_library and I think, the corresponding calls in pybind11NewTools.cmake should be adapted accordingly:
https://github.com/pybind/pybind11/blob/741d86f2e3527b667ba85d273a5eea19a0978ef5/tools/pybind11NewTools.cmake#L262
However, I'm surprised that I am the first running into that issue. Maybe I'm missing something else?

Reproducible example code
find_package(Python 3 REQUIRED)
find_package(pybind11 REQUIRED)
pybind11_add_module(py_binding_tools_module src/py_binding_tools.cpp)
Is this a regression? Put the last known working version here if it is.

Not a regression

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect tools/pybind11NewTools.cmake around the python_add_library call, then compare it with the FindPython command documented in the issue. Reproduce the failure with the provided find_package and pybind11_add_module example; done means the example configures successfully without the unknown-command error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, python
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.