Procházet zdrojové kódy

ENH: Added INCLUDE_REGULAR_EXPRESSION command to set regular expression used in dependency checking.

Brad King před 25 roky
rodič
revize
be4db9150c

+ 2 - 0
Source/cmCommands.cxx

@@ -41,6 +41,7 @@
 #include "cmWrapTclCommand.cxx"
 #include "cmBuildSharedLibrariesCommand.cxx"
 #include "cmUtilitySourceCommand.cxx"
+#include "cmIncludeRegularExpressionCommand.cxx"
 
 void GetPredefinedCommands(std::list<cmCommand*>& commands)
 {
@@ -79,6 +80,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
   commands.push_back(new cmWrapTclCommand);
   commands.push_back(new cmBuildSharedLibrariesCommand);
   commands.push_back(new cmUtilitySourceCommand);
+  commands.push_back(new cmIncludeRegularExpressionCommand);
 }
 
   

+ 30 - 0
Source/cmIncludeRegularExpressionCommand.cxx

@@ -0,0 +1,30 @@
+/*=========================================================================
+
+  Program:   Insight Segmentation & Registration Toolkit
+  Module:    $RCSfile$
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
+
+
+  Copyright (c) 2000 National Library of Medicine
+  All rights reserved.
+
+  See COPYRIGHT.txt for copyright details.
+
+=========================================================================*/
+#include "cmIncludeRegularExpressionCommand.h"
+
+// cmIncludeRegularExpressionCommand
+bool cmIncludeRegularExpressionCommand::Invoke(std::vector<std::string>& args)
+{
+  if(args.size() != 1)
+    {
+    this->SetError("called with incorrect number of arguments");
+    return false;
+    }
+  m_Makefile->SetIncludeRegularExpression(args[0].c_str());
+  
+  return true;
+}
+

+ 84 - 0
Source/cmIncludeRegularExpressionCommand.h

@@ -0,0 +1,84 @@
+/*=========================================================================
+
+  Program:   Insight Segmentation & Registration Toolkit
+  Module:    $RCSfile$
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
+
+
+  Copyright (c) 2000 National Library of Medicine
+  All rights reserved.
+
+  See COPYRIGHT.txt for copyright details.
+
+=========================================================================*/
+#ifndef cmIncludeRegularExpressionCommand_h
+#define cmIncludeRegularExpressionCommand_h
+
+#include "cmStandardIncludes.h"
+#include "cmCommand.h"
+
+/** \class cmIncludeRegularExpressionCommand
+ * \brief Set the regular expression for following #includes.
+ *
+ * cmIncludeRegularExpressionCommand is used to specify the regular expression
+ * used by cmMakeDepend to determine whether to follow a #include file in
+ * dependency checking.
+ */
+class cmIncludeRegularExpressionCommand : public cmCommand
+{
+public:
+  /**
+   * This is a virtual constructor for the command.
+   */
+  virtual cmCommand* Clone() 
+    {
+    return new cmIncludeRegularExpressionCommand;
+    }
+
+  /**
+   * This is called when the command is first encountered in
+   * the CMakeLists.txt file.
+   */
+  virtual bool Invoke(std::vector<std::string>& args);
+  
+  /**
+   * The name of the command as specified in CMakeList.txt.
+   */
+  virtual const char* GetName() {return "INCLUDE_REGULAR_EXPRESSION";}
+
+  /**
+   * This determines if the command gets propagated down
+   * to makefiles located in subdirectories.
+   */
+  virtual bool IsInherited() 
+    {
+    return true;
+    }
+
+  /**
+   * Succinct documentation.
+   */
+  virtual const char* GetTerseDocumentation() 
+    {
+    return "Set the regular expression used for dependency checking.";
+    }
+  
+  /**
+   * More documentation.
+   */
+  virtual const char* GetFullDocumentation()
+    {
+    return
+      "INCLUDE_REGULAR_EXPRESSION(regex)\n"
+      "Sets the regular expression used in dependency checking.  Only\n"
+      "include files matching this regular expression will be traced.";
+    }
+  
+  cmTypeMacro(cmIncludeRegularExpressionCommand, cmCommand);
+};
+
+
+
+#endif

+ 5 - 8
Source/cmMakeDepend.cxx

@@ -20,14 +20,7 @@
 cmMakeDepend::cmMakeDepend()
 {
   m_Verbose = false;
-  m_IncludeFileRegularExpression.compile("^itk|^vtk|^vnl|^vcl|^f2c");
-}
-
-
-// only files matching this regular expression with be considered
-void cmMakeDepend::SetIncludeRegularExpression(const char* prefix)
-{
-  m_IncludeFileRegularExpression.compile(prefix);
+  m_IncludeFileRegularExpression.compile("");
 }
 
 
@@ -49,6 +42,10 @@ cmMakeDepend::~cmMakeDepend()
 void cmMakeDepend::SetMakefile(cmMakefile* makefile)
 {
   m_Makefile = makefile;
+
+  // Now extract the include file regular expression from the makefile.
+  m_IncludeFileRegularExpression.compile(
+    m_Makefile->m_IncludeFileRegularExpression.c_str());
   
   // Now extract any include paths from the makefile flags
   std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();

+ 0 - 6
Source/cmMakeDepend.h

@@ -103,12 +103,6 @@ public:
    */
   void DoDepends();
 
-  /** 
-   * Set a regular expression that include files must match
-   * in order to be considered as part of the depend information.
-   */
-  void SetIncludeRegularExpression(const char* regex);
-
   /**
    * Add a directory to the search path for include files.
    */

+ 3 - 0
Source/cmMakefile.cxx

@@ -26,6 +26,9 @@
 // default is not to be building executables
 cmMakefile::cmMakefile()
 {
+  // Setup the default include file regular expression.
+  m_IncludeFileRegularExpression = "^itk|^vtk|^vnl|^vcl|^f2c";
+  
   m_DefineFlags = " ";
   m_MakefileGenerator = 0;
   this->AddDefaultCommands();

+ 11 - 1
Source/cmMakefile.h

@@ -246,7 +246,16 @@ public:
       return m_CurrentOutputDirectory.c_str();
     }
   //@}
-  
+
+  /** 
+   * Set a regular expression that include files must match
+   * in order to be considered as part of the depend information.
+   */
+  void SetIncludeRegularExpression(const char* regex)
+    {
+      m_IncludeFileRegularExpression = regex;
+    }
+
   /**
    * Specify the name of the library that is built by this makefile.
    */
@@ -429,6 +438,7 @@ protected:
   std::vector<std::string> m_LinkLibraries;
   std::vector<std::string> m_LinkLibrariesWin32;
   std::vector<std::string> m_LinkLibrariesUnix;
+  std::string m_IncludeFileRegularExpression;
   std::string m_DefineFlags;
   std::vector<customCommand> m_CustomCommands;
   typedef std::map<std::string, cmCommand*> RegisteredCommandsMap;