You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: CMake add_subdirectory() interference from system-installed pybind11 #5937
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 reproduced this with CMake 3.29 and MinGW on Windows. A parent-level include directory for another pybind11 installation is searched before the add_subdirectory copy because the latter is classified as SYSTEM.
I put together a small local fix and regression test: an opt-out keeps the current default behavior but lets pybind11_add_module() prefer its source headers when this collision occurs. The test uses a conflicting fake header and passes locally.
Are you currently working on a PR? If not, I’d be happy to open one.
Activity
JOINKINGER commentedon Sep 3, 2026
I reproduced this with CMake 3.29 and MinGW on Windows. A parent-level include directory for another pybind11 installation is searched before the
add_subdirectorycopy because the latter is classified asSYSTEM.I put together a small local fix and regression test: an opt-out keeps the current default behavior but lets
pybind11_add_module()prefer its source headers when this collision occurs. The test uses a conflicting fake header and passes locally.Are you currently working on a PR? If not, I’d be happy to open one.