Skip to content

Conversation

mhsmith
Copy link
Contributor

@mhsmith mhsmith commented Sep 5, 2025

Description

This PR updates the Android linking workaround in pybind11NewTools.cmake to be compatible with vcpkg, as discussed at #5733 (review). I've also submitted an upstream fix to CMake, so this workaround can eventually be removed.

However, most of the PR is about CMake policy CMP0190, which prohibits calling FindPython with both the Interpreter and Development components at the same time when cross-compiling:

  • Enabled PYBIND11_USE_CROSSCOMPILING whenever CMP0190 is in effect.

  • Updated pybind11NewTools.cmake so it no longer requires the Interpreter component, whether cross-compiling or not. This allows packages to use the same configuration for both cases.

  • Improved pybind11GuessPythonExtSuffix.cmake:

    • Added SKBUILD_SOABI as another possible source of the Python module suffix.
    • Set result variables to the CACHE, just as they are when they're detected from the interpreter. Previously they were set to the PARENT_SCOPE, but that's the module scope of pybind11NewTools.cmake, which isn't accessible when calling functions from a different module. As a result, modules created using pybind11_add_module were being built with no extension at all!
  • To encourage packages to be compatible with cross-compilation, I've removed Interpreter from all the documentation, examples and tests, except for the places which actually needed it.

The new policy can be tested by changing the cmake_minimum_required upper limit in CMakeLists.txt from 4.0 to 4.1, and then using cibuildwheel to build the tests project. However, I haven't changed the cmake_minimum_required in this PR, because I'm not sure what other effects it might have.

See also:

Suggested changelog entry:

  • Fix compatibility with CMake policy CMP0190, which prohibits calling FindPython with both the Interpreter and Development components at the same time when cross-compiling.

📚 Documentation preview 📚: https://pybind11--5829.org.readthedocs.build/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant