diff options
author | Taylor Braun-Jones <taylor@braun-jones.org> | 2019-01-09 13:02:47 -0500 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-01-28 08:24:50 -0500 |
commit | a5098cad94c152e397b258be69ae152eb1bda3df (patch) | |
tree | 75055f8a973456e38b65b4f6db9961858c66ddb5 /Source | |
parent | 40628b2519ae1553a33f701cf46ee8fbbd013b85 (diff) | |
download | cmake-a5098cad94c152e397b258be69ae152eb1bda3df.tar.gz |
cmake: Add --ignore-eol option to `-E compare_files` command
Fixes: #13007
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmcmd.cxx | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index ce3691d479..0ad9b88a02 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; |