diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-09-27 18:32:37 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-02-04 15:50:57 +0100 |
commit | 5d0fd24f0ff9289dba2d41a38a7054770c3a3eee (patch) | |
tree | 0e1963850c18812868286fa27d2c0ac947405d80 /sources/pyside-tools/cmake/PySideToolsSetup.cmake | |
parent | b69d0262e0262274a8f050f9b627e9ca4a3b1833 (diff) |
CMake: shiboken: Add support for cross-building
The shiboken project will be cross-compiled either if
CMAKE_CROSSCOMPILING is set to TRUE (which is usually set
by a CMake toolchain file or computed by CMake itself)
or if QFP_SHIBOKEN_HOST_PATH is provided on the command line.
Various code is added to ensure the correct target Qt and Python
libraries are found, as well as host Qt and Shiboken tools.
These are specified to the project by setting one of the following
vars:
- QFP_QT_TARGET_PATH (for device Qt libs and includes)
- QFP_PYTHON_TARGET_PATH (for device python libs and includes)
- QFP_SHIBOKEN_HOST_PATH (for host shiboken generator)
- QT_HOST_PATH (for host moc and friends)
To cross-compile the libraries, the project needs to find the host
Shiboken6Tools package (to use the host binding generator).
Any path specified in QFP_SHIBOKEN_HOST_PATH variable will be used to
search for that package.
When cross-compiling we now use the new FindPython CMake module in
shiboken_find_required_python instead of FindPythonInterp and
FindPythonLibs.
The old modules can't be used because they rely on executing the
python interpreter which can't be done if the host and target
platforms are different.
The new module instead internally relies on executing a python-config
shell script that is distributed with Python installations. This shell
script knows various details about the built Python and provides that
to the CMake module without having to run an executable of a different
architecture.
The CMake variables set by the new module have different names, so in
order not to modify too much build system code initially, we set the
old variable names with data from the new variables. This can
potentially be cleaned up in a follow up change.
The shiboken6 generator tool and its library dependency apiextractor
will not be built when cross-compiling (so there's no need to provide
a path to the LLVM libs).
Only the supporting libraries and python modules are built.
Tests are not built by default because running the target python
interpreter on a host machine will likely not work (different
platform / architecture). Support could potentially be added for
certain platforms so that the tests run via a user-space qemu.
Two new config tests are added to query information about the
target Qt and Python libraries. These will also be used by setup.py.
These will be used to extract necessary info instead of running
qmake / qtpaths / python because their arch is different from the
host one.
Just like with limited-api mode, when cross-compiling,
the signature embedding does not embed pre-compiled pyc files because
the host and python target can be of different versions.
PYTHON_WITH_COUNT_ALLOCS is always false when cross-compiling because
there's no way to query that information from the target python
installation without resorting to parsing certain files in a hacky
way.
Because we require a valid Python_SOABI value to be determined by
FindPython, we now require CMake version 3.17+ when cross-compiling.
We might be able to get rid of this requirement in the future at
the cost of some hacky code that could be difficult to maintain.
Task-number: PYSIDE-802
Task-number: PYSIDE-1033
Change-Id: I29a23b2d6366247090e55dd9176fbda7acdc29e8
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside-tools/cmake/PySideToolsSetup.cmake')
0 files changed, 0 insertions, 0 deletions