Skip to content

[BUG] regression when mixing installed pybind11 with local copy #2709

Closed
@henryiii

Description

@henryiii

Issue description

Hi all, since the recent refactor of CMake files (pull request #2370), when setting up include paths, pybind11_add_module puts priority on the already installed version of pybind11 (PYTHON_INCLUDE_DIRS) instead of the local copy (pybind11_INCLUDE_DIR). As an effect, wrong header files are included.

I understand that the documentation of pybind11_add_module says that pybind11 must be properly installed for it to work, but this nevertheless looks like a bug -- why add pybind11_INCLUDE_DIR if you expect it to be ignored?

Any idea how to get the old behavior? I found a hacky solution by modifying pybind11_add_module to do

target_link_libraries(${target_name} PRIVATE pybind11::headers pybind11::module)

instead of

target_link_libraries(${target_name} PRIVATE pybind11::module)

but I hope to find something better. Thanks!

From @ikicic on Gitter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions