summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2001-03-15 18:09:16 -0500
committerBrad King <brad.king@kitware.com>2001-03-15 18:09:16 -0500
commitbe4db9150c6b3bd8a6c39d48fa693a6209c34740 (patch)
tree033cb0942c8e0b7eb43afbfaef19ec403ab56083
parentb9a8948ec879f2e6a9a2f6220bba061c44c8d4bb (diff)
downloadcmake-be4db9150c6b3bd8a6c39d48fa693a6209c34740.tar.gz
ENH: Added INCLUDE_REGULAR_EXPRESSION command to set regular expression used in dependency checking.
-rw-r--r--Source/cmCommands.cxx2
-rw-r--r--Source/cmIncludeRegularExpressionCommand.cxx30
-rw-r--r--Source/cmIncludeRegularExpressionCommand.h84
-rw-r--r--Source/cmMakeDepend.cxx13
-rw-r--r--Source/cmMakeDepend.h6
-rw-r--r--Source/cmMakefile.cxx3
-rw-r--r--Source/cmMakefile.h12
7 files changed, 135 insertions, 15 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index f4abf326c1..7bdcaac7c1 100644
--- a/Source/cmCommands.cxx
+++ b/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);
}
diff --git a/Source/cmIncludeRegularExpressionCommand.cxx b/Source/cmIncludeRegularExpressionCommand.cxx
new file mode 100644
index 0000000000..89a40df183
--- /dev/null
+++ b/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;
+}
+
diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h
new file mode 100644
index 0000000000..688ad60230
--- /dev/null
+++ b/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
diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx
index 4280442072..5bd34cfe54 100644
--- a/Source/cmMakeDepend.cxx
+++ b/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();
diff --git a/Source/cmMakeDepend.h b/Source/cmMakeDepend.h
index 596588921e..e7e6f5d6be 100644
--- a/Source/cmMakeDepend.h
+++ b/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.
*/
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 815421f93b..8248f5e20a 100644
--- a/Source/cmMakefile.cxx
+++ b/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();
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 293d2bfb3f..21ce96f6bd 100644
--- a/Source/cmMakefile.h
+++ b/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;