cmake -P: CMake Warning: Ignoring extra path from command line
Hi.
First a little bit of pre-text how we use CMake for scripting
We are using CMake quite heavily in our codebase to do many general CLI scripting tasks via CMake script-mode (cmake -P )
(basically CMake has become our cross-platform CLI scripting language
We pretty much make full use of what the cmake CLI parameter syntax allows:
cmake [{-D <var>=<value>}...] -P <cmake-script-file> [-- <unparsed-options>...]
- we pre-populate some variables via
-D
for the script that we are running -
-P
could point to any of dozens of script files (or could be non-existent, since often the script-file is determined by user input) - after the
<cmake-script-file>
path, we typically immediately let the user pass any number of arguments for this script- we do not currently use
--
to separate the script arguments from the other CMake CLI arguments, but for the bug that I will show below I tested it, and it does not seem to make a difference
- we do not currently use
CMake Warning: Ignoring extra path from command line
is displayed when it shouldn't
Bug: Minimal steps to reproduce the issue:
mkdir folder
touch folder/CMakeLists.txt
touch some-script.cmake
cmake -P some-script.cmake anything-here folder
Then CMake prints the warning:
CMake Warning:
Ignoring extra path from command line:
"C:/your-cwd-path/anything-here"
Note: The touch folder/CMakeLists.txt
seems to be important for the bug to happen, without a CMakeLists.txt file in that folder, the warning will not be shown.
From the CMake versions I used recently:
-
3.23.1
seems to have the problem -
3.21.3
does not seem to have the problem
So the change to CMake might have happened somewhere in between!
Expected behavior (in script-mode)
I think if CMake is running in script-mode, it should not try to interpret / check any of the CLI arguments that come after the <cmake-script-file>
in any way.
That seems to have been the case in previous CMake versions, and we make heavy use of that in our CLI scripting.
Some code in CMake seems to have changed recently, which now prints the above warning in script-mode (without good reason ?!!).
PS: so far this warning seems to have no effect in script-mode, although it prominently states Ignoring extra path
... all of our CMake CLI scripts that I have checked (so far) did work just fine, same way as they used to, except for the annoying warning that is now printed.
PSS: in our cmake scripts we typically use CMAKE_ARGC
and the CMAKE_ARGV${i}
variables to read the CLI arguments that should be handled in the script code.
Thanks