-
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
Use pybind11 with cmake_find_package only #1481
Use pybind11 with cmake_find_package only #1481
Conversation
Some configurations of 'pybind11/2.4.3' failed in build 1 (
|
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") | ||
conan_basic_setup() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the cmake helper always required to make sure that the compiler flags are set correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not mandatory. Here I wanted to test that the package can be consumed ina transparent way with the CMake macros they provide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be needed when a cpython recipe is used.
Can't the call to conan_basic_setup
be moved to after the find_package
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please, leave the conan_basic_setup()
call, it is our toolchain until Conan provides a proper toolchain (WIP).
Some configurations of 'pybind11/2.4.3' failed in build 2 (
|
Some configurations of 'pybind11/2.4.3' failed in build 3 (
|
Some configurations of 'pybind11/2.4.3' failed in build 4 (
|
All green in build 5 (
|
All green in build 6 (
|
All green in build 7 (
|
All green in build 8 (
|
Some configurations of 'pybind11/2.4.3' failed in build 9 (
|
Some configurations of 'pybind11/2.4.3' failed in build 10 (
|
An unexpected error happened and has been reported. Help is on its way! 🏇 |
Some configurations of 'pybind11/2.4.3' failed in build 12 (
|
recipes/pybind11/all/conanfile.py
Outdated
@@ -38,6 +38,8 @@ def package(self): | |||
cmake.install() | |||
os.unlink(os.path.join(self.package_folder, "lib", "cmake", "pybind11", "pybind11Config.cmake")) | |||
os.unlink(os.path.join(self.package_folder, "lib", "cmake", "pybind11", "pybind11ConfigVersion.cmake")) | |||
pybind11tools_path = os.path.join(self.package_folder, "lib", "cmake", "pybind11", "pybind11Tools.cmake") | |||
tools.replace_in_file(pybind11tools_path, "PYBIND11_INCLUDE_DIR", "pybind11_INCLUDE_DIRS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jgsogo maybe this is not a good solution when consuming this package from the cmake_package_multi generator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I see here is that inside the file pybind11Tools
we have a problem. We shouldn't use pybind11_INCLUDE_DIRS
but the pybind11::pybind11
target... but it won't work if using just a cmake
generator.
I only have questions here: can we use the CONAN_LIB::...
target? Probably not the same name for cmake_find_package
generators. Should we create always the target pybind11::pybind11
even for cmake
generator? What about old CMake without targets supports (do we care about so old versions for this recipe?)?
A different way to go is add a list to different include directories (it already has a bunch of them). We can add the generator expression that works for the cmake_find_package[_multi]
generator:
target_include_directories(${target_name} ${inc_isystem}
PRIVATE ${pybind11_INCLUDE_DIRS} # from project CMakeLists.txt
PRIVATE ${pybind11_INCLUDE_DIR} # from pybind11Config
PRIVATE ${PYTHON_INCLUDE_DIRS}
)
Here we have a similar problem as the one be have in the protobuf
package. We need to hardcode in a file something that works for any generator that we will define afterward. Can we workaround it? Is this one reason why we need a proper deploy
function with the additional install folder in the cache?
I know this is not an answer, only questions, but I need to think more about this issue.
I'm trying to replace my locally built
|
@danimtb pls rebase |
@SSE4 this was just a test/proposal and it is still not ready to be merged. I have made it a draft. Thanks |
Is this pull request still alive? |
@madebr I need to give it another try. Unfortunately, we cannot remove |
All green in build 15 (
|
Would it be possible to also add the targets that the documentation specifies? |
All green in build 16 (
|
This PR is not exaclty what I was expecting but at least we prove that the consumption of the library can be simplified and the macros of cmake work. If you think it is not relevant I am fine dropping it. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
less code is always nice!
All green in build 17 (
|
Seems everything works fine after the line endings change, sorry for the noise 😅 |
Wow. GitHub is not removing existing approvals when an empty commit is pushed. Very smart 👍 |
Specify library name and version: pybin11/all
Try to consume pybind11 in the canonical way indicated in the documentation for CMake.
conan-center hook activated.