Chapter 4. API Guides
The example in build_system/cmake/idf_as_lib demonstrates the creation of an application equivalent to hello world
application using a custom CMake project.
4.4.21 ESP-IDF CMake Build System API
idf-build-commands
idf_build_get_property(var property [GENERATOR_EXPRESSION])
Retrieve a build property property and store it in var accessible from the current scope. Specifying GENERA-
TOR_EXPRESSION will retrieve the generator expression string for that property, instead of the actual value, which
can be used with CMake commands that support generator expressions.
idf_build_set_property(property val [APPEND])
Set a build property property with value val. Specifying APPEND will append the specified value to the current value
of the property. If the property does not previously exist or it is currently empty, the specified value becomes the first
element/member instead.
idf_build_component(component_dir)
Present a directory component_dir that contains a component to the build system. Relative paths are converted to ab-
solute paths with respect to current directory. All calls to this command must be performed before idf_build_process.
This command does not guarantee that the component will be processed during build (see the COMPONENTS argu-
ment description for idf_build_process)
idf_build_process(target
[PROJECT_DIR project_dir]
[PROJECT_VER project_ver]
[PROJECT_NAME project_name]
[SDKCONFIG sdkconfig]
[SDKCONFIG_DEFAULTS sdkconfig_defaults]
[BUILD_DIR build_dir]
[COMPONENTS component1 component2 ...])
Performs the bulk of the behind-the-scenes magic for including ESP-IDF components such as component configu-
ration, libraries creation, dependency expansion and resolution. Among these functions, perhaps the most important
from a user’s perspective is the libraries creation by calling each component’s idf_component_register.
This command creates the libraries for each component, which are accessible using aliases in the form
idf::component_name. These aliases can be used to link the components to the user’s own targets, either libraries
or executables.
The call requires the target chip to be specified with target argument. Optional arguments for the call include:
• PROJECT_DIR - directory of the project; defaults to CMAKE_SOURCE_DIR
• PROJECT_NAME - name of the project; defaults to CMAKE_PROJECT_NAME
• PROJECT_VER - version/revision of the project; defaults to “1”
• SDKCONFIG - output path of generated sdkconfig file; defaults to PROJECT_DIR/sdkconfig or
CMAKE_SOURCE_DIR/sdkconfig depending if PROJECT_DIR is set
• SDKCONFIG_DEFAULTS - list of files containing default config to use in the build (list must contain full
paths); defaults to empty. For each value filename in the list, the config from file filename.target, if it exists, is
also loaded.
• BUILD_DIR - directory to place ESP-IDF build-related artifacts, such as generated binaries, text files, com-
ponents; defaults to CMAKE_BINARY_DIR
• COMPONENTS - select components to process among the components known by the build system (added via
idf_build_component). This argument is used to trim the build. Other components are automatically added if
they are required in the dependency chain, i.e. the public and private requirements of the components in this
list are automatically added, and in turn the public and private requirements of those requirements, so on and
so forth. If not specified, all components known to the build system are processed.
Espressif Systems 1291
Submit Document Feedback
Release v4.4