Skip to content

Commit 999cc27

Browse files
committed
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 <[email protected]>
1 parent de5ad78 commit 999cc27

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tools/cmakev2/project.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,10 @@ macro(idf_project_init)
568568
# Ensure this function is executed only once throughout the entire
569569
# project.
570570

571+
# Warn about the use of deprecated variables.
572+
deprecate_variable(COMPONENTS)
573+
deprecate_variable(EXCLUDE_COMPONENTS)
574+
571575
# Set PROJECT_NAME build property
572576
__init_project_name()
573577

tools/cmakev2/utilities.cmake

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,40 @@ function(idf_dbg)
109109
message(DEBUG " IDF: ${joined}")
110110
endfunction()
111111

112+
#[[
113+
idf_deprecated(<msg>...)
114+
115+
*msg[in]*
116+
117+
Message to print.
118+
119+
Print deprecated ``<msg>``. Multiple messages are concatenated into a
120+
single message with no separator between them.
121+
#]]
122+
function(idf_deprecated)
123+
set(joined "")
124+
math(EXPR last "${ARGC} - 1")
125+
foreach(i RANGE 0 ${last})
126+
string(APPEND joined "${ARGV${i}}")
127+
endforeach()
128+
message(DEPRECATION " IDF: ${joined}")
129+
endfunction()
130+
131+
#[[
132+
deprecate_variable(<var>)
133+
134+
*var[in]*
135+
136+
Deprecated variable name.
137+
138+
Print a warning about the use of a deprecated variable.
139+
#]]
140+
function(deprecate_variable var)
141+
if(${var})
142+
idf_deprecated("The use of the '${var}' variable is deprecated and will be ignored.")
143+
endif()
144+
endfunction()
145+
112146
#[[
113147
__get_real_target(TARGET <target>
114148
OUTPUT <variable>)

0 commit comments

Comments
 (0)