Re: [Zephyr-announce] Zephyr CMake package / find_package(Zephyr)

Carles Cufi
 

You need to be inside a zephyr tree (or pointing to it with ZEPHYR_BASE) that has #23054 merged in, so the latest upstream master will do. zephyr-export is implemented in the zephyr tree, not in west (i.e., it's an extension command).

-----Original Message-----
From: devel@... <devel@...> On
Behalf Of Kumar Gala via Lists.Zephyrproject.Org
Sent: 30 March 2020 16:19
To: Rasmussen, Torsten <Torsten.Rasmussen@...>
Cc: devel@...
Subject: Re: [Zephyr-devel] [Zephyr-announce] Zephyr CMake package /
find_package(Zephyr)

What version of west has 'zephyr-export’??

[galak@spiff zephyr]$ west -V
West version: v0.7.2
[galak@spiff zephyr]$ west zephyr-export
usage: west [-h] [-z ZEPHYR_BASE] [-v] [-V] <command> ...
west: error: argument <command>: invalid choice: 'zephyr-export' (choose
from 'init', 'update', 'list', 'manifest', 'diff', 'status', 'forall',
'help', 'config', 'topdir', 'selfupdate', 'completion', 'boards',
'build', 'sign', 'flash', 'debug', 'debugserver', 'attach’)- k

- k

On Mar 30, 2020, at 8:31 AM, Rasmussen, Torsten
<Torsten.Rasmussen@...> wrote:

Hi All,

A new way of including boilerplate code has been introduced with this
PR https://github.com/zephyrproject-rtos/zephyr/pull/23054

This means a simple Zephyr application now looks as:
# Find Zephyr. This also loads Zephyr's build system.
cmake_minimum_required(VERSION 3.13.1) find_package(Zephyr HINTS
$ENV{ZEPHYR_BASE})
project(my_zephyr_app)

This means that developers no longer need to set ZEPHYR_BASE in their
environment, but can let CMake find the Zephyr base using
find_package().

For this to work, it is necessary to execute a new west command: `west
zephyr-export` This command only needs to be executed once, for
example after a `west init`

All samples in Zephyr repository has been updated to use:
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})

To all downstream user having own Zephyr-based applications, you may
switch to the new find_package() method.

Note: this new feature is fully compatible with the old
`include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake)` design, but
if you keep using the old design, then it is still required to `source
zephyr-env.sh` or execute `zephyr-env.cmd`.

Using the new `find_package()` remove the need to `source zephyr-
env.sh`.

It is still possible to set the environment variable ZEPHYR_BASE, and
doing so will overwrite the CMake package search functionality in
Zephyr.

For more information on the new desgin, re-read the getting started
guide (as the latest docs has not yet been build, this is a ):
https://docs.zephyrproject.org/latest/getting_started/index.html
https://docs.zephyrproject.org/latest/guides/zephyr_cmake_package.html


Best regards

Torsten


Join devel@lists.zephyrproject.org to automatically receive all group messages.