Commit Graph

7 Commits

Author SHA1 Message Date
Grzegorz Swiderski 9d1b361265 cmake: Require Python >= 3.10
The minimum Python version was bumped for Zephyr LTSv3, but only in the
documentation and CI. The build system would still accept Python 3.8,
yet some scripts in tree have already broken support with that version.
Incompatibility errors should be prevented early.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2024-09-23 10:01:20 +02:00
Tom Burdick 8c4c180575 cmake: Fix finding python in virtualenv
When running cmake directly (without west, as twister does) on nix the
CMake environment paths are set and thus it does not find the
virtualenv'ed python. Fix this by ignoring the cmake environment
variables nix sets.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-09-11 14:00:44 -04:00
Torsten Rasmussen 207da52e8e cmake: find python path adjustment
Fixes: #70258

Specify NO_CMAKE_PATH to prevent CMake find_program from having a
preference for searching CMAKE_PREFIX_PATH.

Some tool like NixOS / Nix package manager sets this variable
to point inside the nix store, like this:
CMAKE_PREFIX_PATH=/nix/store/gpvnsgf8zhqjjgk63dd...-python3-3.11.6-env

thus causing `find_program()` to prefer this over the tool in the
default path.

Support Nix environments by specifying NO_CMAKE_PATH and in addition
support `VIRTUAL_ENV` environment setting for search path when set by
the virtual environment.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2024-05-24 18:04:28 -04:00
Marc Herbert 13df15845e cmake: drop ERROR_QUIET in python.cmake
ERROR_QUIET should be used only when the command is actually expected to
fail, otherwise discarding stderr can be extremely time-consuming. See
recent example of time lost in commit 40c2e08e82 ("xcc/cmake: don't
discard stderr; don't (ever!) use ERROR_QUIET")

If some Python interpreter cannot even evaluate `sys.version_info[:2]`,
then we definitely don't want to hide what its stderr says about that.

Fixes commit 94de3e9f60 ("cmake: FindPython3: Adjust python3 program
search")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-12-13 13:56:59 +01:00
Torsten Rasmussen 40d85ebcc5 cmake: python module cleanup.
CMake 3.16 find_python3 module introduced `Python3_EXECUTABLE` as
artifact specifier.
This allows Zephyr to cleanup its Python detection mechanism and thus
remove the Zephyr specific `PYTHON_PREFER` variable, which is now
deprecated.

This further improves the Python detection mechanism in Zephyr as it
allows users to specify Python3_EXECUTABLE and thereby follows CMake
documentation.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-08-21 13:21:52 +02:00
Carles Cufi 33211b3fb4 cmake: Bump the minimum required Python version to 3.8
Given that 3.6 is now several years old and the current and previous
Ubuntu LTS ship with 3.8 or later, upgrade the minimum required Python
version from 3.6 to 3.8.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-24 18:35:57 +02:00
Torsten Rasmussen 61453e4a58 cmake: Zephyr CMake package and CMake modules
Create a cmake/modules folder containing all Zephyr CMake modules.
All Zephyr cmake files that are included from boilerplate are now
converted into CMake modules which can be individually loaded.

The Zephyr CMake package is updated to support loading of individual
CMake modules using the COMPONENTS argument to `find_package(Zephyr)`.
If the COMPONENTS argument is not specified, the default Zephyr build
system will load.
If COMPONENTS is specified then, only those components and the
dependencies will be loaded.

If a Zephyr CMake module depends on another CMake module which has not
been loaded, it will automatically be loaded.

This allows us to modularize and reuse individual parts of the Zephyr
CMake build system in a more flexible way in future.

Such usage could be:
- Higher livel multi image build system
- Invocation of individual components, for example dts processing by
  twister without loading all build code
- Doc build
- Unittesting

With this new CMake package and CMake module scheme then direct
sourcing of boilerplate.cmake has been deprecated.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00