Skip to content

fix(cmake): keep cross-compiling support with CMake 4.1 / CMP0190#6115

Closed
henryiii wants to merge 1 commit into
pybind:masterfrom
henryiii:fix/crosscompiling-emulator-cmp0190
Closed

fix(cmake): keep cross-compiling support with CMake 4.1 / CMP0190#6115
henryiii wants to merge 1 commit into
pybind:masterfrom
henryiii:fix/crosscompiling-emulator-cmp0190

Conversation

@henryiii

@henryiii henryiii commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

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_EMULATOR to be defined when FindPython is called with both Interpreter and Development while cross-compiling. The Emscripten toolchain file defines it (to node) automatically, so the NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR condition added in #5829 turned _PYBIND11_CROSSCOMPILING off in exactly the Emscripten/Pyodide case, even when the project set PYBIND11_USE_CROSSCOMPILING itself. 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_CROSSCOMPILING is 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:

emulator PYBIND11_USE_CROSSCOMPILING before after
unset unset / ON / OFF ON ON
empty unset / ON / OFF OFF ON
real command unset OFF OFF
real command ON OFF ON
real command OFF OFF OFF

The bold row is the reported bug. With CMP0190 OLD (or CMake < 4.1) the result is again CMAKE_CROSSCOMPILING AND PYBIND11_USE_CROSSCOMPILING, as in pybind11 3.0.1.

Suggested changelog entry:

  • Cross-compiling support is no longer disabled when CMAKE_CROSSCOMPILING_EMULATOR is defined, which CMake 4.1's CMP0190 and the Emscripten toolchain do. This repairs Emscripten/Pyodide builds.

https://claude.ai/code/session_013JABmnjt9oAh29p1pytAB3

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
@henryiii henryiii closed this Jul 25, 2026
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.

[BUG]: Cannot compile emscripten/pyodide project

1 participant