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
What version (or hash if on master) of pybind11 are you using?
2.13.6
Problem description
pybind11Common.cmake defines a set of imported targets pybind11::pybind11 etc, They are guarded behind a global include guard. But the defined targets only have directory scope. Hence if one runs find_package(pybind11) from different subdirectories, the first one will run and pybind11Common.cmake and define the targets, the second one will bail at the global include guard, but the targets are not available since they where defined in a different directory and are not global.
This will need to an hard error, since the needed targets are now missing in the second subdirectory.
Changing the guard to "DIRECTORY" solves the issues. But one might still run into issues if one subdirectory would promote one or more targets to global scope. Generally I think each targets should be guarded by a if(NOT TARGET ..)That seems safer to me. Generally I would prefer of handle it more in line with how the autogenerated pybind11Targets.cmake handle it.
Basically it has a list of all the expected targets, and checks if all are defined, then it can return early, or if none is defined, then it can add them. Everything else is a fatal error.
Required prerequisites
What version (or hash if on master) of pybind11 are you using?
2.13.6
Problem description
pybind11Common.cmake defines a set of imported targets pybind11::pybind11 etc, They are guarded behind a global include guard. But the defined targets only have directory scope. Hence if one runs find_package(pybind11) from different subdirectories, the first one will run and pybind11Common.cmake and define the targets, the second one will bail at the global include guard, but the targets are not available since they where defined in a different directory and are not global.
This will need to an hard error, since the needed targets are now missing in the second subdirectory.
Changing the guard to "DIRECTORY" solves the issues. But one might still run into issues if one subdirectory would promote one or more targets to global scope. Generally I think each targets should be guarded by a
if(NOT TARGET ..)
That seems safer to me. Generally I would prefer of handle it more in line with how the autogenerated pybind11Targets.cmake handle it.Basically it has a list of all the expected targets, and checks if all are defined, then it can return early, or if none is defined, then it can add them. Everything else is a fatal error.
The relevant line,
pybind11/tools/pybind11Common.cmake
Line 21 in 7e418f4
which was introduced in a recent change. 28dbce4
Reproducible example code
No response
Is this a regression? Put the last known working version here if it is.
2.13.5
The text was updated successfully, but these errors were encountered: