summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-01-28 13:26:45 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-01-28 13:27:03 (GMT)
commita844c7248d7cfca9569ea8aa6a2147f564a5b2f1 (patch)
treed9128d1bb018d26c7f4740ae4510e72c741dbc0f /Source
parent1593e16d881bf74fd8981e1290d20f28191f1f0e (diff)
parenta5098cad94c152e397b258be69ae152eb1bda3df (diff)
downloadCMake-a844c7248d7cfca9569ea8aa6a2147f564a5b2f1.zip
CMake-a844c7248d7cfca9569ea8aa6a2147f564a5b2f1.tar.gz
CMake-a844c7248d7cfca9569ea8aa6a2147f564a5b2f1.tar.bz2
Merge topic 'cmake-E-compare_files-eol'
a5098cad94 cmake: Add --ignore-eol option to `-E compare_files` command Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2778
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;