From dd5aae9c56474ab2d857842f65c78941009348f1 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Tue, 4 Nov 2025 14:38:13 +0100 Subject: [PATCH] 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 --- tools/cmakev2/project.cmake | 4 ++++ tools/cmakev2/utilities.cmake | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/tools/cmakev2/project.cmake b/tools/cmakev2/project.cmake index e7544da86b8..a1f8ffb3ae5 100644 --- a/tools/cmakev2/project.cmake +++ b/tools/cmakev2/project.cmake @@ -568,6 +568,10 @@ macro(idf_project_init) # Ensure this function is executed only once throughout the entire # project. + # Warn about the use of deprecated variables. + deprecate_variable(COMPONENTS) + deprecate_variable(EXCLUDE_COMPONENTS) + # Set PROJECT_NAME build property __init_project_name() diff --git a/tools/cmakev2/utilities.cmake b/tools/cmakev2/utilities.cmake index a58d188e9a8..69f94a8dfb6 100644 --- a/tools/cmakev2/utilities.cmake +++ b/tools/cmakev2/utilities.cmake @@ -109,6 +109,40 @@ function(idf_dbg) message(DEBUG " IDF: ${joined}") endfunction() +#[[ + idf_deprecated(...) + + *msg[in]* + + Message to print. + + Print deprecated ````. Multiple messages are concatenated into a + single message with no separator between them. +#]] +function(idf_deprecated) + set(joined "") + math(EXPR last "${ARGC} - 1") + foreach(i RANGE 0 ${last}) + string(APPEND joined "${ARGV${i}}") + endforeach() + message(DEPRECATION " IDF: ${joined}") +endfunction() + +#[[ + deprecate_variable() + + *var[in]* + + Deprecated variable name. + + Print a warning about the use of a deprecated variable. +#]] +function(deprecate_variable var) + if(${var}) + idf_deprecated("The use of the '${var}' variable is deprecated and will be ignored.") + endif() +endfunction() + #[[ __get_real_target(TARGET OUTPUT )