@@ -95,24 +95,9 @@ if(NOT PythonLibsNew_FIND_VERSION)
95
95
set (PythonLibsNew_FIND_VERSION "3.6" )
96
96
endif ()
97
97
98
- # Save variables that get set by PythonInterp
99
- macro (_PYBIND11_PUSH_IF_DEFINED name )
100
- if (DEFINED "${name} " )
101
- set ("_PYBIND11_ORIG_${name} " "${${name} }" )
102
- endif ()
103
- endmacro ()
104
-
105
- _pybind11_push_if_defined(PYTHON_INCLUDE_DIR)
106
- _pybind11_push_if_defined(PYTHON_MODULE_EXTENSION)
107
- _pybind11_push_if_defined(PYTHON_IS_DEBUG)
108
-
109
98
find_package (PythonInterp ${PythonLibsNew_FIND_VERSION} ${_pythonlibs_required}
110
99
${_pythonlibs_quiet} )
111
100
112
- unset (PYTHON_INCLUDE_DIR)
113
- unset (PYTHON_MODULE_EXTENSION)
114
- unset (PYTHON_IS_DEBUG)
115
-
116
101
if (NOT PYTHONINTERP_FOUND)
117
102
set (PYTHONLIBS_FOUND FALSE )
118
103
set (PythonLibsNew_FOUND FALSE )
@@ -166,11 +151,13 @@ if(NOT _PYTHON_SUCCESS MATCHES 0)
166
151
return ()
167
152
endif ()
168
153
154
+ option (
155
+ PYBIND11_PYTHONLIBS_OVERRWRITE
156
+ "Overwrite cached values read from Python library (classic search). Turn off if cross-compiling and manually setting these values."
157
+ ON )
169
158
# Can manually set values when cross-compiling
170
159
macro (_PYBIND11_GET_IF_UNDEF lst index name )
171
- if (DEFINED "_PYBIND11_ORIG_${name} " )
172
- set ("${name} " "${_PYBIND11_ORIG_${name} }" )
173
- elseif (NOT DEFINED "${name} " )
160
+ if (PYBIND11_PYTHONLIBS_OVERRWRITE OR NOT DEFINED "${name} " )
174
161
list (GET "${lst} " "${index} " "${name} " )
175
162
endif ()
176
163
endmacro ()
0 commit comments