fix(cmake): keep cross-compiling support with CMake 4.1 / CMP0190#6115
Closed
henryiii wants to merge 1 commit into
Closed
fix(cmake): keep cross-compiling support with CMake 4.1 / CMP0190#6115henryiii wants to merge 1 commit into
henryiii wants to merge 1 commit into
Conversation
CMP0190 requires CMAKE_CROSSCOMPILING_EMULATOR to be defined when cross-compiling, and the Emscripten toolchain defines it as soon as node is available. The emulator check therefore disabled _PYBIND11_CROSSCOMPILING in exactly the Emscripten/Pyodide case, even when the project asked for cross-compiling support. The emulator now only suppresses the CMP0190 default; an explicit PYBIND11_USE_CROSSCOMPILING is honored again. Fixes pybind#6043 Fix proposed by mhsmith. Assisted-by: ClaudeCode:claude-opus-5 Claude-Session: https://claude.ai/code/session_013JABmnjt9oAh29p1pytAB3
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
See #6112. Duplicate of #6094.
🤖 AI text below 🤖
Description
Fixes #6043. Fix proposed by @mhsmith in #6043.
CMake 4.1 policy CMP0190 requires
CMAKE_CROSSCOMPILING_EMULATORto be defined whenFindPythonis called with bothInterpreterandDevelopmentwhile cross-compiling. The Emscripten toolchain file defines it (tonode) automatically, so theNOT DEFINED CMAKE_CROSSCOMPILING_EMULATORcondition added in #5829 turned_PYBIND11_CROSSCOMPILINGoff in exactly the Emscripten/Pyodide case, even when the project setPYBIND11_USE_CROSSCOMPILINGitself. The build then failed with a spurious "Cannot run the interpreter".The emulator check now only suppresses the CMP0190-related default; an explicit
PYBIND11_USE_CROSSCOMPILINGis honored again. An emulator set to an empty value counts as no emulator.Verified by simulation (no Emscripten toolchain available), CMake 4.4, CMP0190
NEW,CMAKE_CROSSCOMPILING=ON. Value of_PYBIND11_CROSSCOMPILING:PYBIND11_USE_CROSSCOMPILINGThe bold row is the reported bug. With CMP0190
OLD(or CMake < 4.1) the result is againCMAKE_CROSSCOMPILING AND PYBIND11_USE_CROSSCOMPILING, as in pybind11 3.0.1.Suggested changelog entry:
CMAKE_CROSSCOMPILING_EMULATORis defined, which CMake 4.1'sCMP0190and the Emscripten toolchain do. This repairs Emscripten/Pyodide builds.https://claude.ai/code/session_013JABmnjt9oAh29p1pytAB3