Debugging Cmake; Example Component Cmakelists - Espressif ESP32-S2 Programming Manual

Table of Contents

Advertisement

Chapter 4. API Guides

4.4.11 Debugging CMake

For full details about
CMake
Some tips for debugging the ESP-IDF CMake-based build system:
• When CMake runs, it prints quite a lot of diagnostic information including lists of components and component
paths.
• Running cmake -DDEBUG=1 will produce more verbose diagnostic output from the IDF build system.
• Running cmake with the --trace or --trace-expand options will give a lot of information about
control flow. See the
When included from a project CMakeLists file, the project.cmake file defines some utility modules and global
variables and then sets IDF_PATH if it was not set in the system environment.
It also defines an overridden custom version of the built-in
to add all of the ESP-IDF specific project functionality.
Warning On Undefined Variables
By default, idf.py passes the --warn-uninitialized flag to
variable is referenced in the build. This can be very useful to find buggy CMake files.
If you don't want this behaviour, it can be disabled by passing --no-warnings to idf.py.
Browse the
/tools/cmake/project.cmake

4.4.12 Example Component CMakeLists

Because the build environment tries to set reasonable defaults that will work most of the time, component CMake-
Lists.txt can be very small or even empty (see
variables
is usually required for some functionality.
Here are some more advanced examples of component CMakeLists files.
Adding conditional configuration
The configuration system can be used to conditionally compile some files depending on the options selected in the
project configuration.
Kconfig:
config FOO_ENABLE_BAR
bool "Enable the BAR feature."
help
This enables the BAR feature of the FOO component.
CMakeLists.txt:
set(srcs "foo.c" "more_foo.c")
if(CONFIG_FOO_ENABLE_BAR)
list(APPEND srcs "bar.c")
endif()
idf_component_register(SRCS "${srcs}"
This example makes use of the CMake
This can also be used to select or stub out an implementation, as such:
Espressif Systems
and CMake commands, see the
cmake command line
documentation.
file and supporting functions in
Minimal Component
...)
if
function and
Submit Document Feedback
CMake v3.5
documentation.
CMake
project function. This function is overridden
CMake
so it will print a warning if an undefined
/tools/cmake/
CMakeLists). However, overriding
list APPEND
function.
1283
for more details.
component
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Table of Contents

Save PDF