Commit Graph

6 Commits

Author SHA1 Message Date
Torsten Rasmussen daac2d55ab cmake: move script mode handling from package helper to extensions.cmake
Move Zephyr CMake script mode handling from package_helper.cmake into
extensions.cmake.

This ensures that all Zephyr CMake script which includes
extensions.cmake will have the same functions stubbed or mocked and thus
does not need to replicate this behavior.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2024-10-08 17:00:30 +02:00
Torsten Rasmussen c7779bec8c cmake: stub zephyr_set(... SCOPE ...) function in package helper
Fixes: #63011

Custom targets are not available in script mode, which cause snippet
loading to fail when using package helper.

Lookup of snippets is supported by package helper, thus allowing twister
to filter test cases based on snippets.

However, loading of snippets itself is not supported as snippets make
use of Zephyr scoping, which uses custom targets, something that is not
available in script mode.

Therefore overload the `zephyr_set()` function, so that CMake package
helper can be used together with snippets.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-10-05 09:43:28 +01:00
Torsten Rasmussen ca76349d24 cmake: update package helper description to use EXTRA_CONF_FILE var
Update package_helper.cmake to use EXTRA_CONF_FILE instead of deprecated
OVERLAY_CONFIG variable.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-23 16:40:21 +02:00
Torsten Rasmussen 3a9b2a3e83 cmake: recommend CMake >=3.20.5 as minimum CMake version
CMake versions <3.20.5 contains the following bug:
https://gitlab.kitware.com/cmake/cmake/-/issues/22310

This bug was fixed in CMake 3.20.5:
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6232

Generally Zephyr can build with CMake >=3.20.0, however the
`cmake/package_helper.cmake` is impacted by the above issue.

Therefore, specifically request CMake >=3.20.5 for package helper
and update documentation to recommend CMake version 3.20.5 in order
to minimize risk of users being impacted by this bug.

Users invoking package helper with CMake 3.20.0-3.20.4 will see:
> CMake Error at cmake/package_helper.cmake:45 (cmake_minimum_required):
>  CMake 3.20.5 or higher is required.  You are running version 3.20.x

Rest of Zephyr still builds with CMake versions >=3.20.0.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-03-07 18:15:58 +01:00
Reto Schneider 7a6c5710ff cmake: Update cmake_minimum_required to 3.20.0
As Zephyr currently requires CMake version 3.20.0, update all
occurrences of cmake_minimum_required.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-07-04 10:18:45 +02:00
Torsten Rasmussen 117008331d cmake: package_helper CMake script
The Zephyr CMake package helper script allows to invoke Zephyr package
modules as they are invoked at configure time, up to the modules given
with `-DMODULES=<modules>`.
This allows to run the configure time part of the Zephyr build system
without generating a complete build system.

This means that for example devicetree module can be invoked for a given
sample and board to generate zephyr.dts identical to what is created
by the build system during a build.

To generate zephyr.dts for hello_world, invoke the script as:
$ cmake -DBOARD=<board> -B build -S samples/hello_world \
$       -DMODULES=dts -P <ZEPHYR_BASE>/cmake/package_helper.cmake

Other modules, for example 'kconfig' and 'zephyr_modules' can also be
invoked this way.

This will allow other tools, such as twister, to executed only a
subset of the build system like dts in order to do filtering before
determine if a complete build should be invoked.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-23 11:34:22 -08:00