mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 06:49:25 +00:00
feat: FindPython by default (#5553)
* feat: FindPython by default Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Update tools/pybind11Config.cmake.in --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
@@ -192,7 +192,25 @@ elseif(
|
||||
))
|
||||
|
||||
# New mode
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/pybind11NewTools.cmake")
|
||||
if(Python_FOUND OR Python3_FOUND)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/pybind11NewTools.cmake")
|
||||
else()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/pybind11NewTools.cmake")
|
||||
|
||||
message(
|
||||
"Using compatibility mode for Python, set PYBIND11_FINDPYTHON to NEW/OLD to silence this message"
|
||||
)
|
||||
set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}")
|
||||
set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIR}")
|
||||
set(Python_INCLUDE_DIRS "${Python_INCLUDE_DIRS}")
|
||||
set(PYTHON_LIBRARY "${Python_LIRARY}")
|
||||
set(PYTHON_LIBRARIES "${Python_LIRARIES}")
|
||||
set(PYTHON_VERSION "${Python_VERSION}")
|
||||
set(PYTHON_VERSION_STRING "${Python_VERSION_STRING}")
|
||||
set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}")
|
||||
set(PYTHON_VERSION_MINOR "${Python_VERSION_MINOR}")
|
||||
set(PYTHON_VERSION_PATCH "${Python_VERSION_PATCH}")
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
|
||||
@@ -67,6 +67,13 @@ from 3.12+ forward (3.15+ _highly_ recommended). If you set the minimum or
|
||||
maximum version of CMake to 3.27+, then FindPython is the default (since
|
||||
FindPythonInterp/FindPythonLibs has been removed via policy `CMP0148`).
|
||||
|
||||
Starting in pybind11 3.0, the new mode is the default, but we provide backward
|
||||
compatible names (`PYTHON_*` vs. the new `Python_* names). Set the mode
|
||||
explicitly to avoid the compatibility defines. You can specify this mode
|
||||
explicitly by setting `PYBIND11_FINDPYTHON` to `COMPAT`, but if you are changing
|
||||
your CMakeLists anyway, please just use the `ON` mode. A future release may
|
||||
default to `ON`.
|
||||
|
||||
New FindPython mode
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
Reference in New Issue
Block a user