summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalUnixMakefileGenerator3.cxx
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2005-05-18 17:46:00 (GMT)
committerKen Martin <ken.martin@kitware.com>2005-05-18 17:46:00 (GMT)
commit78b5cca6e31c2eb3fc684652ecb03b0558a41c8e (patch)
tree0e8927ec0329f49858e11e9f8f7eafce1ced20be /Source/cmGlobalUnixMakefileGenerator3.cxx
parentaa73e653aaf282ecf412e0e6092a95adc8ce3641 (diff)
downloadCMake-78b5cca6e31c2eb3fc684652ecb03b0558a41c8e.zip
CMake-78b5cca6e31c2eb3fc684652ecb03b0558a41c8e.tar.gz
CMake-78b5cca6e31c2eb3fc684652ecb03b0558a41c8e.tar.bz2
ENH: another step to the next generator still not optimized yet
Diffstat (limited to 'Source/cmGlobalUnixMakefileGenerator3.cxx')
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx151
1 files changed, 129 insertions, 22 deletions
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 985e092..a4441b3 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -152,7 +152,19 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile()
for (i = 0; i < m_LocalGenerators.size(); ++i)
{
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
- this->WriteConvenienceRules(makefileStream,lg);
+ // are any parents excluded
+ bool exclude = false;
+ cmLocalGenerator *lg3 = lg;
+ while (lg3)
+ {
+ if (lg3->GetExcludeAll())
+ {
+ exclude = true;
+ break;
+ }
+ lg3 = lg3->GetParent();
+ }
+ this->WriteConvenienceRules(makefileStream,lg,exclude);
}
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[0]);
@@ -427,15 +439,17 @@ void cmGlobalUnixMakefileGenerator3
// Check the build system in this directory.
depends.push_back("cmake_check_build_system");
- commands.push_back(lg->GetRecursiveMakeCall("build.make","depend"));
- commands.push_back(lg->GetRecursiveMakeCall("build.make","requires"));
- commands.push_back(lg->GetRecursiveMakeCall("build.make",0));
+ commands.push_back(lg->GetRecursiveMakeCall("Makefile","all/all"));
// Write the rule.
lg->WriteMakeRule(makefileStream, "The main all target", "all", depends, commands);
- // write the clean
+ // Write and empty all/all:
commands.clear();
+ lg->WriteMakeRule(makefileStream, "The main recursive all target", "all/all",
+ commands, commands);
+
+ // write the clean
commands.push_back(lg->GetRecursiveMakeCall("clean.make",0));
lg->WriteMakeRule(makefileStream, "default clean target", "clean", depends, commands);
}
@@ -444,10 +458,11 @@ void cmGlobalUnixMakefileGenerator3
//----------------------------------------------------------------------------
void
cmGlobalUnixMakefileGenerator3
-::WriteConvenienceRules(std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3 *lg)
+::WriteConvenienceRules(std::ostream& ruleFileStream,
+ cmLocalUnixMakefileGenerator3 *lg,
+ bool exclude)
{
std::vector<std::string> depends;
- std::vector<std::string> tgt_depends;
std::vector<std::string> commands;
std::string localName;
std::string makeTargetName;
@@ -484,37 +499,129 @@ cmGlobalUnixMakefileGenerator3
if((t->second.GetType() == cmTarget::EXECUTABLE) ||
(t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
(t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
- (t->second.GetType() == cmTarget::MODULE_LIBRARY))
+ (t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
+ (t->second.GetType() == cmTarget::UTILITY))
{
// Add a rule to build the target by name.
localName = lg->GetRelativeTargetDirectory(t->second);
-
+
commands.clear();
- makeTargetName = localName;
- makeTargetName += "/depend";
- commands.push_back(lg->GetRecursiveMakeCall("build.make",makeTargetName.c_str()));
- makeTargetName = localName;
- makeTargetName += "/requires";
- commands.push_back(lg->GetRecursiveMakeCall("build.make",makeTargetName.c_str()));
+ if (t->second.GetType() != cmTarget::UTILITY)
+ {
+ makeTargetName = localName;
+ makeTargetName += "/depend";
+ commands.push_back(lg->GetRecursiveMakeCall("build.make",makeTargetName.c_str()));
+ makeTargetName = localName;
+ makeTargetName += "/requires";
+ commands.push_back(lg->GetRecursiveMakeCall("build.make",makeTargetName.c_str()));
+ }
makeTargetName = localName;
makeTargetName += "/build";
commands.push_back(lg->GetRecursiveMakeCall("build.make",makeTargetName.c_str()));
// Write the rule.
- lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
+ localName += "/all";
+ depends.clear();
+ this->AppendGlobalTargetDepends(depends,t->second);
+ lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
localName.c_str(), depends, commands);
+
+ // add the all/all dependency
+ if (!exclude && t->second.IsInAll())
+ {
+ depends.clear();
+ depends.push_back(localName);
+ commands.clear();
+ lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
+ "all/all", depends, commands);
+ }
+ // Write the rule.
+ commands.clear();
+ commands.push_back(lg->GetRecursiveMakeCall("Makefile",localName.c_str()));
+ depends.clear();
+ depends.push_back("cmake_check_build_system");
+ localName = lg->GetRelativeTargetDirectory(t->second);
+ lg->WriteMakeRule(ruleFileStream, "Build rule for subir invocation for target.",
+ localName.c_str(), depends, commands);
+
// Add a target with the canonical name (no prefix, suffix or path).
- if(localName != t->second.GetName())
+ commands.clear();
+ depends.clear();
+ depends.push_back(localName);
+ lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
+ t->second.GetName(), depends, commands);
+ }
+ }
+}
+
+
+
+//----------------------------------------------------------------------------
+void
+cmGlobalUnixMakefileGenerator3
+::AppendGlobalTargetDepends(std::vector<std::string>& depends,
+ const cmTarget& target)
+{
+ // Keep track of dependencies already listed.
+ std::set<cmStdString> emitted;
+
+ // A target should not depend on itself.
+ emitted.insert(target.GetName());
+
+ // Loop over all library dependencies but not for static libs
+ if (target.GetType() != cmTarget::STATIC_LIBRARY)
+ {
+ const cmTarget::LinkLibraries& tlibs = target.GetLinkLibraries();
+ for(cmTarget::LinkLibraries::const_iterator lib = tlibs.begin();
+ lib != tlibs.end(); ++lib)
+ {
+ // Don't emit the same library twice for this target.
+ if(emitted.insert(lib->first).second)
{
- commands.clear();
- tgt_depends.clear();
- tgt_depends.push_back(localName);
- lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
- t->second.GetName(), tgt_depends, commands);
+ // Add this dependency.
+ this->AppendAnyGlobalDepend(depends, lib->first.c_str());
}
}
}
+
+ // Loop over all utility dependencies.
+ const std::set<cmStdString>& tutils = target.GetUtilities();
+ for(std::set<cmStdString>::const_iterator util = tutils.begin();
+ util != tutils.end(); ++util)
+ {
+ // Don't emit the same utility twice for this target.
+ if(emitted.insert(*util).second)
+ {
+ // Add this dependency.
+ this->AppendAnyGlobalDepend(depends, util->c_str());
+ }
+ }
}
+//----------------------------------------------------------------------------
+void
+cmGlobalUnixMakefileGenerator3
+::AppendAnyGlobalDepend(std::vector<std::string>& depends, const char* name)
+{
+ cmTarget *result = 0;
+
+ // search each local generator until a match is found
+ unsigned int i;
+ for (i = 0; i < m_LocalGenerators.size(); ++i)
+ {
+ // search all targets
+ result = m_LocalGenerators[i]->GetMakefile()->FindTarget(name);
+ // if a match was found then ...
+ if (result)
+ {
+ cmLocalUnixMakefileGenerator3 *lg3 =
+ static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
+ std::string tgtName = lg3->GetRelativeTargetDirectory(*result);
+ tgtName += "/all";
+ depends.push_back(tgtName);
+ return;
+ }
+ }
+}