diff --git a/cmake/dts.cmake b/cmake/dts.cmake index 0c9d990c804..f41e1aebd44 100644 --- a/cmake/dts.cmake +++ b/cmake/dts.cmake @@ -140,6 +140,7 @@ if(SUPPORTS_DTS) ${DTC_INCLUDE_FLAG_FOR_DTS} # include the DTS source and overlays ${NOSYSDEF_CFLAG} -D__DTS__ + ${DTS_EXTRA_CPPFLAGS} -P -E # Stop after preprocessing -MD # Generate a dependency file as a side-effect diff --git a/doc/application/index.rst b/doc/application/index.rst index d4965439a76..bac3044b5e0 100644 --- a/doc/application/index.rst +++ b/doc/application/index.rst @@ -783,6 +783,20 @@ You can also define the variable in the application :file:`CMakeLists.txt` file. Make sure to do so **before** pulling in the Zephyr boilerplate with ``find_package(Zephyr ...)``. +Devicetree source are passed through the C preprocessor, so you can +include files that can be located in a ``DTS_ROOT`` directory. By +convention devicetree include files have a ``.dtsi`` extension. + +You can also use the preprocessor to control the content of a devicetree +file, by specifying directives through the ``DTS_EXTRA_CPPFLAGS`` CMake +Cache variable: + +.. zephyr-app-commands:: + :tool: all + :board: + :gen-args: -DDTS_EXTRA_CPPFLAGS=-DTEST_ENABLE_FEATURE + :goals: build + :compact: Application Debugging *********************