summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2002-03-01 20:49:10 (GMT)
committerBrad King <brad.king@kitware.com>2002-03-01 20:49:10 (GMT)
commitac74d513827b7575319e37911888c1d6816ddd8a (patch)
tree40753bf0eed56af7a82d7601e5772c548fe2e80d
parent3da299a796f6905662cbee7361e9a59c3c59c7b5 (diff)
downloadCMake-ac74d513827b7575319e37911888c1d6816ddd8a.zip
CMake-ac74d513827b7575319e37911888c1d6816ddd8a.tar.gz
CMake-ac74d513827b7575319e37911888c1d6816ddd8a.tar.bz2
ENH: Added support for including extra files in generated header to get access to export macros of derived projects.
-rw-r--r--Source/cmVTKMakeInstantiatorCommand.cxx27
-rw-r--r--Source/cmVTKMakeInstantiatorCommand.h9
2 files changed, 31 insertions, 5 deletions
diff --git a/Source/cmVTKMakeInstantiatorCommand.cxx b/Source/cmVTKMakeInstantiatorCommand.cxx
index 320edf7..1f9edc5 100644
--- a/Source/cmVTKMakeInstantiatorCommand.cxx
+++ b/Source/cmVTKMakeInstantiatorCommand.cxx
@@ -37,6 +37,7 @@ cmVTKMakeInstantiatorCommand
std::vector<cmStdString> inSourceLists;
m_ExportMacro = "-";
unsigned int groupSize = 10;
+ bool includesMode = false;
// Find the path of the files to be generated.
std::string filePath = m_Makefile->GetCurrentOutputDirectory();
@@ -46,6 +47,7 @@ cmVTKMakeInstantiatorCommand
{
if(args[i] == "GROUP_SIZE")
{
+ includesMode = false;
if(++i < args.size())
{
std::string gSize = args[i].c_str();
@@ -60,6 +62,7 @@ cmVTKMakeInstantiatorCommand
}
else if(args[i] == "HEADER_LOCATION")
{
+ includesMode = false;
if(++i < args.size())
{
headerPath = args[i];
@@ -73,6 +76,7 @@ cmVTKMakeInstantiatorCommand
}
else if(args[i] == "EXPORT_MACRO")
{
+ includesMode = false;
if(++i < args.size())
{
m_ExportMacro = args[i];
@@ -84,12 +88,24 @@ cmVTKMakeInstantiatorCommand
return false;
}
}
- // If not an option, it must be another input source list name.
+ else if(args[i] == "INCLUDES")
+ {
+ includesMode = true;
+ }
+ // If not an option, it must be another input source list name or
+ // an include file.
else
{
std::string s = args[i];
m_Makefile->ExpandVariablesInString(s);
- inSourceLists.push_back(s);
+ if(!includesMode)
+ {
+ inSourceLists.push_back(s);
+ }
+ else
+ {
+ m_Includes.push_back(s);
+ }
}
}
@@ -223,7 +239,12 @@ cmVTKMakeInstantiatorCommand
"#ifndef __" << m_ClassName.c_str() << "_h\n"
"#define __" << m_ClassName.c_str() << "_h\n"
"\n"
- "#include \"vtkInstantiator.h\"\n"
+ "#include \"vtkInstantiator.h\"\n";
+ for(unsigned int i=0;i < m_Includes.size();++i)
+ {
+ os << "#include \"" << m_Includes[i].c_str() << "\"\n";
+ }
+ os <<
"\n"
"class " << m_ClassName.c_str() << "Initialize;\n"
"\n"
diff --git a/Source/cmVTKMakeInstantiatorCommand.h b/Source/cmVTKMakeInstantiatorCommand.h
index ca83954..ee738ce 100644
--- a/Source/cmVTKMakeInstantiatorCommand.h
+++ b/Source/cmVTKMakeInstantiatorCommand.h
@@ -55,7 +55,8 @@ public:
"VTK_MAKE_INSTANTIATOR(className outSourceList\n"
" src-list1 [src-list2 ..]\n"
" EXPORT_MACRO exportMacro\n"
- " [HEADER_LOCATION dir] [GROUP_SIZE groupSize])\n"
+ " [HEADER_LOCATION dir] [GROUP_SIZE groupSize]\n"
+ " [INCLUDES [file1 file2 ..]])\n"
"Generates a new class with the given name and adds its files to the\n"
"given outSourceList. It registers the classes from the other given\n"
"source lists with vtkInstantiator when it is loaded. The output\n"
@@ -71,7 +72,10 @@ public:
"The GROUP_SIZE option must be followed by a positive integer.\n"
"As an implementation detail, the registered creation functions may\n"
"be split up into multiple files. The groupSize option specifies\n"
- "the number of classes per file. Its default is 10.";
+ "the number of classes per file. Its default is 10. The INCLUDES\n"
+ "option can be followed by a list of zero or more files. These files\n"
+ "will be #included by the generated instantiator header, and can be\n"
+ "used to gain access to the specified exportMacro in the C++ code.";
}
cmTypeMacro(cmVTKMakeInstantiatorCommand, cmCommand);
@@ -79,6 +83,7 @@ public:
protected:
std::string m_ClassName;
std::string m_ExportMacro;
+ std::vector<cmStdString> m_Includes;
std::vector<cmStdString> m_Classes;
std::string GenerateCreationFileName(unsigned int group);