pybind11
pybind11 copied to clipboard
[BUG]: Pybind11Tools.cmake not finding Python AND pybind11_add_module creates only executables
Required prerequisites
- [X] Make sure you've read the documentation. Your issue may be addressed there.
- [X] Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- [ ] Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
2.14.0 dev1
Problem description
find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED ${_pybind11_quiet})
Doesn't seem to work in the latest CMAKE.
It should be find_package(Python3 ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED ${_pybind11_quiet})
Otherwise it gives the error:
-- pybind11 v2.14.0 dev1
CMake Error at pybind11/tools/FindPythonLibsNew.cmake:265 (message):
Python libraries not found
Call Stack (most recent call first):
pybind11/tools/pybind11Tools.cmake:44 (find_package)
pybind11/tools/pybind11Common.cmake:200 (include)
pybind11/CMakeLists.txt:229 (include)
pybind11_add_module will also generate project_name.exe even though you specified SHARED as the argument.
Reproducible example code
add_subdirectory(pybind11)
IF(WIN32)
# pybind11_add_module is broken on windows. Only generates EXE and never .dll even if SHARED is specified
# Otherwise it works on all other platforms!
add_library(${PROJECT_NAME} SHARED ${SRC_LIST})
ELSE()
pybind11_add_module(${PROJECT_NAME} SHARED ${SRC_LIST})
ENDIF()
### Is this a regression? Put the last known working version here if it is.
Not a regression