summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2004-11-02 22:38:09 (GMT)
committerBrad King <brad.king@kitware.com>2004-11-02 22:38:09 (GMT)
commit6de0ff4b009503d468b39c23f16e97cf76dbdb10 (patch)
tree803bff2b7e2cf82b0c2301c59d720371508a90e2
parent22cc48c5349d3c024fd92d0d4b43b443b7cf4f57 (diff)
downloadCMake-6de0ff4b009503d468b39c23f16e97cf76dbdb10.zip
CMake-6de0ff4b009503d468b39c23f16e97cf76dbdb10.tar.gz
CMake-6de0ff4b009503d468b39c23f16e97cf76dbdb10.tar.bz2
ENH: Added dependencies between libraries.
-rw-r--r--Source/cmLocalUnixMakefileGenerator2.cxx57
-rw-r--r--Source/cmLocalUnixMakefileGenerator2.h2
2 files changed, 44 insertions, 15 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx
index f3163e9..e2b59af 100644
--- a/Source/cmLocalUnixMakefileGenerator2.cxx
+++ b/Source/cmLocalUnixMakefileGenerator2.cxx
@@ -1266,7 +1266,7 @@ cmLocalUnixMakefileGenerator2
{
std::vector<std::string> commands;
- // Build list of dependencies. TODO: depend on other targets.
+ // Build list of dependencies.
std::vector<std::string> depends;
for(std::vector<std::string>::const_iterator obj = objects.begin();
obj != objects.end(); ++obj)
@@ -1275,19 +1275,9 @@ cmLocalUnixMakefileGenerator2
}
// Add dependencies on libraries that will be linked.
- std::set<cmStdString> 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<std::string> commands;
- // Build list of dependencies. TODO: depend on other targets.
+ // Build list of dependencies.
std::vector<std::string> depends;
for(std::vector<std::string>::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 =
@@ -1849,6 +1844,38 @@ void cmLocalUnixMakefileGenerator2::AppendFlags(std::string& flags,
//----------------------------------------------------------------------------
void
cmLocalUnixMakefileGenerator2
+::AppendLibDepends(const cmTarget& target,
+ std::vector<std::string>& depends)
+{
+ // Do not bother with dependencies for static libraries.
+ if(target.GetType() == cmTarget::STATIC_LIBRARY)
+ {
+ return;
+ }
+
+ // Keep track of dependencies already listed.
+ std::set<cmStdString> 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
::AppendLibDepend(std::vector<std::string>& depends, const char* name)
{
// There are a few cases for the name of the target:
diff --git a/Source/cmLocalUnixMakefileGenerator2.h b/Source/cmLocalUnixMakefileGenerator2.h
index 3ad7b25..3ff1de7 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<std::string>& depends);
void AppendLibDepend(std::vector<std::string>& depends, const char* name);
std::string GetRecursiveMakeCall(const char* tgt, bool silent);
void WriteJumpAndBuildRules(std::ostream& makefileStream);