summaryrefslogtreecommitdiffstats
path: root/Source/cmCableDefineSetCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2001-03-15 19:46:08 (GMT)
committerBrad King <brad.king@kitware.com>2001-03-15 19:46:08 (GMT)
commitb9a8948ec879f2e6a9a2f6220bba061c44c8d4bb (patch)
treee1c0cb53ed87742e9f2402dfa27cc529978a909b /Source/cmCableDefineSetCommand.cxx
parentf84972610ece8f7a82e8505625021ffbab5514e5 (diff)
downloadCMake-b9a8948ec879f2e6a9a2f6220bba061c44c8d4bb.zip
CMake-b9a8948ec879f2e6a9a2f6220bba061c44c8d4bb.tar.gz
CMake-b9a8948ec879f2e6a9a2f6220bba061c44c8d4bb.tar.bz2
ENH: Added SOURCE_FILES syntax to CABLE_DEFINE_SET command.
Diffstat (limited to 'Source/cmCableDefineSetCommand.cxx')
-rw-r--r--Source/cmCableDefineSetCommand.cxx85
1 files changed, 83 insertions, 2 deletions
diff --git a/Source/cmCableDefineSetCommand.cxx b/Source/cmCableDefineSetCommand.cxx
index 68d2d09..a22c9e0 100644
--- a/Source/cmCableDefineSetCommand.cxx
+++ b/Source/cmCableDefineSetCommand.cxx
@@ -36,14 +36,28 @@ bool cmCableDefineSetCommand::Invoke(std::vector<std::string>& args)
// The first argument is the name of the set.
m_SetName = *arg++;
- // The rest of the arguments are the elements to be placed in the set.
- for(; arg != args.end(); ++arg)
+ // All arguments until a "SOURCE_FILES" are the elements to be placed in
+ // the set.
+ for(; (arg != args.end()) && (*arg != "SOURCE_FILES"); ++arg)
{
// If the element cannot be added, return an error.
// This can occur when a tag is not specified and can't be generated.
if(!this->AddElement(*arg))
{ return false; }
}
+
+ // If we are not at the end, the "SOURCE_FILES" keyword has been
+ // encountered.
+ if(arg != args.end())
+ {
+ // The rest of the arguments are source files to be included in
+ // any package which references the set.
+ for(++arg; arg != args.end(); ++arg)
+ {
+ if(!this->AddSourceFile(*arg))
+ { return false; }
+ }
+ }
// Write this command's configuration output.
this->WriteConfiguration();
@@ -65,6 +79,17 @@ void cmCableDefineSetCommand::WriteConfiguration() const
// Output the code.
os << indent << "<Set name=\"" << m_SetName.c_str() << "\">" << std::endl;
+ for(std::vector<std::string>::const_iterator e = m_SourceHeaders.begin();
+ e != m_SourceHeaders.end(); ++e)
+ {
+ os << indent << " <File name=\"" << e->c_str() << "\"/>" << std::endl;
+ }
+ for(std::vector<std::string>::const_iterator e = m_InstantiationSources.begin();
+ e != m_InstantiationSources.end(); ++e)
+ {
+ os << indent << " <File name=\"" << e->c_str()
+ << "\" purpose=\"instantiate\"/>" << std::endl;
+ }
for(Elements::const_iterator e = m_Elements.begin();
e != m_Elements.end(); ++e)
{
@@ -217,3 +242,59 @@ cmCableDefineSetCommand::GenerateTag(const std::string& element,
return false;
}
+
+
+/**
+ * Add a source file associated with this set. Any package referencing
+ * this set will automatically include this source file.
+ */
+bool cmCableDefineSetCommand::AddSourceFile(const std::string& file)
+{
+ // We must locate the file in the include path so that we can detect
+ // its extension, and whether there is more than one to find.
+ std::string header = file+".h";
+ m_Makefile->ExpandVariablesInString(header);
+
+ // See if the file just exists here. The compiler's search path will
+ // locate it.
+ if(cmSystemTools::FileExists(header.c_str()))
+ {
+ m_SourceHeaders.push_back(header);
+ // See if there is a matching .txx as well.
+ std::string txx = file+".txx";
+ m_Makefile->ExpandVariablesInString(txx);
+ if(cmSystemTools::FileExists(txx.c_str()))
+ {
+ m_InstantiationSources.push_back(txx);
+ }
+ return true;
+ }
+
+ // We must look for the file in the include search path.
+ const std::vector<std::string>& includeDirectories =
+ m_Makefile->GetIncludeDirectories();
+
+ for(std::vector<std::string>::const_iterator dir = includeDirectories.begin();
+ dir != includeDirectories.end(); ++dir)
+ {
+ std::string path = *dir + "/" + header;
+ m_Makefile->ExpandVariablesInString(path);
+ if(cmSystemTools::FileExists(path.c_str()))
+ {
+ m_SourceHeaders.push_back(path);
+ // See if there is a matching .txx as well.
+ std::string txx = *dir + "/" + file + ".txx";
+ m_Makefile->ExpandVariablesInString(txx);
+ if(cmSystemTools::FileExists(txx.c_str()))
+ {
+ m_InstantiationSources.push_back(txx);
+ }
+ return true;
+ }
+ }
+
+ // We couldn't locate the source file. Report the error.
+ std::string err = "couldn't find source file " + header;
+ this->SetError(err.c_str());
+ return false;
+}