cmake: fixed regex handling in process_flags function extensions.cmake

This commit fixes an issue in the process_flags function.
The function check a list of flags for generator expression for provided
language, for example:
$<$<COMPILE_LANGUAGE:C>:--flag>
and then converts that into a single compile flag, `--flag`

This works as long as $<COMPILE_LANGUAGE:[language]> is the only
generator expression present in the flag.

In case the flag contains multiple generator expression, then the
current substitution fails.

This commit keep existing behaviour for simple cases, but extends the
more complex cases into a always enabled generator expression, that is
$<$<COMPILE_LANGUAGE:C>:$<ADDITIONAL_EXPRESSION>> into
$<1:$<ADDITIONAL_EXPRESSION>>
and
$<$<FIRST_EXPRESSION>$<COMPILE_LANGUAGE:C>:--flag> into
$<$<FIRST_EXPRESSION>$<1:--flag>

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
1 file changed