@@ -140,8 +140,8 @@ As mentioned above, you can run sysbuild via ``west build`` or ``cmake``.
140
140
141
141
To use sysbuild directly with CMake, you must specify the sysbuild
142
142
project as the source folder, and give ``-DAPP_DIR=<path-to-sample> `` as
143
- an extra CMake argument. `` APP_DIR `` is the path to the main Zephyr
144
- application managed by sysbuild.
143
+ an extra CMake argument or set APP_DIR as environment variable.
144
+ `` APP_DIR `` is the path to the main Zephyr application managed by sysbuild.
145
145
146
146
.. tip ::
147
147
@@ -880,3 +880,57 @@ can be added.
880
880
:maxdepth: 1
881
881
882
882
images.rst
883
+
884
+ Sysbuild and CMake presets
885
+ **************************
886
+
887
+ `CMake presets <https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html >`_ can be used with
888
+ Sysbuild but not all preset macros will work as expected.
889
+
890
+ .. note ::
891
+
892
+ Using CMake presets with sysbuild requires CMake version 3.27 or higher.
893
+
894
+ As described in :ref: `sysbuild ` then sysbuild is a higher-level build system which means that when
895
+ CMake presets are used together with sysbuild, then the preset is consumed and processed by sysbuild
896
+ itself and result is passed to the application.
897
+
898
+ Running sysbuild with preset.
899
+
900
+ .. tabs ::
901
+
902
+ .. group-tab :: ``west build``
903
+
904
+ Here is an example where preset ``release `` should be used.
905
+ For details, see :ref: `west-multi-domain-builds ` in the ``west build documentation ``.
906
+
907
+ .. zephyr-app-commands ::
908
+ :tool: west
909
+ :zephyr-app: samples/hello_world
910
+ :board: reel_board
911
+ :goals: build
912
+ :west-args: --sysbuild -- --preset=release
913
+ :compact:
914
+
915
+ .. group-tab :: ``cmake``
916
+
917
+ Here is an example using CMake and Ninja.
918
+
919
+ .. code-block :: shell
920
+
921
+ APP_DIR=samples/hello_world cmake -Bbuild -GNinja -DBOARD=reel_board share/sysbuild
922
+ ninja -Cbuild
923
+
924
+ When using CMake presets with sysbuild then ``APP_DIR `` must be set in environment in order
925
+ for Sysbuild CMake to be able to include the ``CMakePresets.json `` from the main Zephyr
926
+ application's source directory.
927
+
928
+ .. note ::
929
+
930
+ As sysbuild changes the top-level cmake project to its own directory, the cmake presets are
931
+ parsed from there, the application's presets are included from this file verbatim.
932
+ Therefore relative paths, and macros resolving relative to the source directory will not work as
933
+ expected, but as relative to share/sysbuild, for example ``${sourceDir} ``.
934
+
935
+ The ``${fileDir} `` macro can be used to create portable paths relative to the application's
936
+ directory.
0 commit comments