-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[package] pybind11/2.9.1: pybind11_add_module not found #9343
Comments
Also reported as in https://stackoverflow.com/questions/69781924/cmake-using-conan-pybind11-package |
Same issue here (MacOS with AppleClang, Python 3.7 from an Anaconda environment, and CMake 3.22.0). set(Python_FIND_VIRTUALENV FIRST)
find_package(Python REQUIRED COMPONENTS Interpreter Development) It correctly identifies the python interpreter and include directories I want it to use (again, python3 in the active conda environment). I can get it to compile & link by explicitly including the find_package(pybind11 CONFIG REQUIRED)
if(NOT COMMAND pybind11_add_module)
foreach(INCDIR IN LISTS pybind11_INCLUDE_DIRS)
if(EXISTS "${INCDIR}/../lib/cmake/pybind11/pybind11Tools.cmake")
include("${INCDIR}/../lib/cmake/pybind11/pybind11Common.cmake")
include("${INCDIR}/../lib/cmake/pybind11/pybind11Tools.cmake")
break()
elseif(EXISTS "${INCDIR}/../../lib/cmake/pybind11/pybind11Tools.cmake")
include("${INCDIR}/../../lib/cmake/pybind11/pybind11Common.cmake")
include("${INCDIR}/../../lib/cmake/pybind11/pybind11Tools.cmake")
break()
endif()
endforeach()
endif() Afterwards, modules can be created as usual by using Edit: If it helps, this occurs both for the |
Hello, I have exactly the same problem. I used the patch provided by @phillip-keldenich and it works great. It would be great to know how to properly use this recipe or to fix it altogether. Sadly I'm not "fluent enough" with conan to understand what's going on and to do a PR for that. BTW, @phillip-keldenich why do you need to have an elsif with an include of |
For me, there were two suitable include directories in pybind11_INCLUDE_DIRS (basically, a subdirectory and its parent). |
It seems that the official pybind11 package from conan doesn't expose all cmake files from pybind11. For instance I ended up using a custom conan package that works nicely with CMakeDeps and CMakeToolchain generators (that are the recommended way for conan 2.0): import os
from conans import ConanFile, tools, CMake
class PyBind11Conan(ConanFile):
name = "pybind11"
version = "2.9.2"
settings = "os", "compiler", "arch", "build_type"
description = "Seamless operability between C++11 and Python"
homepage = "https://github.com/pybind/pybind11"
license = "BSD Style: https://github.com/pybind/pybind11/blob/master/LICENSE"
url = "https://github.com/conan-community/conan-pybind11"
no_copy_sources = True
def source(self):
tools.get("%s/archive/v%s.tar.gz" % (self.homepage, self.version))
def build(self):
cmake = CMake(self)
cmake.definitions["PYBIND11_TEST"] = False
cmake.configure(source_folder="pybind11-%s" % self.version)
cmake.build()
cmake.install()
def package(self):
self.copy("*LICENSE", keep_path=False)
def package_id(self):
# Make all options and dependencies (direct and transitive) contribute
# to the package id
self.info.requires.full_package_mode()
def package_info(self):
self.cpp_info.builddirs.append(os.path.join("share", "cmake", "pybind11")) It is an adaptation of this https://github.com/conan-community/conan-pybind11. My CMakeLists.txt looks like that:
|
have this problem too |
Hi there, I'm closing this issue as this recipe has suffer plenty of modifications since this issue was reported. $ conan create recipes/pybind11/all --version 2.13.6 --build=missing
Happy coding 🐸 |
Package and Environment Details (include every applicable attribute)
Conan profile (output of
conan profile show default
orconan profile show <profile>
if custom profile is in use)Steps to reproduce (Include if Applicable)
conanfile.txt
CMakeLists.txt
Logs (Include/Attach if Applicable)
Click to expand log
Workarounds
This can be fixed by manually include the
pybind11Tools.cmake
file which defines the function pybind11_add_module.It seems that conan generated config.cmake file does not include pybind11's tools definition file. Is this the designed behaviour or my settings might be wrong?
The text was updated successfully, but these errors were encountered: