Commit Graph

193 Commits

Author SHA1 Message Date
Sudeep Mohanty
b0d75e86fe test(cmakev2): Remove old cmakev2/test directory, now replaced by buildv2 pytest suite
Made-with: Cursor
2026-03-18 09:27:51 +01:00
Frantisek Hrbata
aad1f9845b fix(cmakev2/project): export build properties as variables for project_include.cmake
In cmake v1, __build_process_project_includes() exports all build
properties as CMake variables before including project_include.cmake
files. cmakev2 was missing this step, causing components like ULP that
reference build properties as CMake variables (e.g. ${SDKCONFIG_HEADER})
to receive empty values.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-03-11 15:44:30 +08:00
Frantisek Hrbata
f17f80bfdd fix(cmakev2/kconfig): add public aliases for sdkconfig output properties
The cmakev2 kconfig module sets sdkconfig output paths using internal
property names (__SDKCONFIG_HEADER, __SDKCONFIG_CMAKE, etc.), but
components like ULP read the public names (SDKCONFIG_HEADER,
SDKCONFIG_CMAKE). This results in empty values being passed to the ULP
sub-project, causing its CMake configure step to fail.

Add public aliases matching the cmake v1 property names for backward
compatibility.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-03-11 15:44:30 +08:00
Sudeep Mohanty
f98df52a0f Merge branch 'feat/buildv2_comp_opt_requires' into 'master'
fix(cmakev2): Defer idf_component_optional_requires linking to library build time

See merge request espressif/esp-idf!46059
2026-03-09 12:12:12 +01:00
Sudeep Mohanty
7f7f40404b Merge branch 'feat/buildv2_component_cb_framework' into 'master'
feat(cmakev2): Add build event callback framework for components

See merge request espressif/esp-idf!46018
2026-03-04 15:12:53 +01:00
Sudeep Mohanty
45dc2e5868 fix(cmakev2): Defer idf_component_optional_requires linking to library build time
This commit introduces a new build property, __OPTIONAL_REQUIRES_MODE,
and uses it to either defer or link immediately, optional requirements
to components that request such linkage via the
idf_component_optional_requires() function in build system v2. The
DEFERRED mode is intended for single-binary projects where in the linking
of optional components happens after the library target is created the
dependency graph is available to the build system, thereby allowing it to
behave like the v1 version of the function.

Made-with: Cursor
2026-03-04 15:09:15 +01:00
Sudeep Mohanty
a8423cf751 Merge branch 'feat/buildv2_examples' into 'master'
feat(cmakev2): Added cmakev2 examples

Closes IDF-13070, IDF-14185, and IDF-15153

See merge request espressif/esp-idf!45400
2026-02-25 13:58:27 +01:00
Frantisek Hrbata
bb1d3802a2 Merge branch 'fix/cmakev2_embed_files' into 'master'
fix(cmakev2): fix embedded file source generation

See merge request espressif/esp-idf!45738
2026-02-25 03:44:30 +01:00
Sudeep Mohanty
678b4955fd feat(cmakev2): Add build event callback framework for components
Introduce a callback mechanism that lets components register CMake
functions to be called at specific points in the build lifecycle.

Currently, this framework only supports registering callbacks to be
called after the executable target is created, i.e, the POST_ELF phase
of the build but before the binary target is created.
2026-02-24 15:17:08 +01:00
Sudeep Mohanty
454b944b76 feat(cmakev2): add idf_build_get_compile_options and use in compat and component
Add idf_build_get_compile_options() to aggregate COMPILE_OPTIONS,
C_COMPILE_OPTIONS, CXX_COMPILE_OPTIONS, and ASM_COMPILE_OPTIONS build
properties with generator expressions. Replace internal
__get_compile_options(OUTPUT ...) usage in idf_component_register and
idf_component_include with the new public function.
2026-02-24 11:21:19 +01:00
Sudeep Mohanty
6a878eb0bf fix(cmakev2): add --cref with MAPFILE_TARGET and remove global -Wl,--cref
When MAPFILE_TARGET is used in idf_build_executable, add the linker
--cref option so the cross-reference table is written to the map file
instead of stdout. Remove the global -Wl,--cref from default link
options in project.cmake so cref is only applied where a map file
is requested.
2026-02-24 11:21:19 +01:00
Roland Dobai
7a6405e824 Merge branch 'fix/cmakev2_ai_preserve_sdkconfig_managed_component_options' into 'master'
fix(cmakev2/kconfig): preserve sdkconfig options from managed components

Closes IDF-15347

See merge request espressif/esp-idf!45944
2026-02-24 10:46:22 +01:00
Frantisek Hrbata
0f349ee404 fix(cmakev2/kconfig): preserve sdkconfig options from managed components
The sdkconfig file may contain configuration options defined in Kconfig
files of managed components. Since kconfgen runs before the component
manager fetches these components, the Kconfig definitions for managed
component options are not yet available. The kconfgen --output config
flag regenerates sdkconfig from kconfiglib's internal state, which only
knows about options with loaded Kconfig definitions. This causes unknown
options (i.e., those from managed components) to be silently dropped
from sdkconfig during intermediate regeneration rounds.

Note that kconfgen's --config flag (used for reading sdkconfig) only
performs deprecated option name replacement and does NOT drop unknown
options. The problem is exclusively in --output config, which writes a
fresh sdkconfig from the parsed Kconfig tree state.

Fix this by introducing a __SDKCONFIG_ORIG build property that provides
an indirection layer for the --config input path:

- Before the component manager runs: __SDKCONFIG_ORIG points to a copy
  of the original sdkconfig (build/sdkconfig.orig), created by the new
  __create_sdkconfig_orig_copy() function. This copy preserves all
  original options, including those from managed components.

- During intermediate kconfgen runs: --config reads from the preserved
  copy (so unknown options survive as input), while --output config
  writes to the real sdkconfig (unknown options may be dropped there,
  but this is harmless since kconfgen always reads from the copy).

- After the component manager completes: __SDKCONFIG_ORIG is reset to
  point to the real sdkconfig and __BASE_KCONFGEN_CMD is rebuilt, so
  that subsequent operations (menuconfig, save-defconfig, confserver)
  read and write the actual sdkconfig file directly.

The flow is:

  __create_sdkconfig_orig_copy()
    -> __SDKCONFIG_ORIG = build/sdkconfig.orig

  __generate_sdkconfig()
    -> --config build/sdkconfig.orig --output config project/sdkconfig

  __fetch_components_from_registry():
    loop:
      download_components()
      __generate_sdkconfig()
        -> --config build/sdkconfig.orig --output config project/sdkconfig
      if success: break
    endloop
    -> __SDKCONFIG_ORIG = project/sdkconfig
    -> rebuild __BASE_KCONFGEN_CMD

  idf_create_menuconfig() / save-defconfig / confserver
    -> uses --config project/sdkconfig (the real file)

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-02-18 17:29:18 +08:00
Jan Beran
86020e9732 feat(cmakev2): add config-report target 2026-02-18 16:23:37 +08:00
Frantisek Hrbata
5dac2fee69 Merge branch 'fix/cmakev2_idf_component_optional_requires' into 'master'
fix(cmakev2/compat): change idf_component_optional_requires behavior

Closes IDFGH-17112

See merge request espressif/esp-idf!45588
2026-02-12 08:50:24 +01:00
Frantisek Hrbata
f62f45cf5c fix(cmakev2/utilities): add a dependency target for the embedded file
Currently, embedded files can be added in two ways. First, by calling
the `target_add_binary_data` function directly within a component.
Second, by passing `EMBED_FILES` or `EMBED_TXTFILES` to
`idf_component_register`, or in cmakev2 by setting the `EMBED_FILES` or
`EMBED_TXTFILES` component properties.

The source file for an embedded file is generated using
`add_custom_command`. When the embedded file is added directly in the
component's CMakeLists.txt file by using the `target_add_binary_data`
function, the `add_custom_command` command is evaluated in the same
directory context where the component target is created. As a result,
the generated embedded file can be used automatically as a file
dependency in component's sources.

However, when an embedded file is added via `idf_component_register` or
by setting the component property, the call to `add_custom_command`
inside `target_add_binary_data` occurs after the component has been
evaluated, specifically after the `add_subdirectory` call, within
`idf_component_include`. This means it is not created in the same
directory context as the component's target. In this case, the embedded
file dependency is not added to the component's target, and the embedded
file is not generated. This behavior is described in the
`add_custom_command` documentation [1].

   > A target created in the same directory (CMakeLists.txt file)
   > that specifies any output of the custom command as a source
   > file is given a rule to generate the file using the command at
   > build time.

To fix this issue, an explicit custom target for the generated embedded
file is created and added as a dependency of the component's target,
ensuring that the file is generated correctly.

[1] - https://cmake.org/cmake/help/latest/command/add_custom_command.html

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-02-10 03:36:58 +08:00
Frantisek Hrbata
e1eae669bc fix(cmakev2/compat): change idf_component_optional_requires behavior
The idf_component_optional_requires compatibility function in cmakev2
currently attempts to mimic the behavior of cmakev1 by adding a
dependency only if a component is already included in the build. In
cmakev1, this is handled by checking the BUILD_COMPONENTS list, which is
created during an early evaluation phase. Because cmakev2 removed this
early phase to allow for configuration-based component dependencies, the
build system does not inherently know which components will be part of
the build beforehand. To compensate, the current compatibility function
relies on the TARGET_EXISTS generator expression to determine if a
component should be linked.

This approach poses a problem because generator expressions are not
evaluated until the generation phase, but cmakev2 processes linker
scripts during the configuration phase by recursively scanning targets
linked to a library. Because the scanner does not recognize and cannot
evaluate generator expressions, any component linked optionally through
generator expression is skipped. If that component carries a linker
script, the script is never added to the library interface, resulting in
build failures. Since cmakev2 aims to support multiple libraries, a
component might also exist globally, causing TARGET_EXISTS to evaluate
to true, yet still be missed during a specific library's recursive scan,
leading to the same omission of necessary linker scripts.

To resolve this, the implementation of idf_component_optional_requires
is changed to check if a component is known to the build system in
COMPONENTS_DISCOVERED build property. If so, it is explicitly included
and linked directly via its interface target. While this may pull more
components into a build than the previous generator expression method,
potentially increasing build times, it ensures that dependency trees are
fully visible to the library target scanner. This serves as a practical
middle ground that maintains compatibility with existing components and
ensures build stability. This approach allows for the gradual fixing of
idf_component_optional_requires usage in components for cmakev2, with
the eventual goal of removing its usage in cmakev2 entirely.

This change also fixes cases where idf_component_optional_requires is
used to conditionally add requirements based on configuration options.
In cmakev2, the presence of a configuration option does not guarantee[1]
that a component has been included via add_subdirectory, unlike the
behavior in cmakev1. With this change even constructions like

```cmake
if(CONFIG_VFS_SUPPORT_IO)
    idf_component_optional_requires(PRIVATE vfs)
endif()
```

will now work in cmakev2, as the updated idf_component_optional_requires
explicitly includes the required component if it is available to the
build system.

Closes https://github.com/espressif/esp-idf/issues/18133

[1] https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system-v2.html#id9

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-02-04 09:28:35 +01:00
Frantisek Hrbata
ce73a1fd8e fix(cmakev2/build): extend idf_build_generate_metadata to also accept executable
Currently, idf_build_generate_metadata only accepts binary targets for
which it generates metadata (project_description.json). On Linux
targets, binary images are not generated, but we still need to generate
project_description.json. Extend the current function to accept both
executable and binary targets and ensure project_description.json is
generated when a Linux target is used.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-01-22 15:41:05 +01:00
Frantisek Hrbata
fc5e7eb22d fix(cmakev2/compat): display empty components as excluded into menuconfig
Some components simply return when included in a build for the Linux
target. This is silently ignored in the `idf_component_include`, and the
component interface target is linked as requirement in
`idf_component_register`. This has the side
effect of such components being reported as included, with their
configuration displayed in the menuconfig for included components,
rather than in the submenu for excluded components. For example, the
`bt` component, if added as a dependency in `idf_component_register`,
will be displayed in menuconfig as an included component for Linux
target. The `idf_component_include` function sets the component's
`COMPONENT_REAL_TARGET` property to `NOTFOUND` in such situations. Use
this information when config.env is generated put such components into
excluded submenu. Note that we cannot avoid linking empty component interface
into library, because there might be recursive dependencies and at the
time when the component is included we might not now if it has a real
target or not.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-01-21 16:48:44 +01:00
Frantisek Hrbata
0a865c6e09 fix(cmakev2/project): generate binaries only if esptool_py component is present
Currently, the CONFIG_APP_BUILD_GENERATE_BINARIES option is used to
determine whether binary images will be generated in
idf_project_default. At present, this option is enabled even for the
Linux target, where the esptool_py component is not included, preventing
the generation of binary images. To address this issue, verify if the
target for esptool_py is present.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-01-21 16:48:44 +01:00
Frantisek Hrbata
029c4135ee fix(cmakev2/idf): fix IDF_TOOLCHAIN build property for linux target
The IDF_TOOLCHAIN build property is currently incorrectly set to the
default `gcc` value for the linux target, whereas it should be empty.
This misconfiguration causes confusion for components like `soc`, which
adjust toolchain options based on the
IDF_TOOLCHAIN(CONFIG_IDF_TOOLCHAIN_GCC) build property's setting.

When sdkconfig is generated, the IDF_TOOLCHAIN build property is passed
as an environmental variable to kconfgen, and the CONFIG_IDF_TOOLCHAIN
configuration option is set based on this variable. Additionally, the
CONFIG_IDF_TOOLCHAIN_GCC and CONFIG_IDF_TOOLCHAIN_CLANG configuration
options are set accordingly. Subsequently, CONFIG_IDF_TOOLCHAIN_GCC is
used in several places, such as `components/soc/project_include.cmake`,
to configure the toolchain (compiler flags) by invoking functions from
`tools/cmake/toolchain_flags.cmake`, which is included only for
non-linux targets. As a result the configuration fails, because
functions from `tools/cmake/toolchain_flags.cmake` are not available on
linux target.

Since the IDF_TOOLCHAIN cmake cache variable is actually set in the
`tools/cmake/toolchain.cmake` file, the IDF_TOOLCHAIN build property
should be set after the toolchain is initialized in cmakev2's project
initialization. Note that each toolchain file, except for linux,
includes `toolchain.cmake`, which in turn includes
`toolchain_flags.cmake`. This means the IDF_TOOLCHAIN cmake cache
variable is set for every target except linux, because the toolchain
file for linux is empty. As a result CONFIG_IDF_TOOLCHAIN is empty and
CONFIG_IDF_TOOLCHAIN_GCC not set as for cmakev1.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-01-21 16:48:44 +01:00
Frantisek Hrbata
26f2961696 fix(cmakev2/component): use component interface in dependency chain
The dependency chain currently tracks component names that are included
recursively with `idf_component_include`. However, these component names
can be ambiguous because a component may be referenced by different
names, such as with a namespace. Additionally, `idf_component_include`
can accept anything that `__get_component_interface` accepts, meaning
even the component interface target can be used to include the component
in the build. To uniquely identify each component, use component
interface targets instead of names in the dependency chain.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-01-21 16:48:44 +01:00
Frantisek Hrbata
0f4ec41421 fix(cmakev2/component): use __idf_component_get_property_unchecked
In some instances, the COMPONENTS_DISCOVERED build property is used to
walk through the component list and obtain component properties, such as
during configuration preparation or the inclusion of project_include
files. Since we know the component interfaces from the
COMPONENT_INTERFACES build property, we can switch to the faster
`__idf_component_get_property_unchecked` method to obtain component properties
in these cases. This change reduces the reconfiguration time by 0.4
seconds on my computer.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-01-13 16:49:12 +01:00
Frantisek Hrbata
368b90245b fix(cmakev2/component_validation): accelerate component validation
The commit f951ae5b18 ("feat(cmakev2): Added component validation
checks for ...") introduced support for validating component sources and
include directories. It heavily relies on iterating through the
registered components to obtain their properties. For instance, it
examines all components for each component source file to ensure that
the source files do not originate from other components. However, it
turns out that `idf_component_get_property` is a bottleneck in this
process, causing reconfiguration to take 3-4 times longer than before
the introduction of this check. Since we know of all the component
interfaces, we can bypass the checks performed by
`idf_component_get_property` and instead use the raw version,
`__idf_component_get_property_unchecked`, which operates much faster.

Following are hello_world example reconfigure times before and after.

before:

-- Configuring done (11.1s)
-- Generating done (0.2s)

after:

-- Configuring done (3.9s)
-- Generating done (0.2s)

A new library property LIBRARY_COMPONENT_INTERFACES_LINKED is added that
keeps component interfaces linked to the library.

Fixes: f951ae5b18 ("feat(cmakev2): Added component validation checks for ..")
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-01-13 16:47:25 +01:00
Frantisek Hrbata
d01979e3d8 feat(cmakev2): introduce __idf_component_get_property_unchecked helper
Retrieve the value of the specified component property quickly. The
existing `idf_component_get_property` function performs various checks
to identify the component interface target, which keeps the component
properties, and accepts a component name, target, target alias, or
interface. While `idf_component_get_property` uses a cache to identify
the component interface relatively quickly, it is still much slower
compared to the raw `get_property`. The
`__idf_component_get_property_unchecked` function provides a faster way how to
obtain component property if the component interface is already known.
It skips all the checks, so it must be used carefully.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-01-13 16:45:01 +01:00
Sudeep Mohanty
ff2fac5581 fix(cmakev2): Remove redundant picolibc flags from project.cmake
This commit removes picolibc flags from project.cmake file since they
are added by the esp_libc component when project_include.cmake files are
evaluated.
2025-12-23 13:22:15 +01:00
Sudeep Mohanty
9855054929 fix(cmakev2): Fix the order of project initialization in cmakev2
This commit moves the project initialization by moving the
__init_project_configuration() after the sdkconfig is generated and
included. This is because __init_project_configuration() depends on
config options.
2025-12-23 13:20:24 +01:00
Sudeep Mohanty
f951ae5b18 feat(cmakev2): Added component validation checks for cmakev2
This commit adds component validation checks for cmakev2. The file
component_validation.cmake is ported to cmakev2 and updated to work in
the buildv2 environment.
2025-12-18 13:54:13 +01:00
Sudeep Mohanty
d671bf70ee fix(cmakev2): Correctly set SRCS property for cmakev2 components
The function __set_component_cmakev1_properties() sets cmakev1
properties for cmakev2 components to maintain backword copatibility.
However, the function was setting SOURCES property instead of SRCS
property as was intended.
2025-12-18 10:37:49 +01:00
Frantisek Hrbata
261856e02c feat(cmakev2/build): add idf_build_generate_depgraph function
The idf_build_generate_depgraph function creates a component dependency
graph in dot (graphviz) format for a specified executable. It uses
existing helper functions from cmakev1, ensuring that the generated dot
files are produced in the same manner as in cmakev1. While adjustments
might be needed in the future if necessary, the current implementation
is intended to offer the same functionality as cmakev1.  Similar to
cmakev1, the dot files are only generated only when the
__BUILD_COMPONENT_DEPGRAPH_ENABLED build property is set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-12-11 14:00:55 +08:00
Daniel Paul
b12c0e35f4 feat(cmakev2): Add source of the component into project_description.json 2025-12-03 19:58:47 +08:00
Roland Dobai
b60860eb7e Merge branch 'fix/cmakev2_unnecessary_config_generation' into 'master'
fix(cmakev2/kconfig): avoid unnecessary sdkconfig generation

Closes IDF-14431

See merge request espressif/esp-idf!43663
2025-11-26 13:32:12 +01:00
Frantisek Hrbata
ca3974c937 feat(cmakev2/ldgen): provide ldgen with a list of mutable libraries
The build system keeps track of each component source. Currently
there are four types of sources:

1. "project_components" - project components
2. "project_extra_components" - components from EXTRA_COMPONENT_DIRS
3. "project_managed_components" - custom project dependencies managed by the IDF Component Manager
4. "idf_components" - ESP-IDF built-in components, typically under /components

This can be used to identify the component libraries that are likely to
change during application development and pass them to ldgen as mutable
libraries. Add all components with "project_components" as their source
as mutable.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-24 14:58:02 +01:00
Frantisek Hrbata
4ba40bce20 fix(cmakev2/kconfig): avoid unnecessary sdkconfig generation
Add a helper function `__should_generate_sdkconfig()` that checks
whether the sdkconfig file should be generated.  The
`__generate_sdkconfig()` function can be called multiple times, such as
when the initial sdkconfig is generated at the start of the build
process and later after additional components are fetched by the
component manager.  There might be no components fetched by the
component manager, for example, in the hello_world example, or the
downloaded components may not contain any configuration files. In such
cases, there is no need to regenerate the sdkconfig. This helper
function stores the list of configuration files in the
`__PREV_KCONFIGS`, `__PREV_KCONFIG_PROJBUILDS`, and
`__PREV_SDKCONFIG_RENAMES` build properties at its end, and at the
beginning, it compares them with the current lists of configuration
files.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-24 13:44:01 +01:00
Frantisek Hrbata
e08aca162a feat(cmakev2/size): add idf_create_size_report function
The idf_create_size_report function allows for the creation of size
report targets based on the generated link map file. The size report
targets are created using the TARGET option name: "<target>",
"<target>-files", and "<target>-components". These size report targets
are added to the idf_default_project with the TARGET set to "size",
resulting in the creation of "size", "size-files", and "size-components"
targets for the default project.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-19 11:35:36 +01:00
Frantisek Hrbata
e216eeeebc fix(cmakev2/project): unset global variables in idf_project_init macro
The idf_project_init macro is evaluated within the global variable
scope, and currently, there are a few variables still set. Let's ensure
all variables are properly unset to avoid polluting the global variable
namespace.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-19 11:34:03 +01:00
Frantisek Hrbata
bba4446ee0 fix(cmakev2/build): display a warning when the MINIMAL_BUILD property is set
The MINIMAL_BUILD property is not relevant in cmakev2, as only
components explicitly linked through targets are included in the build
by design. Display a warning when this outdated build property is set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-19 11:34:03 +01:00
Frantisek Hrbata
2b35b5b1bb fix(cmakev2/build): fix the generation of the link map file
The link flag for generating the map file is currently added globally to
the link_options. If multiple executables are generated, the link map
file is overwritten by the last created executable. Since cmakev2
supports building multiple executables, the link map file options need
to be set for each executable individually. To address this, add a new
MAPFILE_TARGET option to the idf_build_executable function. When set,
the link map file will be generated by the linker, and a target
specified in the MAPFILE_TARGET option will be created for the map file.

This also splits the idf_project_default macro.  Only the
idf_project_init macro needs be called within the global scope, as it
includes the project_include.cmake files and the cmake version of the
configuration. The remaining functionality of the idf_project_default
macro is implemented in a __project_default helper function to avoid
polluting the global variable space.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-19 11:33:57 +01:00
Frantisek Hrbata
e97027214e fix(cmakev2/build): pass binary target to idf_build_generate_metadata
Currently, the `idf_build_generate_metadata` function takes an
executable target as an argument, and the binary name is stored in the
`EXECUTABLE_BINARY` property. This approach is inconvenient because a
single executable might generate multiple binary images, making it
unreliable to store the binary image name in the executable property due
to the N:1 relationship. To address this, pass the binary image target
instead of the executable target to the `idf_build_generate_metadata`
function. This change is facilitated by linking the binary target,
executable target, and library interface targets with the following
properties:

binary:EXECUTABLE_TARGET -> executable:LIBRARY_INTERFACE -> library

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-19 11:30:18 +01:00
Frantisek Hrbata
5130b7d228 fix(cmakev2/project): remove temporary workaround for partition and bootloader flash dependencies
With commit b719292b75 ("refactor(build-system): Simplify flash target creation"),
partition table and bootloader components are correctly adding their
dependency on the flash target, so there is no need for this to be done
in the build system. This removes the temporary workaround.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-19 11:26:07 +01:00
Sudeep Mohanty
94809d6638 feat(cmakev2): Add uf2 target support for cmakev2
This commit adds support for uf2 targets for cmake2. The following
changes have been made:
- Adds a new tools/cmakev2/uf2.cmake.
- Adds the idf_create_uf2() function to create the uf2 targets. This
  function now takes the executable as an argument thus allowing the uf2
  target to be created per-executable.
- idf_project_default() is updated to create the uf2 targets.
2025-11-18 15:08:53 +05:30
Sudeep Mohanty
5b0d81bc50 feat(cmakev2): Add dfu target support for cmakev2
This commit adds support for dfu targets for cmake2. The following
changes have been made:
- Adds a new tools/cmakev2/dfu.cmake file on similar lines as the
  tools/cmake/dfu.cmake file.
- Adds the idf_create_dfu() function to create the dfu targets. This
  function now takes the executable as an argument thus allowing the dfu
  target to be created per-executable.
- idf_project_default() is updated to create the dfu target.
2025-11-18 15:08:12 +05:30
Frantisek Hrbata
999cc27599 feat(cmakev2/project): add warning for usage of deprecated variables
The COMPONENTS and EXCLUDE_COMPONENTS variables are unused in cmakev2. A
deprecation warning will be printed if they are set. This change also
includes a helper functions for printing deprecation warnings.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-04 14:38:13 +01:00
Frantisek Hrbata
de5ad78f6b fix(cmakev2/project): drop prefix_map_gdbinit in favor of gdbinit/prefix_map
The cmakev1 dropped generation of prefix_map_gdbinit, reflect this
change also in cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-04 12:08:50 +01:00
Frantisek Hrbata
37efbf8675 fix(cmakev2/project): bump C and CXX standard
The cmakev1 bumped C and CXX standard to gnu23 and gnu++26, do the same
in cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-04 11:10:02 +01:00
Frantisek Hrbata
c98146a8c6 fix(cmakev2/compat): add esp_stdio to common requires
The cmakev1 added esp_stdio to common requires, add it in cmakev2 too
for backward compatibility.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-04 11:06:02 +01:00
Frantisek Hrbata
7116d9dc01 feat(toolchain): more remove_duplicated_flags function to separate file
Currently, the toolchain CMake files use the remove_duplicated_flags
function from utilities.cmake. The cmakev2 implementation also includes
this function for backward compatibility. Move the
remove_duplicated_flags function to a separate file,
deduplicate_flags.cmake, so it can be shared between cmakev1 and
cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
997cd81675 feat(cmakev2/compat): add idf_component_register to the API
Using idf_component_register is the preferred method for creating new
components for cmakev2. This approach ensures compatibility with both
versions of the build system. The KCONFIG and KCONFIG_PROJBUILD options
have been removed from the API documentation, but are retained in code
in case a cmakev1 component uses these options to warn about
incompatibility. Also remove a note about `project_include.cmake`,
because cmakev2 includes all project_include files.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
fc1f995e5e fix(cmakev2/component): set the cmakev2 component archive name
Currently, the archive file name is set only in the cmakev1
idf_component_register shim. The predictable component archive file name
is important, for example, for usage in linker fragments. Ensure that
the cmakev2 component also has the archive file name set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
a7977d0d14 fix(cmakev2/component): fix setting SOURCES for cmakev2 components
Currently, when the cmakev2 component sources are set, the SRCS target
property is used.  This is obviously wrong because the correct CMake
property is SOURCES.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00