@@ -95,24 +95,9 @@ if(NOT PythonLibsNew_FIND_VERSION)
9595 set (PythonLibsNew_FIND_VERSION "3.6" )
9696endif ()
9797
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-
10998find_package (PythonInterp ${PythonLibsNew_FIND_VERSION} ${_pythonlibs_required}
11099 ${_pythonlibs_quiet} )
111100
112- unset (PYTHON_INCLUDE_DIR)
113- unset (PYTHON_MODULE_EXTENSION)
114- unset (PYTHON_IS_DEBUG)
115-
116101if (NOT PYTHONINTERP_FOUND)
117102 set (PYTHONLIBS_FOUND FALSE )
118103 set (PythonLibsNew_FOUND FALSE )
@@ -166,11 +151,13 @@ if(NOT _PYTHON_SUCCESS MATCHES 0)
166151 return ()
167152endif ()
168153
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 )
169158# Can manually set values when cross-compiling
170159macro (_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} " )
174161 list (GET "${lst} " "${index} " "${name} " )
175162 endif ()
176163endmacro ()
0 commit comments