diff --git a/examples/build_system/cmake/plugins/CMakeLists.txt b/examples/build_system/cmake/plugins/CMakeLists.txt index 34cdcf31c8..9022686730 100644 --- a/examples/build_system/cmake/plugins/CMakeLists.txt +++ b/examples/build_system/cmake/plugins/CMakeLists.txt @@ -3,4 +3,6 @@ cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) +# "Trim" the build. Include the minimal set of components, main, and plugins. +set(COMPONENTS main plugin_hello plugin_nihao) project(plugins) diff --git a/examples/build_system/cmake/plugins/README.md b/examples/build_system/cmake/plugins/README.md index 331e8e115e..a1b4511994 100644 --- a/examples/build_system/cmake/plugins/README.md +++ b/examples/build_system/cmake/plugins/README.md @@ -52,6 +52,14 @@ For each plugin, a structure describing the plugin (or a pointer to it) is place ## Example code overview +This example uses the optional `COMPONENTS` project variable to streamline the build process. By specifying components in this variable, only those components and their dependencies are linked to the application, reducing build time. Additionally, listing plugin components in the `COMPONENTS` variable ensures that only the specified plugins are linked. This approach provides a convenient way to quickly select the plugins to include in the application. The `COMPONENTS` variable is set in the project's CMakeLists.txt file: + +```cmake +set(COMPONENTS main plugin_hello plugin_nihao) +``` + +For details about the `COMPONENTS` project variable, please refer to the Build System documentation. + This example contains 4 components: * `main` — Only calls two sample functions defined in `plugins` component.