File tree 2 files changed +21
-3
lines changed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -127,10 +127,20 @@ endif()
127
127
# Check on every access - since Python2 and Python3 could have been used - do nothing in that case.
128
128
129
129
if (DEFINED ${_Python} _INCLUDE_DIRS)
130
+ # Only add Python for build - must be added during the import for config
131
+ # since it has to be re-discovered.
132
+ #
133
+ # This needs to be a target to be included after the local pybind11
134
+ # directory, just in case there there is an installed pybind11 sitting
135
+ # next to Python's includes. It also ensures Python is a SYSTEM library.
136
+ add_library (pybind11::python_headers INTERFACE IMPORTED )
137
+ set_property (
138
+ TARGET pybind11::python_headers PROPERTY INTERFACE_INCLUDE_DIRECTORIES
139
+ "$<BUILD_INTERFACE:${${_Python} _INCLUDE_DIRS}>" )
130
140
set_property (
131
141
TARGET pybind11::pybind11
132
142
APPEND
133
- PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${ ${_Python} _INCLUDE_DIRS}> )
143
+ PROPERTY INTERFACE_LINK_LIBRARIES pybind11::python_headers )
134
144
set (pybind11_INCLUDE_DIRS
135
145
"${pybind11_INCLUDE_DIR} " "${${_Python} _INCLUDE_DIRS}"
136
146
CACHE INTERNAL "Directories where pybind11 and possibly Python headers are located" )
Original file line number Diff line number Diff line change @@ -81,11 +81,19 @@ if(PYBIND11_MASTER_PROJECT)
81
81
endif ()
82
82
endif ()
83
83
84
- # Only add Python for build - must be added during the import for config since it has to be re-discovered.
84
+ # Only add Python for build - must be added during the import for config since
85
+ # it has to be re-discovered.
86
+ #
87
+ # This needs to be an target to it is included after the local pybind11
88
+ # directory, just in case there are multiple versions of pybind11, we want the
89
+ # one we expect.
90
+ add_library (pybind11::python_headers INTERFACE IMPORTED )
91
+ set_property (TARGET pybind11::python_headers PROPERTY INTERFACE_INCLUDE_DIRECTORIES
92
+ "$<BUILD_INTERFACE:${PYTHON_INCLUDE_DIRS} >" )
85
93
set_property (
86
94
TARGET pybind11::pybind11
87
95
APPEND
88
- PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE: ${PYTHON_INCLUDE_DIRS} > )
96
+ PROPERTY INTERFACE_LINK_LIBRARIES pybind11::python_headers )
89
97
90
98
set (pybind11_INCLUDE_DIRS
91
99
"${pybind11_INCLUDE_DIR} " "${PYTHON_INCLUDE_DIRS} "
You can’t perform that action at this time.
0 commit comments