Merge topic 'vs7-empty-groups'

545fdec VS: Avoid empty source groups in some cases (#3474)
This commit is contained in:
Brad King 2013-03-12 13:46:47 -04:00 committed by CMake Topic Stage
commit 32fb1f2371
2 changed files with 23 additions and 9 deletions

View File

@ -1621,17 +1621,30 @@ cmLocalVisualStudio7Generator
return dir_max; return dir_max;
} }
void cmLocalVisualStudio7Generator bool cmLocalVisualStudio7Generator
::WriteGroup(const cmSourceGroup *sg, cmTarget& target, ::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
std::ostream &fout, const char *libName, std::ostream &fout, const char *libName,
std::vector<std::string> *configs) std::vector<std::string> *configs)
{ {
const std::vector<const cmSourceFile *> &sourceFiles = const std::vector<const cmSourceFile *> &sourceFiles =
sg->GetSourceFiles(); sg->GetSourceFiles();
// If the group is empty, don't write it at all. std::vector<cmSourceGroup> const& children = sg->GetGroupChildren();
if(sourceFiles.empty() && sg->GetGroupChildren().empty())
// Write the children to temporary output.
bool hasChildrenWithSources = false;
cmOStringStream tmpOut;
for(unsigned int i=0;i<children.size();++i)
{ {
return; if(this->WriteGroup(&children[i], target, tmpOut, libName, configs))
{
hasChildrenWithSources = true;
}
}
// If the group is empty, don't write it at all.
if(sourceFiles.empty() && !hasChildrenWithSources)
{
return false;
} }
// If the group has a name, write the header. // If the group has a name, write the header.
@ -1752,11 +1765,10 @@ void cmLocalVisualStudio7Generator
} }
} }
std::vector<cmSourceGroup> const& children = sg->GetGroupChildren(); // If the group has children with source files, write the children.
if(hasChildrenWithSources)
for(unsigned int i=0;i<children.size();++i)
{ {
this->WriteGroup(&children[i], target, fout, libName, configs); fout << tmpOut.str();
} }
// If the group has a name, write the footer. // If the group has a name, write the footer.
@ -1764,6 +1776,8 @@ void cmLocalVisualStudio7Generator
{ {
this->WriteVCProjEndGroup(fout); this->WriteVCProjEndGroup(fout);
} }
return true;
} }
void cmLocalVisualStudio7Generator:: void cmLocalVisualStudio7Generator::

View File

@ -109,7 +109,7 @@ private:
FCInfo& fcinfo); FCInfo& fcinfo);
void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target); void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target);
void WriteGroup(const cmSourceGroup *sg, bool WriteGroup(const cmSourceGroup *sg,
cmTarget& target, std::ostream &fout, cmTarget& target, std::ostream &fout,
const char *libName, std::vector<std::string> *configs); const char *libName, std::vector<std::string> *configs);