From f6fcfbb9e6909e32f901510ae0d955bd3c750e80 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Wed, 25 Sep 2024 15:50:45 +0200 Subject: [PATCH] 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 --- tools/cmake/project.cmake | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index fe126c8bdd..be9229c65d 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -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)