cmake: fix <keys> argument in import_kconfig()

The signature of import_kconfig() take two mandatory arguments and one
optional:
> import_kconfig(<prefix> <kconfig_fragment> [<keys>])

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 <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2022-10-14 15:45:55 +02:00 committed by Stephanos Ioannidis
parent 3d24a07c6b
commit 430370c4e4
1 changed files with 7 additions and 3 deletions

View File

@ -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 '<keys>': import_kconfig(... ${ARGV3})")
endif()
set(${ARGV2} "${keys}" PARENT_SCOPE)
endif()
endfunction()
########################################################