-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: android CMake support #5733
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
Merged
+13
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I just looked at the original problem in vcpkg (pybind11 2.6.13) and came to a similiar fixup, however injected on top of
find_package(Python)
. With 3.0.0, I found android broken again for a different reason, and now I'm here with questions:Has this issue been reported to CMake? I cannot see any relevant changes, so I don't understand how this is limited to "older versions".
IMO the situation is similar to Windows DLLs: no undefined symbols. And this is how it is handled for Windows:
https://github.com/Kitware/CMake/blob/6754d2f9b8d5ba24b87db232a0aedca8d15c707d/Modules/FindPython/Support.cmake#L1517-L1522
https://github.com/Kitware/CMake/blob/6754d2f9b8d5ba24b87db232a0aedca8d15c707d/Modules/FindPython/Support.cmake#L4327-L4335
There is no trace of
ANDROID
in this file.IMO it should be avoided to modify imported targets from other CMake modules. In particular, I don't see why it is not sufficient to modifiy
pybind11::module
.This is the spot which causes trouble in vcpkg now.
${${_Python}_LIBRARIES}
is initialized for multi-config use intarget_link_libraries
, withdebug
andoptimized
keywords which are not allowed when setting the property directly.My initial fixup is to use
$<LINK_ONLY:${_Python}::Python>
.Alternatively, is possible to use
target_link_libraries(pybind11::module INTERFACE ${${_Python}_LIBRARIES})
Disclaimer: I'm a python rookie.
vcpkg WIP: microsoft/vcpkg#46539
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.
... Maybe the goal is to fix the following?
Uh oh!
There was an error while loading. Please reload this page.
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.
Testing with the openimageio port, using
${${_Python}_LIBRARIES}
still fails because the actual variablePython3_LIBRARIES
is not set in the scope of this line of code.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.
Okay, the openimageio issue is from looking for
Interpreter Development.Module
components if not on Windows.Development
should be at least inOPTIONAL_COMPONENTS
.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.
Hi, it was me who originally wrote this code in #5714, but I didn't subscribe to this PR so I didn't notice your comments. Sorry about that.
I'm currently working on a fix which I'll submit to CMake, and then I'll post a link here so you can review it. In the long run, this should allow all of these workarounds to be removed.
Yes, that was the reason. This pattern is recommended in pybind11's documentation, so it will be used by many Python packages.
Thanks, that seems like a good solution. I'll test it, and if it works, I'll submit it as another pybind11 PR.
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.
Let's continue the discussion in the new PR: