Attached Files | source_group_targets_dos.patch [^] (10,328 bytes) 2009-05-28 21:19 [Show Content] [Hide Content]diff -Naur cmake-2.6.4-orig/Source/cmLocalVisualStudio6Generator.cxx cmake-2.6.4-sg/Source/cmLocalVisualStudio6Generator.cxx
--- cmake-2.6.4-orig/Source/cmLocalVisualStudio6Generator.cxx 2009-05-12 10:05:16.627335600 -0700
+++ cmake-2.6.4-sg/Source/cmLocalVisualStudio6Generator.cxx 2009-05-07 15:10:24.186760700 -0700
@@ -307,7 +307,7 @@
// Add the file to the list of sources.
std::string source = (*i)->GetFullPath();
cmSourceGroup& sourceGroup =
- this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
+ this->Makefile->FindSourceGroup(source.c_str(), sourceGroups, target);
sourceGroup.AssignSource(*i);
// while we are at it, if it is a .rule file then for visual studio 6 we
// must generate it
diff -Naur cmake-2.6.4-orig/Source/cmLocalVisualStudio7Generator.cxx cmake-2.6.4-sg/Source/cmLocalVisualStudio7Generator.cxx
--- cmake-2.6.4-orig/Source/cmLocalVisualStudio7Generator.cxx 2009-05-12 10:05:16.642555200 -0700
+++ cmake-2.6.4-sg/Source/cmLocalVisualStudio7Generator.cxx 2009-05-07 19:16:37.482836000 -0700
@@ -1179,7 +1179,7 @@
this->ModuleDefinitionFile = (*i)->GetFullPath();
}
cmSourceGroup& sourceGroup =
- this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
+ this->Makefile->FindSourceGroup(source.c_str(), sourceGroups, target);
sourceGroup.AssignSource(*i);
}
@@ -1349,6 +1349,11 @@
{
return;
}
+ // If the group is target scoped and this is the wrong target, skip it
+ if(sg->HasTargetScope() && !sg->MatchTarget(target.GetName()))
+ {
+ return;
+ }
// If the group has a name, write the header.
std::string name = sg->GetName();
diff -Naur cmake-2.6.4-orig/Source/cmMakefile.cxx cmake-2.6.4-sg/Source/cmMakefile.cxx
--- cmake-2.6.4-orig/Source/cmMakefile.cxx 2009-05-12 10:05:16.749092400 -0700
+++ cmake-2.6.4-sg/Source/cmMakefile.cxx 2009-05-07 18:59:43.083078200 -0700
@@ -82,11 +82,11 @@
#if defined(CMAKE_BUILD_WITH_CMAKE)
this->AddSourceGroup("", "^.*$");
this->AddSourceGroup
- ("Source Files",
- "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|f|F|f90|for|fpp"
- "|ftn|m|mm|rc|def|r|odl|idl|hpj|bat)$");
+ ("Source Files",
+ "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|f|F|f90|for|fpp"
+ "|ftn|m|mm|rc|def|r|odl|idl|hpj|bat)$");
this->AddSourceGroup("Header Files",
- "\\.(h|hh|h\\+\\+|hm|hpp|hxx|in|txx|inl)$");
+ "\\.(h|hh|h\\+\\+|hm|hpp|hxx|in|txx|inl)$");
this->AddSourceGroup("CMake Rules", "\\.rule$");
this->AddSourceGroup("Resources", "\\.plist$");
#endif
@@ -2421,12 +2421,19 @@
*/
cmSourceGroup&
cmMakefile::FindSourceGroup(const char* source,
- std::vector<cmSourceGroup> &groups)
+ std::vector<cmSourceGroup> &groups,
+ cmTarget &target)
{
// First search for a group that lists the file explicitly.
for(std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin();
sg != groups.rend(); ++sg)
{
+ // Skip groups that are defined for other targets
+ if(sg->HasTargetScope() && !sg->MatchTarget(target.GetName()))
+ {
+ continue;
+ }
+
cmSourceGroup *result = sg->MatchChildrenFiles(source);
if(result)
{
@@ -2438,6 +2445,12 @@
for(std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin();
sg != groups.rend(); ++sg)
{
+ // Skip groups that are defined for other targets
+ if(sg->HasTargetScope() && !sg->MatchTarget(target.GetName()))
+ {
+ continue;
+ }
+
cmSourceGroup *result = sg->MatchChildrenRegex(source);
if(result)
{
diff -Naur cmake-2.6.4-orig/Source/cmMakefile.h cmake-2.6.4-sg/Source/cmMakefile.h
--- cmake-2.6.4-orig/Source/cmMakefile.h 2009-05-12 10:05:16.764312000 -0700
+++ cmake-2.6.4-sg/Source/cmMakefile.h 2009-05-07 15:28:18.992381900 -0700
@@ -689,7 +689,8 @@
* find what source group this source is in
*/
cmSourceGroup& FindSourceGroup(const char* source,
- std::vector<cmSourceGroup> &groups);
+ std::vector<cmSourceGroup> &groups,
+ cmTarget &target);
#endif
void RegisterData(cmData*);
diff -Naur cmake-2.6.4-orig/Source/cmSourceGroup.cxx cmake-2.6.4-sg/Source/cmSourceGroup.cxx
--- cmake-2.6.4-orig/Source/cmSourceGroup.cxx 2009-05-12 10:05:18.408028800 -0700
+++ cmake-2.6.4-sg/Source/cmSourceGroup.cxx 2009-05-07 19:32:19.836179900 -0700
@@ -20,6 +20,7 @@
{
public:
std::vector<cmSourceGroup> GroupChildren;
+ std::vector<std::string> Targets;
};
//----------------------------------------------------------------------------
@@ -68,7 +69,25 @@
this->GroupRegex.compile("^$");
}
}
-
+//----------------------------------------------------------------------------
+void cmSourceGroup::AddTarget(const char* target)
+{
+ if(!MatchTarget(target))
+ {
+ this->Internal->Targets.push_back(std::string(target));
+ }
+
+ // Set the target scope on all child groups
+ std::vector<cmSourceGroup>::iterator iter =
+ this->Internal->GroupChildren.begin();
+ std::vector<cmSourceGroup>::iterator end =
+ this->Internal->GroupChildren.end();
+ for(;iter!=end; ++iter)
+ {
+ iter->Internal->Targets = this->Internal->Targets;
+ }
+}
+
//----------------------------------------------------------------------------
void cmSourceGroup::AddGroupFile(const char* name)
{
@@ -80,7 +99,30 @@
{
return this->Name.c_str();
}
-
+
+//----------------------------------------------------------------------------
+bool cmSourceGroup::MatchTarget(const char* target) const
+{
+ std::vector<std::string>::const_iterator iter =
+ this->Internal->Targets.begin();
+ std::vector<std::string>::const_iterator end =
+ this->Internal->Targets.end();
+ for(;iter!=end; ++iter)
+ {
+ if (*iter == target)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+//----------------------------------------------------------------------------
+bool cmSourceGroup::HasTargetScope() const
+{
+ return this->Internal->Targets.size() > 0;
+}
+
//----------------------------------------------------------------------------
bool cmSourceGroup::MatchesRegex(const char* name)
{
@@ -111,6 +153,23 @@
}
//----------------------------------------------------------------------------
+bool cmSourceGroup::HasSourceFiles() const
+{
+ std::vector<cmSourceGroup>::iterator iter =
+ this->Internal->GroupChildren.begin();
+ std::vector<cmSourceGroup>::iterator end =
+ this->Internal->GroupChildren.end();
+ for(;iter!=end; ++iter)
+ {
+ if(!iter->HasSourceFiles())
+ {
+ return false;
+ }
+ }
+ return this->SourceFiles.size() > 0;
+}
+
+//----------------------------------------------------------------------------
std::vector<const cmSourceFile*>& cmSourceGroup::GetSourceFiles()
{
return this->SourceFiles;
@@ -119,6 +178,7 @@
//----------------------------------------------------------------------------
void cmSourceGroup::AddChild(cmSourceGroup child)
{
+ child.Internal->Targets = this->Internal->Targets;
this->Internal->GroupChildren.push_back(child);
}
diff -Naur cmake-2.6.4-orig/Source/cmSourceGroup.h cmake-2.6.4-sg/Source/cmSourceGroup.h
--- cmake-2.6.4-orig/Source/cmSourceGroup.h 2009-05-12 10:05:18.423248400 -0700
+++ cmake-2.6.4-sg/Source/cmSourceGroup.h 2009-05-07 19:18:43.232031200 -0700
@@ -46,6 +46,11 @@
* Set the regular expression for this group.
*/
void SetGroupRegex(const char* regex);
+
+ /**
+ * Add a target for which this group is valid.
+ */
+ void AddTarget(const char* target);
/**
* Add a file name to the explicit list of files for this group.
@@ -66,7 +71,17 @@
* Get the name of this group.
*/
const char* GetName() const;
-
+
+ /**
+ * Get the target for this group.
+ */
+ bool MatchTarget(const char* target) const;
+
+ /**
+ * True when a target has been set.
+ */
+ bool HasTargetScope() const;
+
/**
* Check if the given name matches this group's regex.
*/
@@ -100,14 +115,23 @@
*/
const std::vector<const cmSourceFile*>& GetSourceFiles() const;
std::vector<const cmSourceFile*>& GetSourceFiles();
+
+ /**
+ * True when this group or any of it's children have source files
+ */
+ bool HasSourceFiles() const;
+ /**
+ * Get the list of the source files that have been assigned to this
+ * source group.
+ */
std::vector<cmSourceGroup> const& GetGroupChildren() const;
private:
/**
* The name of the source group.
*/
std::string Name;
-
+
/**
* The regular expression matching the files in the group.
*/
diff -Naur cmake-2.6.4-orig/Source/cmSourceGroupCommand.cxx cmake-2.6.4-sg/Source/cmSourceGroupCommand.cxx
--- cmake-2.6.4-orig/Source/cmSourceGroupCommand.cxx 2009-05-12 10:05:18.438468000 -0700
+++ cmake-2.6.4-sg/Source/cmSourceGroupCommand.cxx 2009-05-07 19:34:21.804149300 -0700
@@ -88,6 +88,7 @@
// Process arguments.
bool doingFiles = false;
+ bool doingTarget = false;
for(unsigned int i=1; i < args.size(); ++i)
{
if(args[i] == "REGULAR_EXPRESSION")
@@ -105,6 +106,12 @@
}
doingFiles = false;
}
+ else if(args[i] == "TARGET")
+ {
+ // Next argument will specify a target
+ doingFiles = false;
+ doingTarget = true;
+ }
else if(args[i] == "FILES")
{
// Next arguments will specify files.
@@ -123,6 +130,15 @@
src = cmSystemTools::CollapseFullPath(src.c_str());
sg->AddGroupFile(src.c_str());
}
+ else if(doingTarget)
+ {
+ // Get the root ancestor as it will propagate this change to all children
+ std::vector<std::string> root(folders.begin(), folders.begin()+1);
+ cmSourceGroup * sgTop = this->Makefile->GetSourceGroup(root);
+ sgTop->AddTarget(args[i].c_str());
+ doingTarget = false;
+ doingFiles = false;
+ }
else
{
cmOStringStream err;
writeGroups.patch [^] (2,679 bytes) 2013-02-04 04:54 [Show Content] [Hide Content]commit eed476621dc8acb90c5e80e509015b363eb8f4c4
Author: Anton Helwart <sidtrun@gmail.com>
Date: Mon Feb 4 10:35:48 2013 +0100
Fixing a bug in WriteGroup methode of VS7 generator.
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index f9df861..50a3d44 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1603,17 +1603,30 @@ cmLocalVisualStudio7Generator
return dir_max;
}
-void cmLocalVisualStudio7Generator
+bool cmLocalVisualStudio7Generator
::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
std::ostream &fout, const char *libName,
std::vector<std::string> *configs)
{
const std::vector<const cmSourceFile *> &sourceFiles =
sg->GetSourceFiles();
+ std::vector<cmSourceGroup> const& children = sg->GetGroupChildren();
+
+ // Write the children to temporary output.
+ bool hasChildrenWithSources = false;
+ cmOStringStream tmpOut;
+ for(unsigned int i=0;i<children.size();++i)
+ {
+ 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() && sg->GetGroupChildren().empty())
+ if(sourceFiles.empty() && !hasChildrenWithSources)
{
- return;
+ return false;
}
// If the group has a name, write the header.
@@ -1734,11 +1747,10 @@ void cmLocalVisualStudio7Generator
}
}
- std::vector<cmSourceGroup> const& children = sg->GetGroupChildren();
-
- for(unsigned int i=0;i<children.size();++i)
+ // If the group has children with source files, write the children.
+ if(hasChildrenWithSources)
{
- this->WriteGroup(&children[i], target, fout, libName, configs);
+ fout << tmpOut.str();
}
// If the group has a name, write the footer.
@@ -1746,6 +1758,8 @@ void cmLocalVisualStudio7Generator
{
this->WriteVCProjEndGroup(fout);
}
+
+ return true;
}
void cmLocalVisualStudio7Generator::
diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h
index 5a1d208..d9e2ef0 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -109,7 +109,7 @@ private:
FCInfo& fcinfo);
void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target);
- void WriteGroup(const cmSourceGroup *sg,
+ bool WriteGroup(const cmSourceGroup *sg,
cmTarget& target, std::ostream &fout,
const char *libName, std::vector<std::string> *configs);
|