mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
FindPython: Add support for python specific crosscompiling emulator
Fixes: #27996
This commit is contained in:
@@ -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
|
``_FOUND`` variables (i.e. without the custom prefix) are also defined by
|
||||||
each call to the :command:`find_package` command.
|
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
|
Commands
|
||||||
^^^^^^^^
|
^^^^^^^^
|
||||||
|
|
||||||
|
|||||||
@@ -1034,7 +1034,7 @@ function (_PYTHON_GET_LAUNCHER _PYTHON_PGL_NAME)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (_${_PYTHON_PREFIX}_CROSSCOMPILING)
|
if (_${_PYTHON_PREFIX}_CROSSCOMPILING)
|
||||||
set (${_PYTHON_PGL_NAME} "${CMAKE_CROSSCOMPILING_EMULATOR}" PARENT_SCOPE)
|
set (${_PYTHON_PGL_NAME} "${_${_PYTHON_PREFIX}_CROSSCOMPILING_EMULATOR}" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -1642,16 +1642,23 @@ endif()
|
|||||||
|
|
||||||
## handle cross-compiling constraints for components:
|
## handle cross-compiling constraints for components:
|
||||||
## If Interpreter and/or Compiler are specified with Development 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)
|
cmake_policy (GET CMP0190 _${_PYTHON_PREFIX}_CROSSCOMPILING_POLICY)
|
||||||
unset (_${_PYTHON_PREFIX}_CROSSCOMPILING)
|
unset (_${_PYTHON_PREFIX}_CROSSCOMPILING)
|
||||||
|
unset (_${_PYTHON_PREFIX}_CROSSCOMPILING_EMULATOR)
|
||||||
if (CMAKE_CROSSCOMPILING AND _${_PYTHON_PREFIX}_CROSSCOMPILING_POLICY STREQUAL "NEW")
|
if (CMAKE_CROSSCOMPILING AND _${_PYTHON_PREFIX}_CROSSCOMPILING_POLICY STREQUAL "NEW")
|
||||||
if (${_PYTHON_BASE}_FIND_COMPONENTS MATCHES "Interpreter|Compiler"
|
if (${_PYTHON_BASE}_FIND_COMPONENTS MATCHES "Interpreter|Compiler"
|
||||||
AND ${_PYTHON_BASE}_FIND_COMPONENTS MATCHES "Development")
|
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)
|
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()
|
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()
|
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
|
``_FOUND`` variables (i.e. without the custom prefix) are also defined by
|
||||||
each call to the :command:`find_package` command.
|
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
|
Commands
|
||||||
^^^^^^^^
|
^^^^^^^^
|
||||||
|
|
||||||
|
|||||||
@@ -651,6 +651,19 @@ can be controlled with the following variable:
|
|||||||
``_FOUND`` variables (i.e. without the custom prefix) are also defined by
|
``_FOUND`` variables (i.e. without the custom prefix) are also defined by
|
||||||
each call to the :command:`find_package` command.
|
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
|
Commands
|
||||||
^^^^^^^^
|
^^^^^^^^
|
||||||
|
|
||||||
|
|||||||
@@ -12,22 +12,25 @@ unset(${PYTHON}_ARTIFACTS_PREFIX)
|
|||||||
|
|
||||||
|
|
||||||
# Search cross-compilation artifacts
|
# 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
|
file(MAKE_DIRECTORY "${PSEUDO_EMULATOR_DIR}")
|
||||||
-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}"
|
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release
|
||||||
COMMAND_ERROR_IS_FATAL ANY)
|
-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 TRUE)
|
||||||
set(CMAKE_CROSSCOMPILING_EMULATOR "${PSEUDO_EMULATOR_DIR}/pseudo_emulator")
|
|
||||||
|
|
||||||
|
|
||||||
find_package(${PYTHON} ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development)
|
find_package(${PYTHON} ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
CMake Error at .+/Support\.cmake:[0-9]+ \(message\):
|
CMake Error at .+/Support\.cmake:[0-9]+ \(message\):
|
||||||
Python: When cross-compiling, Interpreter and/or Compiler components cannot
|
Python: When cross-compiling, Interpreter and/or Compiler components cannot
|
||||||
be searched when CMAKE_CROSSCOMPILING_EMULATOR variable is not specified
|
be searched when Python_CROSSCOMPILING_EMULATOR or
|
||||||
\(see policy CMP0190\)\.
|
CMAKE_CROSSCOMPILING_EMULATOR variable is not specified \(see policy
|
||||||
|
CMP0190\)\.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
CMake Error at .+/Support\.cmake:[0-9]+ \(message\):
|
CMake Error at .+/Support\.cmake:[0-9]+ \(message\):
|
||||||
Python: When cross-compiling, Interpreter and/or Compiler components cannot
|
Python: When cross-compiling, Interpreter and/or Compiler components cannot
|
||||||
be searched when CMAKE_CROSSCOMPILING_EMULATOR variable is not specified
|
be searched when Python_CROSSCOMPILING_EMULATOR or
|
||||||
\(see policy CMP0190\)\.
|
CMAKE_CROSSCOMPILING_EMULATOR variable is not specified \(see policy
|
||||||
|
CMP0190\)\.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
CMake Error at .+/Support\.cmake:[0-9]+ \(message\):
|
CMake Error at .+/Support\.cmake:[0-9]+ \(message\):
|
||||||
Python2: When cross-compiling, Interpreter and/or Compiler components
|
Python2: When cross-compiling, Interpreter and/or Compiler components
|
||||||
cannot be searched when CMAKE_CROSSCOMPILING_EMULATOR variable is not
|
cannot be searched when Python2_CROSSCOMPILING_EMULATOR or
|
||||||
specified \(see policy CMP0190\)\.
|
CMAKE_CROSSCOMPILING_EMULATOR variable is not specified \(see policy
|
||||||
|
CMP0190\)\.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
CMake Error at .+/Support\.cmake:[0-9]+ \(message\):
|
CMake Error at .+/Support\.cmake:[0-9]+ \(message\):
|
||||||
Python3: When cross-compiling, Interpreter and/or Compiler components
|
Python3: When cross-compiling, Interpreter and/or Compiler components
|
||||||
cannot be searched when CMAKE_CROSSCOMPILING_EMULATOR variable is not
|
cannot be searched when Python3_CROSSCOMPILING_EMULATOR or
|
||||||
specified \(see policy CMP0190\)\.
|
CMAKE_CROSSCOMPILING_EMULATOR variable is not specified \(see policy
|
||||||
|
CMP0190\)\.
|
||||||
|
|||||||
@@ -2,22 +2,24 @@ cmake_policy(SET CMP0190 NEW)
|
|||||||
|
|
||||||
enable_language(C)
|
enable_language(C)
|
||||||
|
|
||||||
## First, built an pseudo-emulator
|
if (NOT DEFINED ${PYTHON}_CROSSCOMPILING_EMULATOR)
|
||||||
set(PSEUDO_EMULATOR_DIR "${CMAKE_CURRENT_BINARY_DIR}/pseudo_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
|
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release
|
||||||
-S "${CMAKE_CURRENT_SOURCE_DIR}/pseudo_emulator"
|
-S "${CMAKE_CURRENT_SOURCE_DIR}/pseudo_emulator"
|
||||||
-B "${PSEUDO_EMULATOR_DIR}"
|
-B "${PSEUDO_EMULATOR_DIR}"
|
||||||
COMMAND_ERROR_IS_FATAL ANY)
|
COMMAND_ERROR_IS_FATAL ANY)
|
||||||
|
|
||||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build "${PSEUDO_EMULATOR_DIR}"
|
execute_process(COMMAND "${CMAKE_COMMAND}" --build "${PSEUDO_EMULATOR_DIR}"
|
||||||
COMMAND_ERROR_IS_FATAL ANY)
|
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 TRUE)
|
||||||
set(CMAKE_CROSSCOMPILING_EMULATOR "${PSEUDO_EMULATOR_DIR}/pseudo_emulator")
|
|
||||||
|
|
||||||
|
|
||||||
find_package(${PYTHON} ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development)
|
find_package(${PYTHON} ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development)
|
||||||
|
|||||||
@@ -167,11 +167,21 @@ if(CMake_TEST_FindPython2_CPython)
|
|||||||
OPTIONS -DPython_REQUESTED_VERSION=2)
|
OPTIONS -DPython_REQUESTED_VERSION=2)
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin" AND NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
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)
|
||||||
|
run_python(CrossCompiling-TARGET TYPE Python2 VARIANT Python2.crossenv
|
||||||
|
OPTIONS "-DPython2_CROSSCOMPILING_EMULATOR=")
|
||||||
run_python(CrossCompiling-TARGET TYPE Python VARIANT Python.V2
|
run_python(CrossCompiling-TARGET TYPE Python VARIANT Python.V2
|
||||||
OPTIONS -DPython_REQUESTED_VERSION=2)
|
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)
|
||||||
|
run_python(CrossCompiling-BOTH TYPE Python2 VARIANT Python2.crossenv
|
||||||
|
OPTIONS "-DPython2_CROSSCOMPILING_EMULATOR=")
|
||||||
run_python(CrossCompiling-BOTH TYPE Python VARIANT Python.V2
|
run_python(CrossCompiling-BOTH TYPE Python VARIANT Python.V2
|
||||||
OPTIONS -DPython_REQUESTED_VERSION=2)
|
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()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -225,9 +235,19 @@ if(CMake_TEST_FindPython3_CPython)
|
|||||||
run_python(CrossCompiling-TARGET TYPE Python3 VARIANT Python3)
|
run_python(CrossCompiling-TARGET TYPE Python3 VARIANT Python3)
|
||||||
run_python(CrossCompiling-TARGET TYPE Python VARIANT Python.V3
|
run_python(CrossCompiling-TARGET TYPE Python VARIANT Python.V3
|
||||||
OPTIONS -DPython_REQUESTED_VERSION=3)
|
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)
|
||||||
|
run_python(CrossCompiling-BOTH TYPE Python3 VARIANT Python3.crossenv
|
||||||
|
OPTIONS "-DPython3_CROSSCOMPILING_EMULATOR=")
|
||||||
run_python(CrossCompiling-BOTH TYPE Python VARIANT Python.V3
|
run_python(CrossCompiling-BOTH TYPE Python VARIANT Python.V3
|
||||||
OPTIONS -DPython_REQUESTED_VERSION=3)
|
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()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user