Introduce dedicated error codes for "CMake -E compare_files ..."
This is a follow up from the discussion at #20803 (closed)
"CMake -E compare_files ..."returns 0 is the files are identical and 1 is the files differ. But it also returns 1 if the command line arguments are invalid. This seems a bug, because having the same error codes for invalid parameters and mismatch is a problem when scripting things - especially is the message is now removed.
I recommend that the function should return 2 or something else on invalid parameters then also. So there is a chance scripts detect mis-usage, e.g. using the "eol" parameter, which is only supported by newer CMake versions.
@asit-dhal remarked: 2 return value in unix means "Misuse of shell builtins". We can assume miss use of command builtins. I will change and send an updated MR.
Changing a return code potentially impacts on existing deployments. The exiting docs at https://cmake.org/cmake/help/v3.17/manual/cmake.1.html?highlight=compare_files#run-a-command-line-tool says "Check if is same as . If files are the same, then returns 0, if not it returns 1. [...]". This should be extended then to says that to says that "2" mean parameter error and any other code shall also be considered an invocation error. For example, there might be the "file not found" case to be handled with dedicated error codes in the future also:
- both files missing -> equal? or not equal? Or dedicated code file missing?
- one file missing -> not equal? Or dedicated code file missing?