CMake with IDF as library and custom kconfig

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

CMake with IDF as library and custom kconfig

Postby permal » Sat Dec 08, 2018 3:56 pm

Hi,

What's the correct way to make the CMake/IDF build system find kconfig-files when IDF is used as a library?

In my particular case, the project has the following structure:

Code: Select all

<root>
|-- CMakeLists.txt
|
|---- main
|         |-- CMakeLists.txt
|
|-- externals/smooth (this is a library that links against IDF via idf_import_components and idf_link_components)
      |-- CMakeLists.txt
      |-- kconfig (this file needs to be picked up by IDF to generate CONFIG_* in sdkconfig.h

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: CMake with IDF as library and custom kconfig

Postby ESP_igrr » Sun Dec 09, 2018 3:15 am

My understanding is that Kconfig files are only handled in components, and externals/smooth is not a component. What you might be able to do is to create one component (without any source files in it), add it to your project via EXTRA_COMPONENT_DIRS, and place Kconfig file into that component.

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

Re: CMake with IDF as library and custom kconfig

Postby permal » Sun Dec 09, 2018 9:52 am

Thanks Iggr.

Turns out to be easy; just set IDF_EXTRA_COMPONENT_DIRS before including idf_functions.cmake

Code: Select all

set(IDF_EXTRA_COMPONENT_DIRS "${IDF_EXTRA_COMPONENT_DIRS} ${CMAKE_CURRENT_LIST_DIR}/smooth_idf_component")
include($ENV{IDF_PATH}/tools/cmake/idf_functions.cmake)
idf_import_components(components $ENV{IDF_PATH} esp-idf)
idf_link_components(${PROJECT_NAME} "${components}")
Btw, the docs still refer to the variable as EXTRA_COMPONENT_DIRS, not IDF_...

Who is online

Users browsing this forum: Baidu [Spider] and 104 guests