Skip to content

[BUG]: CMake add_subdirectory() interference from system-installed pybind11 #5937

@mheistermann

Description

@mheistermann

Required prerequisites

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

d4f9cfb

Problem description

When using pybind11 with add_subdirectory, pybind
sets pybind11_system to SYSTEM and then
uses this to pass SYSTEM to target_include_directories().

When this is combined with the parent project adding some global include folder like /usr/include or /opt/homebrew/include as a "normal" include directory, and a version of pybind11 is installed, that folder will take precedence over pybind11's own include folder (cf. CMake target_include_directories doc)

The result are strange compile errors in the best case.

I'd be happy to create a PR that either removes the SYSTEM argument or adds a CMake configuration option to disable it. Currently I am relying on an ugly workaround in our project.

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