Skip to content

Commit

Permalink
cmake: fix <keys> argument in import_kconfig()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
tejlmand authored and stephanosio committed Nov 2, 2022
1 parent 3d24a07 commit 430370c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cmake/modules/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

########################################################
Expand Down

0 comments on commit 430370c

Please sign in to comment.