cmake: In -P mode ignore extra paths on the command line

Fixes: #23748
4 files changed