summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalUnixMakefileGenerator3.cxx
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2005-05-25 19:09:06 (GMT)
committerKen Martin <ken.martin@kitware.com>2005-05-25 19:09:06 (GMT)
commita2f148936b335c6ebb31d2fa7bfef521a043330c (patch)
tree832c9d5cc87dae1136def3176b5b6a4a191ea8f1 /Source/cmGlobalUnixMakefileGenerator3.cxx
parentd7cbf3e1d6c3753b4d05cf43e0d9978ad154f5ff (diff)
downloadCMake-a2f148936b335c6ebb31d2fa7bfef521a043330c.zip
CMake-a2f148936b335c6ebb31d2fa7bfef521a043330c.tar.gz
CMake-a2f148936b335c6ebb31d2fa7bfef521a043330c.tar.bz2
ENH: added clean target for subdirs
Diffstat (limited to 'Source/cmGlobalUnixMakefileGenerator3.cxx')
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx52
1 files changed, 51 insertions, 1 deletions
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index d0ed30a..e5eb27c 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -477,7 +477,8 @@ cmGlobalUnixMakefileGenerator3
// write the directory rule
commands.clear();
- commands.push_back(lg->GetRecursiveMakeCall("Makefile",makeTargetName.c_str()));
+ commands.push_back
+ (lg->GetRecursiveMakeCall("Makefile",makeTargetName.c_str()));
// Write the rule.
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.",
@@ -488,7 +489,56 @@ cmGlobalUnixMakefileGenerator3
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.",
makeTargetName.c_str(), all_tgts, commands);
}
+
+ // now do the clean targets
+ if (lg->GetParent())
+ {
+ std::string dir = lg->GetMakefile()->GetStartOutputDirectory();
+ dir = lg->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,cmLocalGenerator::MAKEFILE);
+ makeTargetName = dir;
+ makeTargetName += "/clean";
+
+ std::vector<std::string> all_tgts;
+
+ // for all of out targets
+ for (cmTargets::const_iterator l = lg->GetMakefile()->GetTargets().begin();
+ l != lg->GetMakefile()->GetTargets().end(); l++)
+ {
+ if((l->second.GetType() == cmTarget::EXECUTABLE) ||
+ (l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
+ (l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
+ (l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
+ (l->second.GetType() == cmTarget::UTILITY))
+ {
+ // Add this to the list of depends rules in this directory.
+ std::string tname = lg->GetRelativeTargetDirectory(l->second);
+ tname += "/clean";
+ all_tgts.push_back(tname);
+ }
+ }
+ // write the directory rule add in the subdirs
+ std::vector<cmLocalGenerator *> subdirs = lg->GetChildren();
+
+ // for each subdir add the directory depend
+ std::vector<cmLocalGenerator *>::iterator sdi = subdirs.begin();
+ for (; sdi != subdirs.end(); ++sdi)
+ {
+ cmLocalUnixMakefileGenerator3 * lg2 =
+ static_cast<cmLocalUnixMakefileGenerator3 *>(*sdi);
+ dir = lg2->GetMakefile()->GetStartOutputDirectory();
+ dir += "/clean";
+ dir = lg2->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,
+ cmLocalGenerator::MAKEFILE);
+ all_tgts.push_back(dir);
+ }
+
+ // write the directory clean rule
+ commands.clear();
+ lg->WriteMakeRule(ruleFileStream, "Convenience name for directory clean.",
+ makeTargetName.c_str(), all_tgts, commands);
+ }
+
// for each target Generate the rule files for each target.
const cmTargets& targets = lg->GetMakefile()->GetTargets();
bool needRequiresStep = this->NeedRequiresStep(lg);