https://github.com/jameswalmsley/cmake-kconfig
Minimal Kconfig cmake integration (Adapted from Zephyr RTOS).
https://github.com/jameswalmsley/cmake-kconfig
c cmake configuration configuration-management embedded kconfig
Last synced: about 1 month ago
JSON representation
Minimal Kconfig cmake integration (Adapted from Zephyr RTOS).
- Host: GitHub
- URL: https://github.com/jameswalmsley/cmake-kconfig
- Owner: jameswalmsley
- Created: 2020-02-18T23:32:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-08-30T05:56:36.000Z (over 1 year ago)
- Last Synced: 2025-04-02T04:23:25.438Z (about 2 months ago)
- Topics: c, cmake, configuration, configuration-management, embedded, kconfig
- Language: Python
- Size: 146 KB
- Stars: 56
- Watchers: 3
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cmake-kconfig
Minimal cmake project with kconfig integration adapted from Zephyr.
# Example
Default build using a provided configurations called `test`.
```
mkdir build
cd build
cmake -GNinja -DBOARD=test ..
ninja
```Note the above uses the config provided by:
```
configs/test_defconfig
```Updating the configuration:
```
ninja menuconfig
```This will bring up an interactive menu to turn options on/off and it will
save a .config file in the build directory.The test_defconfig can be updated by copying the build/.config file to
configs/test_defconfig and committing.Before any targets are built an autoconf.h header file is generated under:
```
build/kconfig/include/generate/autoconf.h
```This is allows everything to have a common configuration.
## Cmake
```
if(CONFIG_TEST_OPTION)
message("Config test_option is enabled")
endif()
```## Make
```
-include build/.configifeq ($(CONFIG_TEST_OPTION),y)
objs += src/test_option.o
endif
```## C/C++ ...
```
#include#ifdef CONFIG_TEST_OPTION
// Code built for option.
#endif
```
# KconfigKconfig is Brilliant! It manages a unified configuration separately from
the main source code that can be used with the build system and source code.It is the best-in-class configuration management tool that exists for embedded
C code, period.It allows dependencies to be defined between different config options.
And the best thing is, some really smart people have worked all this out before,
so we get a really powerful system for little effort/cost.