I would like to use Kconfig to manage application-specific configuration.
An example of what I want to achieve:
/* main.c */ #ifdef CONFIG_MYAPP_DO_THING DoTheThing(); #endif /* prj.conf */ CONFIG_MYAPP_DO_THING=y
At the moment I am achieving this in a way that feels rather convoluted, and I am thinking that there is probably a cleaner way, but I cannot think of it.
This is what I am doing (my application is out-of-tree):
- the root of my repo has a Kconfig.app file that defines the options available, e.g:
menuconfig MYAPP bool "My Application" default y help My Application configuration if MYAPP config MYAPP_DO_THING bool "Enable doing the thing" endif #MYAPP
- the root of my repo has a zephyr/module.yml file:
build: cmake: . kconfig: Kconfig.app
- the root of my repo has CMakeLists.txt that includes the following snippet:
# bring in modules (by telling the Zephyr build system where to look for a zephyr/modules.yml ) set(ZEPHYR_EXTRA_MODULES ${CMAKE_CURRENT_LIST_DIR})
This makes my whole app look like a module to the Zephyr build system.
It seems like using Kconfig for your own application config would be the natural/idiomatic thing to do, so I would be surprised if there wasn't a simpler way to define custom KConfig options at the app level (e.g. a special name for a Kconfig file in the root that is implicitly brought in the build?), but I have not found it.
Is there something less convoluted I could do?