Skip to content

Commit

Permalink
Use PYBIND11_CROSSCOMPILING instead of CMAKE_CROSSCOMPILING
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed May 29, 2024
1 parent 4da0baf commit 12159d5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
19 changes: 18 additions & 1 deletion tools/pybind11Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ set(pybind11_INCLUDE_DIRS
"${pybind11_INCLUDE_DIR}"
CACHE INTERNAL "Include directory for pybind11 (Python not requested)")

# Cross-compilation support
if(NOT DEFINED PYBIND11_CROSSCOMPILING)
if(CMAKE_CROSSCOMPILING)
message(
WARNING
"A behavior change for cross-compilation is planned for future versions "
"of pybind11. To opt in to the improved cross-compilation logic now and "
"to silence this warning, use 'set(PYBIND11_CROSSCOMPILING ${CMAKE_CROSSCOMPILING})'.")
endif()
set(PYBIND11_CROSSCOMPILING
Off
CACHE
BOOL
"Enable cross-compilation mode and avoid using the build machine's Python interpreter to infer properties about the host machine."
)
endif()

# --------------------- Shared targets ----------------------------

# Build an interface library target:
Expand Down Expand Up @@ -195,7 +212,7 @@ endif()

# --------------------- pybind11_find_import -------------------------------

if(NOT _pybind11_nopython AND NOT CMAKE_CROSSCOMPILING)
if(NOT _pybind11_nopython AND NOT PYBIND11_CROSSCOMPILING)
# Check to see if modules are importable. Use REQUIRED to force an error if
# one of the modules is not found. <package_name>_FOUND will be set if the
# package was found (underscores replace dashes if present). QUIET will hide
Expand Down
4 changes: 2 additions & 2 deletions tools/pybind11NewTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if(NOT Python_FOUND AND NOT Python3_FOUND)
endif()

# Interpreter should not be found when cross-compiling
if(CMAKE_CROSSCOMPILING)
if(PYBIND11_CROSSCOMPILING)
set(_pybind11_interp_component "")
else()
set(_pybind11_interp_component Interpreter)
Expand Down Expand Up @@ -110,7 +110,7 @@ if(PYBIND11_MASTER_PROJECT)
endif()
endif()

if(NOT CMAKE_CROSSCOMPILING)
if(NOT PYBIND11_CROSSCOMPILING)
# If a user finds Python, they may forget to include the Interpreter component
# and the following two steps require it. It is highly recommended by CMake
# when finding development libraries anyway, so we will require it.
Expand Down

0 comments on commit 12159d5

Please sign in to comment.