summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-08-24 18:21:49 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-08-24 18:21:49 (GMT)
commit9220e974017e34b53ba0650ec45c1a16566b6b88 (patch)
tree1e4ce1b543aa647e2ef7b79e2ab5c25dc1abf81c /Source/cmMakefile.cxx
parent9a4e7ea742e7ff8e1110f3fe55e98340cb309aef (diff)
downloadCMake-9220e974017e34b53ba0650ec45c1a16566b6b88.zip
CMake-9220e974017e34b53ba0650ec45c1a16566b6b88.tar.gz
CMake-9220e974017e34b53ba0650ec45c1a16566b6b88.tar.bz2
BUG: fix #4057 (which had several duplicates): handle recursivew source groups better, i.e. multiple sourcegroups with the same end component work now
Alex
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx148
1 files changed, 71 insertions, 77 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index ecfdf80..534ab02 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1448,105 +1448,99 @@ cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname)
}
#if defined(CMAKE_BUILD_WITH_CMAKE)
-cmSourceGroup* cmMakefile::GetSourceGroup(const char* name)
+cmSourceGroup* cmMakefile::GetSourceGroup(const std::vector<std::string>&name)
{
- // First see if the group exists. If so, replace its regular expression.
- for(std::vector<cmSourceGroup>::iterator sg = this->SourceGroups.begin();
- sg != this->SourceGroups.end(); ++sg)
+ cmSourceGroup* sg = 0;
+
+ // first look for source group starting with the same as the one we wants
+ for (std::vector<cmSourceGroup>::iterator sgIt = this->SourceGroups.begin();
+ sgIt != this->SourceGroups.end(); ++sgIt)
+
{
- std::string sgName = sg->GetName();
- if(sgName == name)
+ std::string sgName = sgIt->GetName();
+ if(sgName == name[0])
{
- return &(*sg);
+ sg = &(*sgIt);
+ break;
}
- else
- {
- cmSourceGroup *target = sg->lookupChild(name);
+ }
- if(target)
+ if(sg != 0)
+ {
+ // iterate through its children to find match source group
+ for(unsigned int i=1; i<name.size(); ++i)
+ {
+ sg = sg->lookupChild(name[i].c_str());
+ if(sg == 0)
{
- return target;
+ break;
}
}
}
- return 0;
+ return sg;
+}
+
+ void cmMakefile::AddSourceGroup(const char* name,
+ const char* regex,
+ const char* parent)
+{
+ if (name)
+ {
+ std::vector<std::string> nameVector;
+ nameVector.push_back(name);
+ AddSourceGroup(nameVector, regex, parent);
+ }
}
-void cmMakefile::AddSourceGroup(const char* name,
+void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
const char* regex,
const char *parent)
{
- // First see if the group exists. If so, replace its regular expression.
- for(unsigned int i=0;i<this->SourceGroups.size();++i)
+ cmSourceGroup* sg = 0;
+ std::vector<std::string> currentName;
+ int i = 0;
+ const int lastElement = name.size()-1;
+ for(i=lastElement; i>=0; --i)
{
- cmSourceGroup *sg = &this->SourceGroups[i];
-
- std::string sgName = sg->GetName();
- if(!parent)
+ currentName.assign(name.begin(), name.begin()+i+1);
+ sg = this->GetSourceGroup(currentName);
+ if(sg != 0)
{
- if(sgName == name)
- {
- if ( regex )
- {
- // We only want to set the regular expression. If there are already
- // source files in the group, we don't want to remove them.
- sg->SetGroupRegex(regex);
- }
- return;
- }
+ break;
}
- else
- {
- if(sgName == parent)
- {
- cmSourceGroup *localtarget = sg->lookupChild(name);
- if(localtarget)
- {
- if ( regex )
- {
- // We only want to set the regular expression. If there are
- // already source files in the group, we don't want to remove
- // them.
- localtarget->SetGroupRegex(regex);
- }
- }
- else
- {
- sg->AddChild(cmSourceGroup(name, regex));
- }
- return;
- }
- else
- {
- cmSourceGroup *localtarget = sg->lookupChild(parent);
+ }
- if(localtarget)
- {
- cmSourceGroup *addtarget = localtarget->lookupChild(name);
-
- if(addtarget)
- {
- if ( regex )
- {
- // We only want to set the regular expression. If there are
- // already source files in the group, we don't want to
- // remove them.
- addtarget->SetGroupRegex(regex);
- }
- }
- else
- {
- localtarget->AddChild(cmSourceGroup(name, regex));
- }
- return;
- }
- }
+ // i now contains the index of the last found component
+ if(i==lastElement)
+ {
+ // group already exists, replace its regular expression
+ if ( regex )
+ {
+ // We only want to set the regular expression. If there are already
+ // source files in the group, we don't want to remove them.
+ sg->SetGroupRegex(regex);
}
+ return;
+ }
+ else if(i==-1)
+ {
+ // group does not exists nor belong to any existing group
+ // add its first component
+ this->SourceGroups.push_back(cmSourceGroup(name[0].c_str(), regex));
+ sg = this->GetSourceGroup(currentName);
+ i = 0; // last component found
}
- // The group doesn't exist. Add it.
- this->SourceGroups.push_back(cmSourceGroup(name, regex));
+ // build the whole source group path
+ for(++i; i<=lastElement; ++i)
+ {
+ sg->AddChild(cmSourceGroup(name[i].c_str(), 0));
+ sg = sg->lookupChild(name[i].c_str());
+ }
+
+ sg->SetGroupRegex(regex);
}
+
#endif
void cmMakefile::AddExtraDirectory(const char* dir)