Multi-value keywords in cmake_parse_arguments()

Hello,

can someone perhaps confirm if this is a feature or a side effect that should be avoided:

function(foo)
  cmake_parse_arguments(
    PARSE_ARGV
    0
    PARSED_ARGS # prefix
    "" # options
    "" # one-value keywords
    "OPTIONS" # multi-value keywords
  )
  message(STATUS "${PARSED_ARGS_OPTIONS}")
endfunction()

foo(OPTIONS --foo --bar --baz)
# outputs: --foo;--bar;--baz

foo(OPTIONS --foo --bar OPTIONS --baz)
# outputs: --foo;--bar;--baz

The multi-value keywords could be used multiple times in a function call?

I think this is an unexpected side effect.
In fact, all options can be specified multiple time. For one-value, the last option specified wins. And for multi-value, all arguments are aggregated.

Please create an issue for this problem. We have two options here:

  1. Keep the current behavior, but the doc must be updated
  2. Raise an error if options are not uniquely specified, but require a policy.
1 Like