cmake: Add input redirection for script mode (-P)
This MR implements the input-redirection mode for cmake -P
, as described in #23636.
Tests
A battery of tests are added to Tests/RunCMake/ScriptMode/
which cover the basic cmake -P -
case, plus multiple other cmake -P
scenarios including:
- Passing additional arguments before and after
-P -
- Passing
-DVAR=Value
arguments, specifically, after-P -
. (These will be ignored, just as they are by the current CMake. In a command likecmake -P script.cmake -DVAR=value
, the-D
argument is assumed to be a script argument, so it is not processed bycmake
.) - Running
cmake -P - --trace
- Running
cmake -P -DVAR=Value
, because the error produced has changed.- Previously, it resulted in:
CMake Error: No script specified for argument -P
- With this change, the
-D...
argument is interpreted as the script filename:CMake Error: Error processing file: -DVAR=value
- Previously, it resulted in:
Fixes: #23636
Edited by Frank Dana