cmake: Re-direct KCONFIG_ROOT when convention is used
Automatically detect the Kconfig file in it's conventional placement ${APPLICATION_SOURCE_DIR}/Kconfig and set KCONFIG_ROOT accordingly. 'Convention over configuration' is an imporant principle for minimizing metadata and keeping things consistent. We use this principle for instance with the file prj.conf. This commit applies this principle to also re-direrct KCONFIG_ROOT. Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit is contained in:
parent
3c834bdf27
commit
89a197be84
2 changed files with 16 additions and 10 deletions
|
@ -4,7 +4,14 @@ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/kconfig/include/generated)
|
|||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/kconfig/include/config)
|
||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/generated)
|
||||
|
||||
set_ifndef(KCONFIG_ROOT ${ZEPHYR_BASE}/Kconfig)
|
||||
if(KCONFIG_ROOT)
|
||||
# KCONFIG_ROOT has either been specified as a CMake variable or is
|
||||
# already in the CMakeCache.txt. This has precedence.
|
||||
elseif(EXISTS ${APPLICATION_SOURCE_DIR}/Kconfig)
|
||||
set(KCONFIG_ROOT ${APPLICATION_SOURCE_DIR}/Kconfig)
|
||||
else()
|
||||
set(KCONFIG_ROOT ${ZEPHYR_BASE}/Kconfig)
|
||||
endif()
|
||||
|
||||
set(BOARD_DEFCONFIG ${BOARD_DIR}/${BOARD}_defconfig)
|
||||
set(DOTCONFIG ${PROJECT_BINARY_DIR}/.config)
|
||||
|
|
|
@ -853,8 +853,9 @@ Make sure to follow these steps in order.
|
|||
|
||||
More details are available below in :ref:`application_dt`.
|
||||
|
||||
#. If your application has its own kernel configuration options, add a
|
||||
line setting the location of the Kconfig file that defines them.
|
||||
#. If your application has its own kernel configuration options,
|
||||
create a :file:`Kconfig` file in the same directory as your
|
||||
application's :file:`CMakeLists.txt`.
|
||||
|
||||
An (unlikely) advanced use case would be if your application has its own
|
||||
unique configuration **options** that are set differently depending on the
|
||||
|
@ -863,13 +864,6 @@ Make sure to follow these steps in order.
|
|||
If you just want to set application specific **values** for existing Zephyr
|
||||
configuration options, refer to the :makevar:`CONF_FILE` description above.
|
||||
|
||||
For example, if you have a file named :file:`Kconfig` in the same directory
|
||||
as your application's :file:`CMakeLists.txt`, add the following line:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
set(KCONFIG_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/Kconfig)
|
||||
|
||||
Structure your :file:`Kconfig` file like this:
|
||||
|
||||
.. literalinclude:: application-kconfig.include
|
||||
|
@ -884,6 +878,11 @@ Make sure to follow these steps in order.
|
|||
See the :ref:`kconfig_extensions` section in the
|
||||
:ref:`board_porting_guide` for more information.
|
||||
|
||||
The :file:`Kconfig` file is automatically detected when placed in
|
||||
the application directory, but it is also possible for it to be
|
||||
found elsewhere if the CMake variable :makevar:`KCONFIG_ROOT` is
|
||||
set with an absolute path.
|
||||
|
||||
#. Now include the mandatory boilerplate that integrates the
|
||||
application with the Zephyr build system on a new line, **after any
|
||||
lines added from the steps above**:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue