summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2002-03-29 15:06:30 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2002-03-29 15:06:30 (GMT)
commit8b3b49a010219eeba327d882e1fe38f721b6bed8 (patch)
tree095e639d4828f7a0e4e905c1f14d5fe32369e923 /Source/cmMakefile.cxx
parent627ab62ce093d8f50ed0ba50a1dd1081165b19f1 (diff)
downloadCMake-8b3b49a010219eeba327d882e1fe38f721b6bed8.zip
CMake-8b3b49a010219eeba327d882e1fe38f721b6bed8.tar.gz
CMake-8b3b49a010219eeba327d882e1fe38f721b6bed8.tar.bz2
ENH: major change, the cmMakefile now contains a master list of cmSourceFile objects, the source lists reference the list via pointers, also you can now set properties on a file, like compile flags, abstract, etc.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx60
1 files changed, 47 insertions, 13 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index aa2b80b..b713395 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -104,6 +104,11 @@ void cmMakefile::AddDefaultCommands()
cmMakefile::~cmMakefile()
{
+ for(std::vector<cmSourceFile*>::iterator i = m_SourceFiles.begin();
+ i != m_SourceFiles.end(); ++i)
+ {
+ delete *i;
+ }
for(unsigned int i=0; i < m_UsedCommands.size(); i++)
{
delete m_UsedCommands[i];
@@ -153,10 +158,10 @@ void cmMakefile::Print() const
l != m_Sources.end(); l++)
{
std::cout << " Class list named: " << l->first << std::endl;
- for(std::vector<cmSourceFile>::const_iterator i = l->second.begin();
+ for(std::vector<cmSourceFile*>::const_iterator i = l->second.begin();
i != l->second.end(); i++)
{
- i->Print();
+ (*i)->Print();
}
}
@@ -361,12 +366,12 @@ cmSourceFile *cmMakefile::GetSource(const char *srclist, const char *cname)
return 0;
}
// find the class
- for (std::vector<cmSourceFile>::iterator i = sl->second.begin();
+ for (std::vector<cmSourceFile*>::iterator i = sl->second.begin();
i != sl->second.end(); ++i)
{
- if (i->GetSourceName() == cname)
+ if ((*i)->GetSourceName() == cname)
{
- return &(*i);
+ return *i;
}
}
return 0;
@@ -423,24 +428,23 @@ void cmMakefile::GenerateMakefile()
void cmMakefile::AddSource(cmSourceFile& cmfile, const char *srclist)
{
- m_Sources[srclist].push_back(cmfile);
+ m_Sources[srclist].push_back(this->AddSource(cmfile));
}
-struct FindSrcByName : std::binary_function<cmSourceFile, cmSourceFile, bool>
+struct FindSrcByName : std::binary_function<cmSourceFile*, cmSourceFile*, bool>
{
public:
- bool operator () (const cmSourceFile &f, const cmSourceFile &test) const
+ bool operator () (const cmSourceFile *f, const cmSourceFile *test) const
{
- return !strcmp(f.GetSourceName().c_str(),test.GetSourceName().c_str());
+ return (f->GetSourceName() == test->GetSourceName());
}
};
void cmMakefile::RemoveSource(cmSourceFile& cmfile,const char *srclist)
{
- std::vector<cmSourceFile> &maplist = m_Sources[srclist];
- std::vector<cmSourceFile>::iterator f =
- std::find_if(maplist.begin(), maplist.end(), std::bind2nd(FindSrcByName(),cmfile));
-// std::vector<cmSourceFile>::iterator f = find_if(maplist.begin(), maplist.end(), matches(srclist);
+ std::vector<cmSourceFile*> &maplist = m_Sources[srclist];
+ std::vector<cmSourceFile*>::iterator f =
+ std::find_if(maplist.begin(), maplist.end(), std::bind2nd(FindSrcByName(),&cmfile));
if (f!=maplist.end())
{
maplist.erase(f);
@@ -1288,3 +1292,33 @@ cmData* cmMakefile::LookupData(const char* name) const
}
}
+cmSourceFile* cmMakefile::GetSource(const char* sourceName)
+{
+ for(std::vector<cmSourceFile*>::iterator i = m_SourceFiles.begin();
+ i != m_SourceFiles.end(); ++i)
+ {
+ if((*i)->GetSourceName() == sourceName
+ || (*i)->GetSourceName()+"."+(*i)->GetSourceExtension() == sourceName)
+ {
+ return *i;
+ }
+ }
+ return 0;
+}
+
+
+
+cmSourceFile* cmMakefile::AddSource(cmSourceFile const&sf)
+{
+ // check to see if it exists
+ cmSourceFile* ret = this->GetSource(sf.GetSourceName().c_str());
+ if(ret && ret->GetSourceExtension() == sf.GetSourceExtension())
+ {
+ return ret;
+ }
+ ret = new cmSourceFile(sf);
+ m_SourceFiles.push_back(ret);
+ return ret;
+}
+
+