fix: add flag for overriding classic Python search values (#4195)

* fix: PyPy needs to overrite broken FindPythonInterp values

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* fix: add flag to opt-in to new (cross-compile) behavior

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Apply suggestions from code review

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
Henry Schreiner 2022-10-23 00:32:17 -04:00 committed by Henry Schreiner
parent ce63bcb980
commit 0e82c36094

View File

@ -151,9 +151,13 @@ if(NOT _PYTHON_SUCCESS MATCHES 0)
return()
endif()
option(
PYBIND11_PYTHONLIBS_OVERWRITE
"Overwrite cached values read from Python library (classic search). Turn off if cross-compiling and manually setting these values."
ON)
# Can manually set values when cross-compiling
macro(_PYBIND11_GET_IF_UNDEF lst index name)
if(NOT DEFINED "${name}")
if(PYBIND11_PYTHONLIBS_OVERWRITE OR NOT DEFINED "${name}")
list(GET "${lst}" "${index}" "${name}")
endif()
endmacro()