feat(cmake): introduce MINIMAL_BUILD build property

Introduce a MINIMAL_BUILD property to streamline the build process by
including only the main component and its direct and indirect
dependencies. This serves as a convenient shortcut for using
set(COMPONENTS main). The MINIMAL_BUILD build property is ignored if the
COMPONENTS variable is defined, as COMPONENTS takes precedence.

To enable a minimal build, add "idf_build_set_property(MINIMAL_BUILD ON)"
to the project's CMake configuration.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2024-09-25 15:50:45 +02:00
parent ad15109daa
commit f6fcfbb9e6

View File

@@ -495,6 +495,24 @@ function(__project_init components_var test_components_var)
endif()
endforeach()
# If a minimal build is requested, set COMPONENTS to "main" only if the COMPONENTS
# variable is not already defined. The COMPONENTS variable takes precedence over
# the MINIMAL_BUILD property.
idf_build_get_property(minimal_build MINIMAL_BUILD)
if(minimal_build)
if(DEFINED COMPONENTS)
message(WARNING "The MINIMAL_BUILD property is disregarded because the COMPONENTS variable is defined.")
set(minimal_build OFF)
else()
set(COMPONENTS main)
set(minimal_build ON)
endif()
else()
set(minimal_build OFF)
endif()
message(STATUS "Minimal build - ${minimal_build}")
spaces2list(COMPONENTS)
spaces2list(EXCLUDE_COMPONENTS)
idf_build_get_property(component_targets __COMPONENT_TARGETS)