[Cmake-commits] [cmake-commits] king committed cmFileCommand.cxx 1.116 1.117 cmFileCommand.h 1.41 1.42

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Jan 7 14:16:37 EST 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv3773/Source

Modified Files:
	cmFileCommand.cxx cmFileCommand.h 
Log Message:
ENH: Add undocumented file(DIFFERENT) command

This new command will be used by generated installation scripts to
determine whether an already-installed export file has changed.


Index: cmFileCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFileCommand.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -C 2 -d -r1.41 -r1.42
*** cmFileCommand.h	19 Dec 2008 02:52:46 -0000	1.41
--- cmFileCommand.h	7 Jan 2009 19:16:35 -0000	1.42
***************
*** 173,176 ****
--- 173,177 ----
    bool HandleRPathCheckCommand(std::vector<std::string> const& args);
    bool HandleRPathRemoveCommand(std::vector<std::string> const& args);
+   bool HandleDifferentCommand(std::vector<std::string> const& args);
  
    // file(INSTALL ...) related functions

Index: cmFileCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFileCommand.cxx,v
retrieving revision 1.116
retrieving revision 1.117
diff -C 2 -d -r1.116 -r1.117
*** cmFileCommand.cxx	5 Jan 2009 16:05:57 -0000	1.116
--- cmFileCommand.cxx	7 Jan 2009 19:16:34 -0000	1.117
***************
*** 113,116 ****
--- 113,120 ----
      return this->HandleInstallCommand(args);
      }
+   else if ( subCommand == "DIFFERENT" )
+     {
+     return this->HandleDifferentCommand(args);
+     }
    else if ( subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH" )
      {
***************
*** 832,835 ****
--- 836,900 ----
  
  //----------------------------------------------------------------------------
+ bool
+ cmFileCommand::HandleDifferentCommand(std::vector<std::string> const& args)
+ {
+   /*
+     FILE(DIFFERENT <variable> FILES <lhs> <rhs>)
+    */
+ 
+   // Evaluate arguments.
+   const char* file_lhs = 0;
+   const char* file_rhs = 0;
+   const char* var = 0;
+   enum Doing { DoingNone, DoingVar, DoingFileLHS, DoingFileRHS };
+   Doing doing = DoingVar;
+   for(unsigned int i=1; i < args.size(); ++i)
+     {
+     if(args[i] == "FILES")
+       {
+       doing = DoingFileLHS;
+       }
+     else if(doing == DoingVar)
+       {
+       var = args[i].c_str();
+       doing = DoingNone;
+       }
+     else if(doing == DoingFileLHS)
+       {
+       file_lhs = args[i].c_str();
+       doing = DoingFileRHS;
+       }
+     else if(doing == DoingFileRHS)
+       {
+       file_rhs = args[i].c_str();
+       doing = DoingNone;
+       }
+     else
+       {
+       cmOStringStream e;
+       e << "DIFFERENT given unknown argument " << args[i];
+       this->SetError(e.str().c_str());
+       return false;
+       }
+     }
+   if(!var)
+     {
+     this->SetError("DIFFERENT not given result variable name.");
+     return false;
+     }
+   if(!file_lhs || !file_rhs)
+     {
+     this->SetError("DIFFERENT not given FILES option with two file names.");
+     return false;
+     }
+ 
+   // Compare the files.
+   const char* result =
+     cmSystemTools::FilesDiffer(file_lhs, file_rhs)? "1" : "0";
+   this->Makefile->AddDefinition(var, result);
+   return true;
+ }
+ 
+ //----------------------------------------------------------------------------
  // File installation helper class.
  struct cmFileInstaller



More information about the Cmake-commits mailing list