[BUG]: CMake FindPython issues on CMake>3.23, and Python linking issue in debug mode #5467
Open
2 of 3 tasks
Labels
triage
New bug, unverified
Required prerequisites
What version (or hash if on master) of pybind11 are you using?
2.13.6
Problem description
Setting:
cmake_minimum_required(VERSION 3.23...3.29)
add_subdirectory("3rdparty/pybind11")
cmake_minimum_required
from 3.10 to 3.23...3.29. As far as I understand, this will have changed CMake's behaviour from using its old FindPython logic to the new FindPython logic.Settings/Issues:
Release mode compilation and
set(PYBIND11_FINDPYTHON ON)
No issues: CMake runs. Compilation works, linking works.
Release mode compilation and
set(PYBIND11_FINDPYTHON OFF)
andfind_package(Python 3.12 COMPONENTS Interpreter Development REQUIRED)
CMake error:
Could not find a package configuration file provided by "PythonInterp" (requested version 3.7) with any of the following names: PythonInterpConfig.cmake pythoninterp-config.cmake
. As far as I could find out, "PythonInterp" is the old deprecated CMake FindPython module, and it shouldn't ever be called in this case. I've investigated this using VS's CMake debugger and inpybind11Common.cmake
line 228 it's using the "else()" with the "Classic mode" and callspybind11Tools.cmake
, which in turn on L50 callsfind_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED ${_pybind11_quiet})
, which in turn callsFindPythonLibsNew.cmake
, which on L114 callsfind_package(PythonInterp ${PythonLibsNew_FIND_VERSION} ${_pythonlibs_required} ${_pythonlibs_quiet})
with 3.7 as version, and this call obviously fails. I don't understand why pybind11's CMake scripts are taking this route, first, since I'm using a recent CMake version and policies, and second, why would it try and find Python at all, if I've gotPYBIND11_FINDPYTHON OFF
and my ownfind_package(Python...)
call has already found 3.12. Yes, I've cleared the CMake cache / build folder.Debug mode compilation and
set(PYBIND11_FINDPYTHON OFF)
andfind_package(Python 3.12 COMPONENTS Interpreter Development REQUIRED)
Same issues as above with PythonInterp
Debug mode compilation and
set(PYBIND11_FINDPYTHON ON)
CMake runs. Compilation works. Linker produces an error:
out\build\x64-debug\LINK : fatal error LNK1104: cannot open file 'python312.lib'
. This is the full linker command-line:So this is really weird. On the linker command-line it shows it's linking to
python312_d.lib
, andpython312.lib
isn't even part of the linker command-line call. Why would it complain that it can't find a file that is not part of its commandline-arguments anyway? Also: In myC:\Users\PatrikHuber\AppData\Local\Programs\Python\Python312\libs
folder, I do have bothpython312.lib
andpython312_d.lib
. So if it was needed, it should find it there. I think something odd is going on here.Reproducible example code
See above.
For the full code, it's the
devel
branch of my library here https://github.com/patrikhuber/eos/tree/devel. It's self-contained and builds with vcpkg plus the rest of the dependencies from submodules (git submodule update --init --recursive
).Is this a regression? Put the last known working version here if it is.
Not a regression
The text was updated successfully, but these errors were encountered: