[cmake-commits] king committed cmAddCustomCommandCommand.cxx 1.34 1.35 cmAddCustomCommandCommand.h 1.29 1.30 cmCustomCommand.cxx 1.23 1.24 cmCustomCommand.h 1.22 1.23 cmMakefileTargetGenerator.cxx 1.69 1.70

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Sep 17 10:50:48 EDT 2007


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

Modified Files:
	cmAddCustomCommandCommand.cxx cmAddCustomCommandCommand.h 
	cmCustomCommand.cxx cmCustomCommand.h 
	cmMakefileTargetGenerator.cxx 
Log Message:
ENH: Added IMPLICIT_DEPENDS option to ADD_CUSTOM_COMMAND.  It currently works only for Makefile generators.  It allows a custom command to have implicit dependencies in the form of C or CXX sources.


Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- cmMakefileTargetGenerator.cxx	13 Sep 2007 17:37:45 -0000	1.69
+++ cmMakefileTargetGenerator.cxx	17 Sep 2007 14:50:46 -0000	1.70
@@ -939,6 +939,21 @@
       }
     this->GenerateExtraOutput(o->c_str(), in, symbolic);
     }
+
+  // Setup implicit dependency scanning.
+  for(cmCustomCommand::ImplicitDependsList::const_iterator
+        idi = cc.GetImplicitDepends().begin();
+      idi != cc.GetImplicitDepends().end(); ++idi)
+    {
+    std::string objFullPath =
+      this->Convert(outputs[0].c_str(), cmLocalGenerator::FULL);
+    std::string srcFullPath =
+      this->Convert(idi->second.c_str(), cmLocalGenerator::FULL);
+    this->LocalGenerator->
+      AddImplicitDepends(*this->Target, idi->first.c_str(),
+                         objFullPath.c_str(),
+                         srcFullPath.c_str());
+    }
 }
 
 //----------------------------------------------------------------------------

Index: cmCustomCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCustomCommand.cxx,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cmCustomCommand.cxx	28 May 2007 15:18:15 -0000	1.23
+++ cmCustomCommand.cxx	17 Sep 2007 14:50:46 -0000	1.24
@@ -134,3 +134,23 @@
 {
   this->EscapeAllowMakeVars = b;
 }
+
+//----------------------------------------------------------------------------
+cmCustomCommand::ImplicitDependsList const&
+cmCustomCommand::GetImplicitDepends() const
+{
+  return this->ImplicitDepends;
+}
+
+//----------------------------------------------------------------------------
+void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l)
+{
+  this->ImplicitDepends = l;
+}
+
+//----------------------------------------------------------------------------
+void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l)
+{
+  this->ImplicitDepends.insert(this->ImplicitDepends.end(),
+                               l.begin(), l.end());
+}

Index: cmCustomCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCustomCommand.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmCustomCommand.h	28 May 2007 15:18:15 -0000	1.22
+++ cmCustomCommand.h	17 Sep 2007 14:50:46 -0000	1.23
@@ -68,6 +68,12 @@
   bool GetEscapeAllowMakeVars() const;
   void SetEscapeAllowMakeVars(bool b);
 
+  typedef std::pair<cmStdString, cmStdString> ImplicitDependsPair;
+  class ImplicitDependsList: public std::vector<ImplicitDependsPair> {};
+  void SetImplicitDepends(ImplicitDependsList const&);
+  void AppendImplicitDepends(ImplicitDependsList const&);
+  ImplicitDependsList const& GetImplicitDepends() const;
+
 private:
   std::vector<std::string> Outputs;
   std::vector<std::string> Depends;
@@ -77,6 +83,7 @@
   std::string WorkingDirectory;
   bool EscapeAllowMakeVars;
   bool EscapeOldStyle;
+  ImplicitDependsList ImplicitDepends;
 };
 
 #endif

Index: cmAddCustomCommandCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddCustomCommandCommand.cxx,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- cmAddCustomCommandCommand.cxx	4 Oct 2006 19:24:24 -0000	1.34
+++ cmAddCustomCommandCommand.cxx	17 Sep 2007 14:50:46 -0000	1.35
@@ -40,6 +40,8 @@
   std::vector<std::string> depends, outputs, output;
   bool verbatim = false;
   bool append = false;
+  std::string implicit_depends_lang;
+  cmCustomCommand::ImplicitDependsList implicit_depends;
 
   // Accumulate one command line at a time.
   cmCustomCommandLine currentLine;
@@ -54,6 +56,8 @@
     doing_command,
     doing_target,
     doing_depends,
+    doing_implicit_depends_lang,
+    doing_implicit_depends_file,
     doing_main_dependency,
     doing_output,
     doing_outputs,
@@ -131,6 +135,10 @@
       {
       doing = doing_main_dependency;
       }
+    else if (copy == "IMPLICIT_DEPENDS")
+      {
+      doing = doing_implicit_depends_lang;
+      }
     else if (copy == "COMMENT")
       {
       doing = doing_comment;
@@ -173,6 +181,25 @@
          case doing_main_dependency:
            main_dependency = copy;
            break;
+         case doing_implicit_depends_lang:
+           implicit_depends_lang = copy;
+           doing = doing_implicit_depends_file;
+           break;
+         case doing_implicit_depends_file:
+           {
+           // An implicit dependency starting point is also an
+           // explicit dependency.
+           depends.push_back(copy);
+
+           // Add the implicit dependency language and file.
+           cmCustomCommand::ImplicitDependsPair
+             entry(implicit_depends_lang, copy);
+           implicit_depends.push_back(entry);
+
+           // Switch back to looking for a language.
+           doing = doing_implicit_depends_lang;
+           }
+           break;
          case doing_command:
            currentLine.push_back(copy);
            break;
@@ -240,6 +267,7 @@
         {
         cc->AppendCommands(commandLines);
         cc->AppendDepends(depends);
+        cc->AppendImplicitDepends(implicit_depends);
         return true;
         }
       }
@@ -271,6 +299,29 @@
                                              commandLines, comment,
                                              working.c_str(), false,
                                              escapeOldStyle);
+
+    // Add implicit dependency scanning requests if any were given.
+    if(!implicit_depends.empty())
+      {
+      bool okay = false;
+      if(cmSourceFile* sf =
+         this->Makefile->GetSourceFileWithOutput(output[0].c_str()))
+        {
+        if(cmCustomCommand* cc = sf->GetCustomCommand())
+          {
+          okay = true;
+          cc->SetImplicitDepends(implicit_depends);
+          }
+        }
+      if(!okay)
+        {
+        cmOStringStream e;
+        e << "could not locate source file with a custom command producing \""
+          << output[0] << "\" even though this command tried to create it!";
+        this->SetError(e.str().c_str());
+        return false;
+        }
+      }
     }
   else
     {
@@ -279,6 +330,7 @@
                                              source.c_str(), commandLines,
                                              comment);
     }
+
   return true;
 }
 

Index: cmAddCustomCommandCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddCustomCommandCommand.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- cmAddCustomCommandCommand.h	17 Jul 2007 17:43:37 -0000	1.29
+++ cmAddCustomCommandCommand.h	17 Sep 2007 14:50:46 -0000	1.30
@@ -71,6 +71,7 @@
       "                     [COMMAND command2 [ARGS] [args2...] ...]\n"
       "                     [MAIN_DEPENDENCY depend]\n"
       "                     [DEPENDS [depends...]]\n"
+      "                     [IMPLICIT_DEPENDS <lang1> depend1 ...]\n"
       "                     [WORKING_DIRECTORY dir]\n"
       "                     [COMMENT comment] [VERBATIM] [APPEND])\n"
       "This defines a new command that can be executed during the build "
@@ -129,6 +130,15 @@
       "created as a file on disk it should be marked as SYMBOLIC with "
       "SET_SOURCE_FILES_PROPERTIES.\n"
 
+      "The IMPLICIT_DEPENDS option requests scanning of implicit "
+      "dependencies of an input file.  The language given specifies the "
+      "programming language whose corresponding dependency scanner should "
+      "be used.  Currently only C and CXX language scanners are supported. "
+      "Dependencies discovered from the scanning are added to those of "
+      "the custom command at build time.  Note that the IMPLICIT_DEPENDS "
+      "option is currently supported only for Makefile generators and "
+      "will be ignored by other generators."
+      "\n"
       "If COMMAND specifies an executable target (created by "
       "ADD_EXECUTABLE) it will automatically be replaced by the location "
       "of the executable created at build time.  Additionally a "



More information about the Cmake-commits mailing list