Part of the complexity is that there can be more than just one command. After the PATCH_COMMAND
, there could be further COMMAND
blocks. Same for all the other custom command keywords like DOWNLOAD_COMMAND
, UPDATE_COMMAND
and so on. That means you would have to match up any INPUT_FILE
with the command it was intended for. It would be even more complicated to have a keyword specific to just the PATCH_COMMAND
due to the way the argument parsing is implemented, so this would most likely need to work for all custom command types, not just PATCH_COMMAND
.
For the specific case in the original question, you don’t even have to use redirection. The patch
command supports an -i
or --input
option for specifying the patch file (at least on macOS it does), so that allows you to specify an input file directly as part of the patch
command.
While I’m not saying that being able to provide input redirection for commands wouldn’t be a useful enhancement, I’m wary of the complexity of implementing it and there is a well-established workaround of using a script as the command instead. The ExternalProject module is also one of the most complex of all the modules CMake provides. The way it parses arguments is… unusual, primarily because of the need to support keywords that can be repeated (the COMMAND
keyword being the main culprit). It stores all keywords on targets, but only in some scenarios (FetchContent now uses it in a way that there are no targets to store them on). If you want to explore contributing this feature, perhaps take a look at the Modules/ExternalProject.cmake
file as a first step. I can provide limited guidance, but my workload is already pretty high so you’d need to be fairly independent.