Giter Club home page Giter Club logo

cmake-kconfig's Introduction

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/.config

ifeq ($(CONFIG_TEST_OPTION),y)
objs += src/test_option.o
endif

C/C++ ...

#include <autoconf.h>

#ifdef CONFIG_TEST_OPTION
// Code built for option.
#endif

Kconfig

Kconfig 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.

cmake-kconfig's People

Contributors

jameswalmsley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cmake-kconfig's Issues

Thans for your share

hi ,
I want to porting zephyr buildsys(docker+cmake+ninja+kconfig+clang_llvm or gcc) to my code.but i am new for it.your commit helped me a lot.
thanks

Lack APPLICATION_BINARY_DIR and APPLICATION_SOURCE_DIR

Thanks your porting at first. It help me a lot.

I found a little bug in it. I can't pass overlay config with relative path by -Doverlay_conf in CMake.

For example:

cmake -Bbuild -DBOARD=test -GNinja -DOVERLAY_CONFIG=overlay.conf

cmake will report error log.

CMake Error at cmake/kconfig.cmake:164 (message):
  File not found: /overlay.conf
Call Stack (most recent call first):
  cmake/top.cmake:24 (include)
  CMakeLists.txt:9 (include)

Then I found out the root issue. We lacked variable APPLICATION_BINARY_DIR and APPLICATION_SOURCE_DIR. They are defined in zephyr cmake zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake

I have create a PR to solve this issue: #2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.