diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx index f3163e984..e2b59afba 100644 --- a/Source/cmLocalUnixMakefileGenerator2.cxx +++ b/Source/cmLocalUnixMakefileGenerator2.cxx @@ -1266,7 +1266,7 @@ cmLocalUnixMakefileGenerator2 { std::vector commands; - // Build list of dependencies. TODO: depend on other targets. + // Build list of dependencies. std::vector depends; for(std::vector::const_iterator obj = objects.begin(); obj != objects.end(); ++obj) @@ -1275,19 +1275,9 @@ cmLocalUnixMakefileGenerator2 } // Add dependencies on libraries that will be linked. - std::set emitted; - emitted.insert(target.GetName()); - 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) - { - // Add this dependency. - this->AppendLibDepend(depends, lib->first.c_str()); - } - } + this->AppendLibDepends(target, depends); + + // Add a dependency on the rule file itself. depends.push_back(ruleFileName); // Construct the full path to the executable that will be generated. @@ -1500,13 +1490,18 @@ cmLocalUnixMakefileGenerator2 // code duplication. std::vector commands; - // Build list of dependencies. TODO: depend on other targets. + // Build list of dependencies. std::vector depends; for(std::vector::const_iterator obj = objects.begin(); obj != objects.end(); ++obj) { depends.push_back(*obj); } + + // Add dependencies on libraries that will be linked. + this->AppendLibDepends(target, depends); + + // Add a dependency on the rule file itself. depends.push_back(ruleFileName); const char* linkLanguage = @@ -1846,6 +1841,38 @@ void cmLocalUnixMakefileGenerator2::AppendFlags(std::string& flags, } } +//---------------------------------------------------------------------------- +void +cmLocalUnixMakefileGenerator2 +::AppendLibDepends(const cmTarget& target, + std::vector& depends) +{ + // Do not bother with dependencies for static libraries. + if(target.GetType() == cmTarget::STATIC_LIBRARY) + { + return; + } + + // Keep track of dependencies already listed. + std::set emitted; + + // A target should not depend on itself. + emitted.insert(target.GetName()); + + // Loop over all dependencies. + 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) + { + // Add this dependency. + this->AppendLibDepend(depends, lib->first.c_str()); + } + } +} + //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator2 diff --git a/Source/cmLocalUnixMakefileGenerator2.h b/Source/cmLocalUnixMakefileGenerator2.h index 3ad7b2579..3ff1de753 100644 --- a/Source/cmLocalUnixMakefileGenerator2.h +++ b/Source/cmLocalUnixMakefileGenerator2.h @@ -124,6 +124,8 @@ protected: void AddSharedFlags(std::string& flags, const char* lang, bool shared); void AddConfigVariableFlags(std::string& flags, const char* var); void AppendFlags(std::string& flags, const char* newFlags); + void AppendLibDepends(const cmTarget& target, + std::vector& depends); void AppendLibDepend(std::vector& depends, const char* name); std::string GetRecursiveMakeCall(const char* tgt, bool silent); void WriteJumpAndBuildRules(std::ostream& makefileStream);