fix(cmake): skip empty PYBIND11_PYTHON_EXECUTABLE_LAST for the first cmake run (#4856)

* fix(cmake): skip empty PYBIND11_PYTHON_EXECUTABLE_LAST for the first cmake run

* style: pre-commit fixes

* Update pybind11NewTools.cmake

* style: pre-commit fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
This commit is contained in:
Ilya Lavrenov 2024-01-08 17:40:41 +04:00 committed by GitHub
parent f29def9ea4
commit aec6cc5406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,14 +110,16 @@ if(NOT DEFINED ${_Python}_EXECUTABLE)
endif() endif()
if(NOT ${_Python}_EXECUTABLE STREQUAL PYBIND11_PYTHON_EXECUTABLE_LAST) if(DEFINED PYBIND11_PYTHON_EXECUTABLE_LAST AND NOT ${_Python}_EXECUTABLE STREQUAL
PYBIND11_PYTHON_EXECUTABLE_LAST)
# Detect changes to the Python version/binary in subsequent CMake runs, and refresh config if needed # Detect changes to the Python version/binary in subsequent CMake runs, and refresh config if needed
unset(PYTHON_IS_DEBUG CACHE) unset(PYTHON_IS_DEBUG CACHE)
unset(PYTHON_MODULE_EXTENSION CACHE) unset(PYTHON_MODULE_EXTENSION CACHE)
set(PYBIND11_PYTHON_EXECUTABLE_LAST endif()
set(PYBIND11_PYTHON_EXECUTABLE_LAST
"${${_Python}_EXECUTABLE}" "${${_Python}_EXECUTABLE}"
CACHE INTERNAL "Python executable during the last CMake run") CACHE INTERNAL "Python executable during the last CMake run")
endif()
if(NOT DEFINED PYTHON_IS_DEBUG) if(NOT DEFINED PYTHON_IS_DEBUG)
# Debug check - see https://stackoverflow.com/questions/646518/python-how-to-detect-debug-Interpreter # Debug check - see https://stackoverflow.com/questions/646518/python-how-to-detect-debug-Interpreter