ENH: Added support for including extra files in generated header to get access to export macros of derived projects.
This commit is contained in:
parent
3da299a796
commit
ac74d51382
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue