Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Pybind11Tools.cmake not finding Python AND pybind11_add_module creates only executables #5382

Open
2 of 3 tasks
Brandon-T opened this issue Sep 20, 2024 · 0 comments
Open
2 of 3 tasks
Labels
triage New bug, unverified

Comments

@Brandon-T
Copy link

Required prerequisites

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
@Brandon-T Brandon-T added the triage New bug, unverified label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage New bug, unverified
Projects
None yet
Development

No branches or pull requests

1 participant