Browse Source

fix: android CMake support (#5733)

pull/5734/head
Henry Schreiner 3 weeks ago committed by GitHub
parent
commit
ad9180c120
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      tools/pybind11NewTools.cmake
  2. 3
      tools/pybind11Tools.cmake

11
tools/pybind11NewTools.cmake

@ -243,6 +243,17 @@ if(TARGET ${_Python}::Python)
endif() endif()
if(TARGET ${_Python}::Module) if(TARGET ${_Python}::Module)
# On Android, older versions of CMake don't know that modules need to link against
# libpython, so Python::Module will be an INTERFACE target with no associated library
# files.
get_target_property(module_target_type ${_Python}::Module TYPE)
if(ANDROID AND module_target_type STREQUAL INTERFACE_LIBRARY)
set_property(
TARGET ${_Python}::Module
APPEND
PROPERTY INTERFACE_LINK_LIBRARIES "${${_Python}_LIBRARIES}")
endif()
set_property( set_property(
TARGET pybind11::module TARGET pybind11::module
APPEND APPEND

3
tools/pybind11Tools.cmake

@ -119,7 +119,8 @@ target_link_libraries(
pybind11::module pybind11::module
INTERFACE INTERFACE
pybind11::python_link_helper pybind11::python_link_helper
"$<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:Cygwin>>:pybind11::_ClassicPythonLibraries>") "$<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:Cygwin>,$<PLATFORM_ID:Android>>:pybind11::_ClassicPythonLibraries>"
)
target_link_libraries(pybind11::embed INTERFACE pybind11::pybind11 target_link_libraries(pybind11::embed INTERFACE pybind11::pybind11
pybind11::_ClassicPythonLibraries) pybind11::_ClassicPythonLibraries)

Loading…
Cancel
Save