Skip to content

cmake: Add input redirection for script mode (-P)

Frank Dana requested to merge ferdnyc/cmake:piped-script into master

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 like cmake -P script.cmake -DVAR=value, the -D argument is assumed to be a script argument, so it is not processed by cmake.)
  • 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

Fixes: #23636

Edited by Frank Dana

Merge request reports