add_custom_command() argument validation too lazy
Creating some examples for another issue I stumbled upon the argument validation of add_custom_command
.
COMMAND
mandatory Although documented as mandatory, the check seems too simple. It only checks for the existence of 4 arguments. So the following example is accepted:
add_custom_command(
OUTPUT output_with_comment.txt
COMMENT "ABC"
)
add_custom_target(some_target)
add_custom_command(
TARGET some_target
PRE_BUILD
VERBATIM
)
Possible solutions:
- Make a mandatory check (probably needs a policy)
- document as optional and decrease minimal numbers of arguments to 2 or even 0
target options
The second problem are the target options where to add the command. They are neither exclusive nor mandatory as documented.
add_custom_target(some_target)
add_custom_command(
TARGET some_target
PRE_BUILD PRE_LINK POST_BUILD
)
Possible solutions:
- Make a mandatory and exlusive check (probably needs a policy)
- document as optional, describe which one is default, and that the final occurence will win
summary
I assume that the current implemented behavior for both deviations is acceptable, so updating the documentation might be the best solution.