zephyr/doc/getting_started/toolchain_custom_cmake.rst
Martí Bolívar 6e57b42758 doc: dts: revisit documentation
This is joint work with Kumar Gala (see signed-off-by).

Document the changes to the generated node macros in macros.bnf,
moving the old file to legacy-macros.bnf and putting it in its own
section.

The actual generated macros are now a low-level detail, so rewrite the
foregoing sections as examples in terms of the new <devicetree.h> APIs.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-24 10:11:20 -05:00

44 lines
1.7 KiB
ReStructuredText

.. _custom_cmake_toolchains:
Custom CMake Toolchains
#######################
To use a custom toolchain defined in an external CMake file, :ref:`set these
environment variables <env_vars>`:
- Set :envvar:`ZEPHYR_TOOLCHAIN_VARIANT` to your toolchain's name
- Set :envvar:`TOOLCHAIN_ROOT` to the path to the directory containing your
toolchain's CMake configuration files.
Zephyr will then include the toolchain cmake files located in the
:file:`TOOLCHAIN_ROOT` directory:
- :file:`cmake/toolchain/generic.cmake`: configures the toolchain for "generic"
use, which mostly means running the C preprocessor on :ref:`devicetree
input files <dt-input-files>`.
- :file:`cmake/toolchain/target.cmake`: configures the toolchain for "target"
use, i.e. building Zephyr and your application's source code.
See the zephyr files :zephyr_file:`cmake/generic_toolchain.cmake` and
:zephyr_file:`cmake/target_toolchain.cmake` for more details on what your
:file:`generic.cmake` and :file:`target.cmake` files should contain.
You can also set ``ZEPHYR_TOOLCHAIN_VARIANT`` and ``TOOLCHAIN_ROOT`` as CMake
variables when generating a build system for a Zephyr application, like so:
.. code-block:: console
west build ... -- -DZEPHYR_TOOLCHAIN_VARIANT=... -DTOOLCHAIN_ROOT=...
.. code-block:: console
cmake -DZEPHYR_TOOLCHAIN_VARIANT=... -DTOOLCHAIN_ROOT=...
If you do this, ``-C <initial-cache>`` `cmake option`_ may useful. If you save
your :makevar:`ZEPHYR_TOOLCHAIN_VARIANT`, :makevar:`TOOLCHAIN_ROOT`, and other
settings in a file named :file:`my-toolchain.cmake`, you can then invoke cmake
as ``cmake -C my-toolchain.cmake ...`` to save typing.
.. _cmake option:
https://cmake.org/cmake/help/latest/manual/cmake.1.html#options