Chapter 4. API Guides
Enumeration
This phase builds a final list of components to be processed in the build, and is performed in the first
half of idf_build_process().
• Retrieve each component’s public and private requirements. A child process is cre-
ated which executes each component’s CMakeLists.txt in script mode. The values
of idf_component_register REQUIRES and PRIV_REQUIRES argument is re-
turned to the parent build process. This is called early expansion. The variable
CMAKE_BUILD_EARLY_EXPANSION is defined during this step.
• Recursively include components based on public and private requirements.
Processing
This phase processes the components in the build, and is the second half of idf_build_process().
• Load project configuration from sdkconfig file and generate an sdkconfig.cmake and sdkconfig.h
header. These define configuration variables/macros that are accessible from the build scripts and
C/C++ source/header files, respectively.
• Include each component’s project_include.cmake.
• Add each component as a subdirectory, processing its CMakeLists.txt. The component CMake-
Lists.txt calls the registration command, idf_component_register which adds source files,
include directories, creates component library, links dependencies, etc.
Finalization
This phase is everything after idf_build_process().
• Create executable and link the component libraries to it.
• Generate project metadata files such as project_description.json and display relevant information
about the project built.
Browse /tools/cmake/project.cmake for more details.
4.4.25 Migrating from ESP-IDF GNU Make System
Some aspects of the CMake-based ESP-IDF build system are very similar to the older GNU Make-based system. The
developer needs to provide values the include directories, source files etc. There is a syntactical difference, however,
as the developer needs to pass these as arguments to the registration command, idf_component_register.
Automatic Conversion Tool
An automatic project conversion tool is available in /tools/cmake/convert_to_cmake.py. Run this command line tool
with the path to a project like this:
$IDF_PATH/tools/cmake/convert_to_cmake.py /path/to/project_dir
The project directory must contain a Makefile, and GNU Make (make) must be installed and available on the PATH.
The tool will convert the project Makefile and any component component.mk files to their equivalent CMake-
Lists.txt files.
It does so by running make to expand the ESP-IDF build system variables which are set by the build, and then
producing equivalent CMakelists files to set the same variables.
Important: When the conversion tool converts a component.mk file, it doesn’t determine what other com-
ponents that component depends on. This information needs to be added manually by editing the new component
Espressif Systems 1297
Submit Document Feedback
Release v4.4