From 430370c4e46652e59a2dd25d3907d0dae797a0e7 Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Fri, 14 Oct 2022 15:45:55 +0200 Subject: [PATCH] cmake: fix argument in import_kconfig() The signature of import_kconfig() take two mandatory arguments and one optional: > import_kconfig( []) but has been implemented in such a way that it loops all arguments after the two mandatory args and sets the same list on those. Fix this error by only setting the created variables on the third and optional argument if it exists. Signed-off-by: Torsten Rasmussen --- cmake/modules/extensions.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/modules/extensions.cmake b/cmake/modules/extensions.cmake index 2573dbd2e52..90b4089b011 100644 --- a/cmake/modules/extensions.cmake +++ b/cmake/modules/extensions.cmake @@ -1461,9 +1461,13 @@ function(import_kconfig prefix kconfig_fragment) list(APPEND keys "${CONF_VARIABLE_NAME}") endforeach() - foreach(outvar ${ARGN}) - set(${outvar} "${keys}" PARENT_SCOPE) - endforeach() + if(ARGC GREATER 2) + if(ARGC GREATER 3) + # Two mandatory arguments and one optional, anything after that is an error. + message(FATAL_ERROR "Unexpected argument after '': import_kconfig(... ${ARGV3})") + endif() + set(${ARGV2} "${keys}" PARENT_SCOPE) + endif() endfunction() ########################################################