From 5564addb3a1c84e58c13a2e25850201e4b39b319 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sat, 25 Jul 2026 12:51:57 -0400 Subject: [PATCH] fix(cmake): keep cross-compiling support with CMake 4.1 / CMP0190 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 #6043 Fix proposed by mhsmith. Assisted-by: ClaudeCode:claude-opus-5 Claude-Session: https://claude.ai/code/session_013JABmnjt9oAh29p1pytAB3 --- tools/pybind11Common.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/pybind11Common.cmake b/tools/pybind11Common.cmake index 1311d3faf9..9e9eb7b004 100644 --- a/tools/pybind11Common.cmake +++ b/tools/pybind11Common.cmake @@ -43,16 +43,16 @@ set(pybind11_INCLUDE_DIRS # CMP0190 prohibits calling FindPython with both Interpreter and Development components # when cross-compiling, unless the CMAKE_CROSSCOMPILING_EMULATOR variable is defined. -if(CMAKE_VERSION VERSION_GREATER_EQUAL "4.1") +# An emulator can run the target interpreter, so it only suppresses this default; a project +# that asks for cross-compiling support explicitly always gets it (see #6043). +if(CMAKE_VERSION VERSION_GREATER_EQUAL "4.1" AND NOT CMAKE_CROSSCOMPILING_EMULATOR) cmake_policy(GET CMP0190 _pybind11_cmp0190) if(_pybind11_cmp0190 STREQUAL "NEW") set(PYBIND11_USE_CROSSCOMPILING "ON") endif() endif() -if(CMAKE_CROSSCOMPILING - AND PYBIND11_USE_CROSSCOMPILING - AND NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR) +if(CMAKE_CROSSCOMPILING AND PYBIND11_USE_CROSSCOMPILING) set(_PYBIND11_CROSSCOMPILING ON CACHE INTERNAL "")