Skip to content

Commit e08a7f5

Browse files
tejlmandgalak
authored andcommitted
doc: Zephyr build configuration CMake package freestanding
Update to the Zephyr build configuration CMake package documentation with description on how a Zephyr build configuration CMake package can be located outside a Zephyr workspace. Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent 489a69c commit e08a7f5

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

doc/guides/modules.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ Each project in the ``west list`` output is tested like this:
771771
- If neither of those checks succeed, the project is not considered a module,
772772
and is not added to :makevar:`ZEPHYR_MODULES`.
773773

774+
.. _modules_without_west:
775+
774776
Without West
775777
------------
776778

doc/guides/zephyr_cmake_package.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ In this example ``my_first_app`` is a Zephyr workspace application.
125125
installed using ``west``
126126

127127

128+
.. _freestanding_application:
129+
128130
Zephyr freestanding application
129131
===============================
130132

@@ -453,6 +455,48 @@ A sample ``ZephyrBuildConfig.cmake`` can be seen below.
453455
endif()
454456
endif()
455457
458+
Zephyr Build Configuration CMake package (Freestanding application)
459+
*******************************************************************
460+
461+
The Zephyr Build Configuration CMake package can be located outside a Zephyr
462+
workspace, for example located with a :ref:`freestanding_application`.
463+
464+
Create the build configuration as described in the previous section, and then
465+
refer to the location of your Zephyr Build Configuration CMake package using
466+
the CMake variable ``ZephyrBuildConfiguration_ROOT``.
467+
468+
#. At the CMake command line, like this:
469+
470+
.. code-block:: console
471+
472+
cmake -DZephyrBuildConfiguration_ROOT=<path-to-build-config> ...
473+
474+
#. At the top of your application's top level :file:`CMakeLists.txt`, like this:
475+
476+
.. code-block:: cmake
477+
478+
set(ZephyrBuildConfiguration_ROOT <path-to-build-config>)
479+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
480+
481+
If you choose this option, make sure to set the variable **before** calling
482+
``find_package(Zephyr ...)``, as shown above.
483+
484+
#. In a separate CMake script which is pre-loaded to populate the CMake cache,
485+
like this:
486+
487+
.. code-block:: cmake
488+
489+
# Put this in a file with a name like "zephyr-settings.cmake"
490+
set(ZephyrBuildConfiguration_ROOT <path-to-build-config>
491+
CACHE STRING "pre-cached build config"
492+
)
493+
494+
You can tell the build system to use this file by adding ``-C
495+
zephyr-settings.cmake`` to your CMake command line.
496+
This principle is useful when not using ``west`` as both this setting and
497+
Zephyr modules can be specified using the same file.
498+
See Zephyr module :ref:`modules_without_west`.
499+
456500
Zephyr CMake package source code
457501
********************************
458502

0 commit comments

Comments
 (0)