[cmake-commits] hoffman committed cmGlobalGenerator.cxx 1.170 1.171
cmGlobalGenerator.h 1.71 1.72 cmMakefile.cxx 1.376 1.377
cmPropertyMap.cxx 1.6 1.7 cmTarget.cxx 1.129 1.130
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Mar 13 13:23:10 EST 2007
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv18269/Source
Modified Files:
cmGlobalGenerator.cxx cmGlobalGenerator.h cmMakefile.cxx
cmPropertyMap.cxx cmTarget.cxx
Log Message:
ENH: add project to target map, not used yet, but created
Index: cmGlobalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- cmGlobalGenerator.h 7 Mar 2007 20:15:46 -0000 1.71
+++ cmGlobalGenerator.h 13 Mar 2007 18:23:08 -0000 1.72
@@ -198,7 +198,7 @@
// has been populated.
void FillProjectMap();
bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen);
-
+ void FillProjectToTargetMap();
void CreateDefaultGlobalTargets(cmTargets* targets);
cmTarget CreateGlobalTarget(const char* name, const char* message,
const cmCustomCommandLines* commandLines,
@@ -214,6 +214,7 @@
std::vector<cmLocalGenerator *> LocalGenerators;
// map from project name to vector of local generators in that project
std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap;
+ std::map<cmStdString, std::set<cmTarget*> > ProjectToTargetMap;
// Set of named installation components requested by the project.
std::set<cmStdString> InstallComponents;
Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.376
retrieving revision 1.377
diff -u -d -r1.376 -r1.377
--- cmMakefile.cxx 12 Mar 2007 14:26:59 -0000 1.376
+++ cmMakefile.cxx 13 Mar 2007 18:23:08 -0000 1.377
@@ -1120,8 +1120,10 @@
// set the subdirs start dirs
lg2->GetMakefile()->SetStartDirectory(srcPath);
lg2->GetMakefile()->SetStartOutputDirectory(binPath);
- lg2->GetMakefile()->SetProperty("EXCLUDE_FROM_ALL",
- (excludeFromAll) ? "TRUE" : "FALSE");
+ if(excludeFromAll)
+ {
+ lg2->GetMakefile()->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
+ }
lg2->GetMakefile()->SetPreOrder(preorder);
if (immediate)
@@ -1342,8 +1344,10 @@
// over changes in CMakeLists.txt, making the information stale and
// hence useless.
target.ClearDependencyInformation( *this, lname );
- target.SetProperty("EXCLUDE_FROM_ALL",
- (excludeFromAll) ? "TRUE" : "FALSE");
+ if(excludeFromAll)
+ {
+ target.SetProperty("EXCLUDE_FROM_ALL", "TRUE");
+ }
target.GetSourceLists() = srcs;
this->AddGlobalLinkInformation(lname, target);
cmTargets::iterator it =
@@ -1358,8 +1362,10 @@
cmTarget target;
target.SetType(cmTarget::EXECUTABLE, exeName);
target.SetMakefile(this);
- target.SetProperty("EXCLUDE_FROM_ALL",
- (excludeFromAll) ?"TRUE" : "FALSE");
+ if(excludeFromAll)
+ {
+ target.SetProperty("EXCLUDE_FROM_ALL", "TRUE");
+ }
target.GetSourceLists() = srcs;
this->AddGlobalLinkInformation(exeName, target);
cmTargets::iterator it =
@@ -2600,11 +2606,6 @@
{
return;
}
- if (!value)
- {
- value = "NOTFOUND";
- }
-
this->Properties.SetProperty(prop,value,cmProperty::DIRECTORY);
}
@@ -2653,6 +2654,11 @@
this->Properties.GetPropertyValue(prop, scope, chain);
if (chain)
{
+ if(this->LocalGenerator->GetParent())
+ {
+ return this->LocalGenerator->GetParent()->GetMakefile()->
+ GetProperty(prop, scope);
+ }
return this->GetCMakeInstance()->GetProperty(prop,scope);
}
@@ -2782,5 +2788,6 @@
"A property on a target that indicates if the target is excluded "
"from the default build target. If it is not, then with a Makefile "
"for example typing make will couse this target to be built as well. "
- "The same concept applies to the default build of other generators.");
+ "The same concept applies to the default build of other generators.",
+ true);
}
Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.170
retrieving revision 1.171
diff -u -d -r1.170 -r1.171
--- cmGlobalGenerator.cxx 12 Mar 2007 14:26:59 -0000 1.170
+++ cmGlobalGenerator.cxx 13 Mar 2007 18:23:08 -0000 1.171
@@ -1055,6 +1055,116 @@
}
while (lg);
}
+ // now create project to target map
+ // This will make sure that targets have all the
+ // targets they depend on as part of the build.
+ this->FillProjectToTargetMap();
+}
+
+
+// Build a map that contains a the set of targets used by each project
+void cmGlobalGenerator::FillProjectToTargetMap()
+{
+ // loop over each project in the build
+ for(std::map<cmStdString,
+ std::vector<cmLocalGenerator*> >::iterator m =
+ this->ProjectMap.begin();
+ m != this->ProjectMap.end(); ++m)
+ {
+ std::vector<cmLocalGenerator*>& lgs = m->second;
+ if(lgs.size() == 0)
+ {
+ continue;
+ }
+ cmStdString const & projectName = m->first;
+ cmMakefile* projectMakefile = lgs[0]->GetMakefile();
+ // get the current EXCLUDE_FROM_ALL value from projectMakefile
+ const char* exclude = 0;
+ std::string excludeSave;
+ bool chain = false;
+ exclude =
+ projectMakefile->GetProperties().
+ GetPropertyValue("EXCLUDE_FROM_ALL",
+ cmProperty::DIRECTORY, chain);
+ if(exclude)
+ {
+ excludeSave = exclude;
+ }
+ // Set EXCLUDE_FROM_ALL to FALSE for the top level makefile because
+ // in the current project nothing is excluded yet
+ projectMakefile->SetProperty("EXCLUDE_FROM_ALL", "FALSE");
+ // now loop over all cmLocalGenerators in this project and pull
+ // out all the targets that depend on each other, even if those
+ // targets come from a target that is excluded.
+ for(std::vector<cmLocalGenerator*>::iterator lg =
+ lgs.begin(); lg != lgs.end(); ++lg)
+ {
+ cmMakefile* mf = (*lg)->GetMakefile();
+ cmTargets& targets = mf->GetTargets();
+ for(cmTargets::iterator t = targets.begin();
+ t != targets.end(); ++t)
+ {
+ cmTarget& target = t->second;
+ // if the target is in all then add it to the project
+ if(!target.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
+ {
+ // add this target to the project
+ this->ProjectToTargetMap[projectName].insert(&target);
+ // now get all the targets that link to this target and
+ // add them
+ cmTarget::LinkLibraryVectorType::const_iterator j, jend;
+ j = target.GetLinkLibraries().begin();
+ jend = target.GetLinkLibraries().end();
+ for(;j!= jend; ++j)
+ {
+ cmTarget* depTarget = this->FindTarget(0, j->first.c_str());
+ if(depTarget)
+ {
+ this->ProjectToTargetMap[projectName].insert(depTarget);
+ }
+ }
+ // Now add any utility targets used by this target
+ std::set<cmStdString>::const_iterator i, end;
+ i = target.GetUtilities().begin();
+ end = target.GetUtilities().end();
+ for(;i!= end; ++i)
+ {
+ cmTarget* depTarget = this->FindTarget(0, i->c_str());
+ if(depTarget)
+ {
+ this->ProjectToTargetMap[projectName].insert(depTarget);
+ }
+ }
+ }
+ }
+ }
+ // Now restore the EXCLUDE_FROM_ALL property on the project top
+ // makefile
+ if(exclude)
+ {
+ exclude = excludeSave.c_str();
+ }
+ projectMakefile->SetProperty("EXCLUDE_FROM_ALL", exclude);
+ }
+ // dump the map for debug purposes
+ // right now this map is not being used, but it was
+ // checked in to avoid constant conflicts.
+ // It is also the first step to creating sub projects
+ // that contain all of the targets they need.
+#if 0
+ std::map<cmStdString, std::set<cmTarget*> >::iterator i =
+ this->ProjectToTargetMap.begin();
+ for(; i != this->ProjectToTargetMap.end(); ++i)
+ {
+ std::cerr << i->first << "\n";
+ std::set<cmTarget*>::iterator t = i->second.begin();
+ for(; t != i->second.end(); ++t)
+ {
+ cmTarget* target = *t;
+ std::cerr << "\t" << target->GetName() << "\n";
+ }
+ }
+#endif
}
Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- cmTarget.cxx 9 Mar 2007 20:14:27 -0000 1.129
+++ cmTarget.cxx 13 Mar 2007 18:23:08 -0000 1.130
@@ -122,7 +122,8 @@
"A property on a target that indicates if the target is excluded "
"from the default build target. If it is not, then with a Makefile "
"for example typing make will couse this target to be built as well. "
- "The same concept applies to the default build of other generators.");
+ "The same concept applies to the default build of other generators.",
+ true);
cm->DefineProperty
("INSTALL_NAME_DIR", cmProperty::TARGET,
@@ -1313,7 +1314,6 @@
}
return 0;
}
-
bool chain = false;
const char *retVal =
this->Properties.GetPropertyValue(prop, scope, chain);
@@ -1321,7 +1321,6 @@
{
return this->Makefile->GetProperty(prop,scope);
}
-
return retVal;
}
Index: cmPropertyMap.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPropertyMap.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cmPropertyMap.cxx 4 Jan 2007 18:02:43 -0000 1.6
+++ cmPropertyMap.cxx 13 Mar 2007 18:23:08 -0000 1.7
@@ -43,7 +43,11 @@
{
return;
}
-
+ if(!value)
+ {
+ this->erase(name);
+ return;
+ }
#ifdef CMAKE_STRICT
if (!this->CMakeInstance)
{
@@ -89,7 +93,7 @@
::GetPropertyValue(const char *name,
cmProperty::ScopeType scope,
bool &chain) const
-{
+{
chain = false;
if (!name)
{
@@ -142,7 +146,6 @@
}
return 0;
}
-
return it->second.GetValue();
}
More information about the Cmake-commits
mailing list