From c368f15328f1f531f301a7e60982e26fffc86d51 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Mon, 6 Jan 2025 19:23:42 +0100 Subject: [PATCH] feat(examples): trim down the plugins example build Set the COMPONENTS project variable to streamline the build process. Although the minimal build feature could be used to specify plugin components in the main component dependencies, it's more convenient to set the plugin components at the project level. This approach also allows for quick selection of which plugins to include in the application. Signed-off-by: Frantisek Hrbata --- examples/build_system/cmake/plugins/CMakeLists.txt | 2 ++ examples/build_system/cmake/plugins/README.md | 8 ++++++++ 2 files changed, 10 insertions(+) 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.