Skip to content

Commit aec6cc5

Browse files
ilya-lavrenovpre-commit-ci[bot]henryiii
authored
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 <[email protected]>
1 parent f29def9 commit aec6cc5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tools/pybind11NewTools.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,17 @@ if(NOT DEFINED ${_Python}_EXECUTABLE)
110110

111111
endif()
112112

113-
if(NOT ${_Python}_EXECUTABLE STREQUAL PYBIND11_PYTHON_EXECUTABLE_LAST)
113+
if(DEFINED PYBIND11_PYTHON_EXECUTABLE_LAST AND NOT ${_Python}_EXECUTABLE STREQUAL
114+
PYBIND11_PYTHON_EXECUTABLE_LAST)
114115
# Detect changes to the Python version/binary in subsequent CMake runs, and refresh config if needed
115116
unset(PYTHON_IS_DEBUG CACHE)
116117
unset(PYTHON_MODULE_EXTENSION CACHE)
117-
set(PYBIND11_PYTHON_EXECUTABLE_LAST
118-
"${${_Python}_EXECUTABLE}"
119-
CACHE INTERNAL "Python executable during the last CMake run")
120118
endif()
121119

120+
set(PYBIND11_PYTHON_EXECUTABLE_LAST
121+
"${${_Python}_EXECUTABLE}"
122+
CACHE INTERNAL "Python executable during the last CMake run")
123+
122124
if(NOT DEFINED PYTHON_IS_DEBUG)
123125
# Debug check - see https://stackoverflow.com/questions/646518/python-how-to-detect-debug-Interpreter
124126
execute_process(

0 commit comments

Comments
 (0)