From ddb8b67a8aa8198ec8a028fb28f6870e44e7a467 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 21 Mar 2024 03:23:57 -0400 Subject: [PATCH] fix(cmake): allow forcing old FindPython (#5042) --- tools/pybind11Common.cmake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/pybind11Common.cmake b/tools/pybind11Common.cmake index 50b15e11b..57721aeb1 100644 --- a/tools/pybind11Common.cmake +++ b/tools/pybind11Common.cmake @@ -173,12 +173,16 @@ endif() # Check to see which Python mode we are in, new, old, or no python if(PYBIND11_NOPYTHON) set(_pybind11_nopython ON) + # We won't use new FindPython if PYBIND11_FINDPYTHON is defined and falselike + # Otherwise, we use if FindPythonLibs is missing or if FindPython was already used elseif( - _pybind11_missing_old_python STREQUAL "NEW" - OR PYBIND11_FINDPYTHON - OR Python_FOUND - OR Python2_FOUND - OR Python3_FOUND) + (NOT DEFINED PYBIND11_FINDPYTHON OR PYBIND11_FINDPYTHON) + AND (_pybind11_missing_old_python STREQUAL "NEW" + OR PYBIND11_FINDPYTHON + OR Python_FOUND + OR Python3_FOUND + )) + # New mode include("${CMAKE_CURRENT_LIST_DIR}/pybind11NewTools.cmake")