Where is $<COMMAND_CONFIG:...> allowed?

The documentation for the $<COMMAND_CONFIG:...> generator expression (introduced in CMake 3.20) is a bit ambiguous regarding where it is allowed to be used. It states the following:

Only valid in add_custom_command() and add_custom_target() as the outer-most generator expression in an argument.

What is meant by “argument” here? Does this mean that it can only appear in a COMMAND, or does “argument” refer to any argument of add_custom_command() or add_custom_target()? Put another way, is it legal to use $<COMMAND_CONFIG:...> in something listed after DEPENDS?

This arose in a recent Qt code review. It would be nice to get clarification so we understand what is intended to be formally supported and what isn’t.


1 Like

I believe it is valid in DEPENDS as well. The idea is to allow dependency on the same config as the output or, in this case, the cross-config feature where a Release tool can be used in a Debug custom command.