这个错误是由于在 CMakeLists.txt 文件中使用了一个未知的 CMake 命令 'pybind11_add_module',并且 CMake 在指定的目录中找不到 CMakeLists.txt 文件。

根据错误信息,看起来你正在尝试使用 pybind11 库来构建一个 Python 绑定的模块,但是 CMake 无法找到 pybind11 库或者你没有正确地配置 pybind11 的路径。

要解决这个问题,你可以按照以下步骤进行操作:

  1. 确保你已经正确地安装了 pybind11 库。你可以通过以下方式之一来安装 pybind11:

    • 使用包管理器(如 pip)安装 pybind11:pip install pybind11
    • 从 pybind11 的 GitHub 仓库手动构建和安装:https://github.com/pybind/pybind11
  2. 确保你已经正确地设置了 pybind11 库的路径。可以在 CMakeLists.txt 文件中使用 find_package 命令来查找和配置 pybind11 库的路径。例如:

    find_package(pybind11 REQUIRED)
    
  3. 确保你在 CMakeLists.txt 文件中正确地使用了 pybind11 的相关命令。'pybind11_add_module' 是 pybind11 库提供的一个 CMake 扩展命令,用于创建 Python 绑定的模块。确保你在 CMakeLists.txt 文件中正确地使用了该命令。例如:

    pybind11_add_module(your_module_name your_module_sources.cpp)
    
  4. 确保你在 CMakeLists.txt 文件中正确地指定了子目录的路径。根据错误信息,CMake 无法在指定的目录中找到 CMakeLists.txt 文件。确保你在 add_subdirectory 命令中正确地指定了子目录的路径。例如:

    add_subdirectory(extern/pybind11)
    

请根据你的实际情况进行相应的调整和修复。确保你已经正确地安装了 pybind11 库,并在 CMakeLists.txt 文件中正确地配置了 pybind11 的路径和使用了正确的命令。

CMake 错误:  找不到 pybind11 库或配置错误

原文地址: https://www.cveoy.top/t/topic/0nz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录