cmMakefile::ExpandArguments: inconsistent behaviors
The problem concerns the handling of arguments for native CMake
commands.
The method cmMakefile::ExpandArguments
with std::vector<cmExpandedCommandArgument>
as output values expand differently quoted arguments, depending on the way arguments are passed to CMake
.
# FIRST
func(unquoted "quoted")
# SECOND
# define a variable holding input values. Add escaped quotes to ensure quotes are forwarded to the caller
set (ARGS unquoted "\"quoted\"")
func(${ARGS})
For FIRST
:
- input (
vector<cmListFileArgument>
):unquoted
(Delim=Unquoted
),quoted
(Delim=Quoted
) - output (
std::vector<cmExpandedCommandArgument>
):unquoted
(Quoted=false
),quoted
(Quoted=true
)
For SECOND
:
- input (
vector<cmListFileArgument>
):${ARGS}
(Delim=Unquoted
) - output (
std::vector<cmExpandedCommandArgument>
):unquoted
(Quoted=false
),"quoted"
(Quoted=false
)
The second argument (the quoted one) seems broken for the SECOND
call: it is described as not quoted but the value itself includes quotes.
So, the final result is inconsistent. Is it by design or is it a bug?
@brad.king FWI, By patching the method cmMakefile::ExpandArguments
, I can get a consistent behavior regardless how arguments are passed and all tests are green...