@@ -46,19 +46,19 @@ else()
4646 message (STATUS "Found xtensor: ${xtensor_INCLUDE_DIRS} /xtensor" )
4747endif ()
4848
49- # Running find_package(PythonInterp) to retrieve the Python version
50- # which is not exported by Pybind11's cmake.
51- # Cf. https://github.com/pybind/pybind11/issues/2268
52- find_package (PythonInterp ${PythonLibsNew_FIND_VERSION} REQUIRED)
49+ find_package (Python COMPONENTS Interpreter REQUIRED)
5350
5451set (pybind11_REQUIRED_VERSION 2.6.1)
55- if ( TARGET pybind11 OR TARGET pybind11::headers)
56- # pybind11 has a variable that indicates its version already, so use that
57- message ( STATUS "Found pybind11 v ${pybind11_VERSION} " )
58- else ( )
52+ if ( NOT TARGET pybind11::headers)
53+ # Defaults to ON for cmake >= 3.18
54+ # https://github.com/pybind/ pybind11/blob/35ff42b56e9d34d9a944266eb25f2c899dbdfed7/CMakeLists.txt#L96
55+ set (PYBIND11_FINDPYTHON OFF )
5956 find_package (pybind11 ${pybind11_REQUIRED_VERSION} REQUIRED)
6057 message (STATUS "Found pybind11: ${pybind11_INCLUDE_DIRS} /pybind11" )
61- endif ()
58+ else ()
59+ # pybind11 has a variable that indicates its version already, so use that
60+ message (STATUS "Found pybind11 v${pybind11_VERSION} " )
61+ endif ()
6262
6363# Look for NumPy headers, except if NUMPY_INCLUDE_DIRS is passed,
6464# which is required under some circumstances (such as wasm, where
0 commit comments