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 <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2025-11-05 11:23:03 +01:00
parent 5724a6e1e4
commit dd5aae9c56
2 changed files with 38 additions and 0 deletions
+4
View File
@@ -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()
+34
View File
@@ -109,6 +109,40 @@ function(idf_dbg)
message(DEBUG " IDF: ${joined}")
endfunction()
#[[
idf_deprecated(<msg>...)
*msg[in]*
Message to print.
Print deprecated ``<msg>``. 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>)
*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 <target>
OUTPUT <variable>)