summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorTaylor Braun-Jones <taylor@braun-jones.org>2019-01-09 18:02:47 (GMT)
committerBrad King <brad.king@kitware.com>2019-01-28 13:24:50 (GMT)
commita5098cad94c152e397b258be69ae152eb1bda3df (patch)
tree75055f8a973456e38b65b4f6db9961858c66ddb5 /Source
parent40628b2519ae1553a33f701cf46ee8fbbd013b85 (diff)
downloadCMake-a5098cad94c152e397b258be69ae152eb1bda3df.zip
CMake-a5098cad94c152e397b258be69ae152eb1bda3df.tar.gz
CMake-a5098cad94c152e397b258be69ae152eb1bda3df.tar.bz2
cmake: Add --ignore-eol option to `-E compare_files` command
Fixes: #13007
Diffstat (limited to 'Source')
-rw-r--r--Source/cmcmd.cxx21
1 files changed, 16 insertions, 5 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index ce3691d..0ad9b88 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -78,7 +78,8 @@ void CMakeCommandUsage(const char* program)
<< " capabilities - Report capabilities built into cmake "
"in JSON format\n"
<< " chdir dir cmd [args...] - run command in a given directory\n"
- << " compare_files file1 file2 - check if file1 is same as file2\n"
+ << " compare_files [--ignore-eol] file1 file2\n"
+ << " - check if file1 is same as file2\n"
<< " copy <file>... destination - copy files to destination "
"(either file or directory)\n"
<< " copy_directory <dir>... destination - copy content of <dir>... "
@@ -540,10 +541,20 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
}
// Compare files
- if (args[1] == "compare_files" && args.size() == 4) {
- if (cmSystemTools::FilesDiffer(args[2], args[3])) {
- std::cerr << "Files \"" << args[2] << "\" to \"" << args[3]
- << "\" are different.\n";
+ if (args[1] == "compare_files" && (args.size() == 4 || args.size() == 5)) {
+ bool filesDiffer;
+ if (args.size() == 4) {
+ filesDiffer = cmSystemTools::FilesDiffer(args[2], args[3]);
+ } else if (args[2] == "--ignore-eol") {
+ filesDiffer = cmsys::SystemTools::TextFilesDiffer(args[3], args[4]);
+ } else {
+ ::CMakeCommandUsage(args[0].c_str());
+ return 1;
+ }
+
+ if (filesDiffer) {
+ std::cerr << "Files \"" << args[args.size() - 2] << "\" to \""
+ << args[args.size() - 1] << "\" are different.\n";
return 1;
}
return 0;