mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-08 16:50:48 +00:00
FindPython: Add support for python specific crosscompiling emulator
Fixes: #27996
This commit is contained in:
8
Help/release/dev/FindPython-CROSSCOMPILING_EMULATOR.rst
Normal file
8
Help/release/dev/FindPython-CROSSCOMPILING_EMULATOR.rst
Normal file
@@ -0,0 +1,8 @@
|
||||
FindPython-CROSSCOMPILING_EMULATOR
|
||||
----------------------------------
|
||||
|
||||
* The :module:`FindPython`, :module:`FindPython2`, and :module:`FindPython3`
|
||||
modules gained the possibility to override the
|
||||
:variable:`CMAKE_CROSSCOMPILING_EMULATOR` variable by respectively, the
|
||||
variables ``Python_CROSSCOMPILING_EMULATOR``,
|
||||
``Python2_CROSSCOMPILING_EMULATOR``, and ``Python3_CROSSCOMPILING_EMULATOR``.
|
||||
@@ -652,6 +652,19 @@ can be controlled with the following variable:
|
||||
``_FOUND`` variables (i.e. without the custom prefix) are also defined by
|
||||
each call to the :command:`find_package` command.
|
||||
|
||||
``Python_CROSSCOMPILING_EMULATOR``
|
||||
.. versionadded:: 4.5
|
||||
|
||||
This variable is only used when the :variable:`CMAKE_CROSSCOMPILING` variable
|
||||
is on and the policy :policy:`CMP0190` is ``NEW``. It should point to a
|
||||
command on the host system that can run executable built for the target
|
||||
system. This variable takes precedence over the
|
||||
:variable:`CMAKE_CROSSCOMPILING_EMULATOR` variable.
|
||||
|
||||
Moreover, to support some specific cases (like
|
||||
`crossenv <https://github.com/robotpy/crossenv>`_), it is possible to set an
|
||||
empty string to this variable.
|
||||
|
||||
Commands
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
@@ -1034,7 +1034,7 @@ function (_PYTHON_GET_LAUNCHER _PYTHON_PGL_NAME)
|
||||
endif()
|
||||
|
||||
if (_${_PYTHON_PREFIX}_CROSSCOMPILING)
|
||||
set (${_PYTHON_PGL_NAME} "${CMAKE_CROSSCOMPILING_EMULATOR}" PARENT_SCOPE)
|
||||
set (${_PYTHON_PGL_NAME} "${_${_PYTHON_PREFIX}_CROSSCOMPILING_EMULATOR}" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -1642,16 +1642,23 @@ endif()
|
||||
|
||||
## handle cross-compiling constraints for components:
|
||||
## If Interpreter and/or Compiler are specified with Development components
|
||||
## the CMAKE_CROSSCOMPILING_EMULATOR variable should be defined
|
||||
## the Python_CROSSCOMPILING_EMULATOR or CMAKE_CROSSCOMPILING_EMULATOR variable
|
||||
## should be defined
|
||||
cmake_policy (GET CMP0190 _${_PYTHON_PREFIX}_CROSSCOMPILING_POLICY)
|
||||
unset (_${_PYTHON_PREFIX}_CROSSCOMPILING)
|
||||
unset (_${_PYTHON_PREFIX}_CROSSCOMPILING_EMULATOR)
|
||||
if (CMAKE_CROSSCOMPILING AND _${_PYTHON_PREFIX}_CROSSCOMPILING_POLICY STREQUAL "NEW")
|
||||
if (${_PYTHON_BASE}_FIND_COMPONENTS MATCHES "Interpreter|Compiler"
|
||||
AND ${_PYTHON_BASE}_FIND_COMPONENTS MATCHES "Development")
|
||||
if (CMAKE_CROSSCOMPILING_EMULATOR)
|
||||
if (DEFINED ${_PYTHON_PREFIX}_CROSSCOMPILING_EMULATOR OR CMAKE_CROSSCOMPILING_EMULATOR)
|
||||
set (_${_PYTHON_PREFIX}_CROSSCOMPILING TRUE)
|
||||
if (DEFINED ${_PYTHON_PREFIX}_CROSSCOMPILING_EMULATOR)
|
||||
set (_${_PYTHON_PREFIX}_CROSSCOMPILING_EMULATOR "${${_PYTHON_PREFIX}_CROSSCOMPILING_EMULATOR}")
|
||||
else()
|
||||
set (_${_PYTHON_PREFIX}_CROSSCOMPILING_EMULATOR "${CMAKE_CROSSCOMPILING_EMULATOR}")
|
||||
endif()
|
||||
else()
|
||||
_python_display_failure ("${_PYTHON_PREFIX}: When cross-compiling, Interpreter and/or Compiler components cannot be searched when CMAKE_CROSSCOMPILING_EMULATOR variable is not specified (see policy CMP0190)." FATAL)
|
||||
_python_display_failure ("${_PYTHON_PREFIX}: When cross-compiling, Interpreter and/or Compiler components cannot be searched when ${_PYTHON_PREFIX}_CROSSCOMPILING_EMULATOR or CMAKE_CROSSCOMPILING_EMULATOR variable is not specified (see policy CMP0190)." FATAL)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -497,6 +497,19 @@ can be controlled with the following variable:
|
||||
``_FOUND`` variables (i.e. without the custom prefix) are also defined by
|
||||
each call to the :command:`find_package` command.
|
||||
|
||||
``Python2_CROSSCOMPILING_EMULATOR``
|
||||
.. versionadded:: 4.5
|
||||
|
||||
This variable is only used when the :variable:`CMAKE_CROSSCOMPILING` variable
|
||||
is on and the policy :policy:`CMP0190` is ``NEW``. It should point to a
|
||||
command on the host system that can run executable built for the target
|
||||
system. This variable takes precedence over the
|
||||
:variable:`CMAKE_CROSSCOMPILING_EMULATOR` variable.
|
||||
|
||||
Moreover, to support some specific cases (like
|
||||
`crossenv <https://github.com/robotpy/crossenv>`_), it is possible to set an
|
||||
empty string to this variable.
|
||||
|
||||
Commands
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
@@ -651,6 +651,19 @@ can be controlled with the following variable:
|
||||
``_FOUND`` variables (i.e. without the custom prefix) are also defined by
|
||||
each call to the :command:`find_package` command.
|
||||
|
||||
``Python3_CROSSCOMPILING_EMULATOR``
|
||||
.. versionadded:: 4.5
|
||||
|
||||
This variable is only used when the :variable:`CMAKE_CROSSCOMPILING` variable
|
||||
is on and the policy :policy:`CMP0190` is ``NEW``. It should point to a
|
||||
command on the host system that can run executable built for the target
|
||||
system. This variable takes precedence over the
|
||||
:variable:`CMAKE_CROSSCOMPILING_EMULATOR` variable.
|
||||
|
||||
Moreover, to support some specific cases (like
|
||||
`crossenv <https://github.com/robotpy/crossenv>`_), it is possible to set an
|
||||
empty string to this variable.
|
||||
|
||||
Commands
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
@@ -12,22 +12,25 @@ unset(${PYTHON}_ARTIFACTS_PREFIX)
|
||||
|
||||
|
||||
# Search cross-compilation artifacts
|
||||
## First, built an pseudo-emulator
|
||||
set(PSEUDO_EMULATOR_DIR "${CMAKE_CURRENT_BINARY_DIR}/pseudo_emulator")
|
||||
|
||||
file(MAKE_DIRECTORY "${PSEUDO_EMULATOR_DIR}")
|
||||
if (NOT DEFINED ${PYTHON}_CROSSCOMPILING_EMULATOR)
|
||||
## First, built an pseudo-emulator
|
||||
set(PSEUDO_EMULATOR_DIR "${CMAKE_CURRENT_BINARY_DIR}/pseudo_emulator")
|
||||
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release
|
||||
-S "${CMAKE_CURRENT_SOURCE_DIR}/pseudo_emulator"
|
||||
-B "${PSEUDO_EMULATOR_DIR}"
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
file(MAKE_DIRECTORY "${PSEUDO_EMULATOR_DIR}")
|
||||
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build "${PSEUDO_EMULATOR_DIR}"
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release
|
||||
-S "${CMAKE_CURRENT_SOURCE_DIR}/pseudo_emulator"
|
||||
-B "${PSEUDO_EMULATOR_DIR}"
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build "${PSEUDO_EMULATOR_DIR}"
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
## Now, configure this pseudo-emulator
|
||||
set(CMAKE_CROSSCOMPILING_EMULATOR "${PSEUDO_EMULATOR_DIR}/pseudo_emulator")
|
||||
endif()
|
||||
|
||||
## Now, configure this pseudo-emulator
|
||||
set(CMAKE_CROSSCOMPILING TRUE)
|
||||
set(CMAKE_CROSSCOMPILING_EMULATOR "${PSEUDO_EMULATOR_DIR}/pseudo_emulator")
|
||||
|
||||
|
||||
find_package(${PYTHON} ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
CMake Error at .+/Support\.cmake:[0-9]+ \(message\):
|
||||
Python: When cross-compiling, Interpreter and/or Compiler components cannot
|
||||
be searched when CMAKE_CROSSCOMPILING_EMULATOR variable is not specified
|
||||
\(see policy CMP0190\)\.
|
||||
be searched when Python_CROSSCOMPILING_EMULATOR or
|
||||
CMAKE_CROSSCOMPILING_EMULATOR variable is not specified \(see policy
|
||||
CMP0190\)\.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
CMake Error at .+/Support\.cmake:[0-9]+ \(message\):
|
||||
Python: When cross-compiling, Interpreter and/or Compiler components cannot
|
||||
be searched when CMAKE_CROSSCOMPILING_EMULATOR variable is not specified
|
||||
\(see policy CMP0190\)\.
|
||||
be searched when Python_CROSSCOMPILING_EMULATOR or
|
||||
CMAKE_CROSSCOMPILING_EMULATOR variable is not specified \(see policy
|
||||
CMP0190\)\.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
CMake Error at .+/Support\.cmake:[0-9]+ \(message\):
|
||||
Python2: When cross-compiling, Interpreter and/or Compiler components
|
||||
cannot be searched when CMAKE_CROSSCOMPILING_EMULATOR variable is not
|
||||
specified \(see policy CMP0190\)\.
|
||||
cannot be searched when Python2_CROSSCOMPILING_EMULATOR or
|
||||
CMAKE_CROSSCOMPILING_EMULATOR variable is not specified \(see policy
|
||||
CMP0190\)\.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
CMake Error at .+/Support\.cmake:[0-9]+ \(message\):
|
||||
Python3: When cross-compiling, Interpreter and/or Compiler components
|
||||
cannot be searched when CMAKE_CROSSCOMPILING_EMULATOR variable is not
|
||||
specified \(see policy CMP0190\)\.
|
||||
cannot be searched when Python3_CROSSCOMPILING_EMULATOR or
|
||||
CMAKE_CROSSCOMPILING_EMULATOR variable is not specified \(see policy
|
||||
CMP0190\)\.
|
||||
|
||||
@@ -2,22 +2,24 @@ cmake_policy(SET CMP0190 NEW)
|
||||
|
||||
enable_language(C)
|
||||
|
||||
## First, built an pseudo-emulator
|
||||
set(PSEUDO_EMULATOR_DIR "${CMAKE_CURRENT_BINARY_DIR}/pseudo_emulator")
|
||||
if (NOT DEFINED ${PYTHON}_CROSSCOMPILING_EMULATOR)
|
||||
## First, built an pseudo-emulator
|
||||
set(PSEUDO_EMULATOR_DIR "${CMAKE_CURRENT_BINARY_DIR}/pseudo_emulator")
|
||||
|
||||
file(MAKE_DIRECTORY "${PSEUDO_EMULATOR_DIR}")
|
||||
file(MAKE_DIRECTORY "${PSEUDO_EMULATOR_DIR}")
|
||||
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release
|
||||
-S "${CMAKE_CURRENT_SOURCE_DIR}/pseudo_emulator"
|
||||
-B "${PSEUDO_EMULATOR_DIR}"
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release
|
||||
-S "${CMAKE_CURRENT_SOURCE_DIR}/pseudo_emulator"
|
||||
-B "${PSEUDO_EMULATOR_DIR}"
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build "${PSEUDO_EMULATOR_DIR}"
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build "${PSEUDO_EMULATOR_DIR}"
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
## Now, configure this pseudo-emulator
|
||||
set(CMAKE_CROSSCOMPILING_EMULATOR "${PSEUDO_EMULATOR_DIR}/pseudo_emulator")
|
||||
endif()
|
||||
|
||||
## Now, configure this pseudo-emulator
|
||||
set(CMAKE_CROSSCOMPILING TRUE)
|
||||
set(CMAKE_CROSSCOMPILING_EMULATOR "${PSEUDO_EMULATOR_DIR}/pseudo_emulator")
|
||||
|
||||
|
||||
find_package(${PYTHON} ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development)
|
||||
|
||||
@@ -167,11 +167,21 @@ if(CMake_TEST_FindPython2_CPython)
|
||||
OPTIONS -DPython_REQUESTED_VERSION=2)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin" AND NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
run_python(CrossCompiling-TARGET TYPE Python2 VARIANT Python2)
|
||||
run_python(CrossCompiling-TARGET TYPE Python2 VARIANT Python2.crossenv
|
||||
OPTIONS "-DPython2_CROSSCOMPILING_EMULATOR=")
|
||||
run_python(CrossCompiling-TARGET TYPE Python VARIANT Python.V2
|
||||
OPTIONS -DPython_REQUESTED_VERSION=2)
|
||||
run_python(CrossCompiling-TARGET TYPE Python VARIANT Python.V2.crossenv
|
||||
OPTIONS -DPython_REQUESTED_VERSION=2
|
||||
"-DPython_CROSSCOMPILING_EMULATOR=")
|
||||
run_python(CrossCompiling-BOTH TYPE Python2 VARIANT Python2)
|
||||
run_python(CrossCompiling-BOTH TYPE Python2 VARIANT Python2.crossenv
|
||||
OPTIONS "-DPython2_CROSSCOMPILING_EMULATOR=")
|
||||
run_python(CrossCompiling-BOTH TYPE Python VARIANT Python.V2
|
||||
OPTIONS -DPython_REQUESTED_VERSION=2)
|
||||
run_python(CrossCompiling-BOTH TYPE Python VARIANT Python.V2.crossenv
|
||||
OPTIONS -DPython_REQUESTED_VERSION=2
|
||||
"-DPython_CROSSCOMPILING_EMULATOR=")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -225,9 +235,19 @@ if(CMake_TEST_FindPython3_CPython)
|
||||
run_python(CrossCompiling-TARGET TYPE Python3 VARIANT Python3)
|
||||
run_python(CrossCompiling-TARGET TYPE Python VARIANT Python.V3
|
||||
OPTIONS -DPython_REQUESTED_VERSION=3)
|
||||
run_python(CrossCompiling-TARGET TYPE Python3 VARIANT Python3.crossenv
|
||||
OPTIONS "-DPython3_CROSSCOMPILING_EMULATOR=")
|
||||
run_python(CrossCompiling-TARGET TYPE Python VARIANT Python.V3.crossenv
|
||||
OPTIONS -DPython_REQUESTED_VERSION=3
|
||||
"-DPython_CROSSCOMPILING_EMULATOR=")
|
||||
run_python(CrossCompiling-BOTH TYPE Python3 VARIANT Python3)
|
||||
run_python(CrossCompiling-BOTH TYPE Python3 VARIANT Python3.crossenv
|
||||
OPTIONS "-DPython3_CROSSCOMPILING_EMULATOR=")
|
||||
run_python(CrossCompiling-BOTH TYPE Python VARIANT Python.V3
|
||||
OPTIONS -DPython_REQUESTED_VERSION=3)
|
||||
run_python(CrossCompiling-BOTH TYPE Python VARIANT Python.V3.crossenv
|
||||
OPTIONS -DPython_REQUESTED_VERSION=3
|
||||
"-DPython_CROSSCOMPILING_EMULATOR=")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user