Index: cmComputeLinkDepends.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.cxx,v
retrieving revision 1.20
diff -u -r1.20 cmComputeLinkDepends.cxx
--- cmComputeLinkDepends.cxx	6 Aug 2008 21:48:53 -0000	1.20
+++ cmComputeLinkDepends.cxx	8 Aug 2008 12:32:14 -0000
@@ -537,6 +537,15 @@
   // Track inferred dependency sets implied by this list.
   std::map<int, DependSet> dependSets;
 
+  // Compute which library configuration to link.
+  cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED;
+  if(this->Config && cmSystemTools::UpperCase(this->Config) == "DEBUG")
+    {
+    linkType = cmTarget::DEBUG;
+    }
+  cmTarget::LinkLibraryType llt = cmTarget::GENERAL;
+  bool haveLLT = false;
+
   // Loop over the libraries linked directly by the depender.
   for(std::vector<std::string>::const_iterator li = libs.begin();
       li != libs.end(); ++li)
@@ -548,41 +557,59 @@
       {
       continue;
       }
-
-    // Add a link entry for this item.
-    int dependee_index = this->AddLinkEntry(item);
-
-    // The depender must come before the dependee.
-    if(depender_index >= 0)
+    if(item == "debug")
       {
-      this->EntryConstraintGraph[dependee_index].push_back(depender_index);
+      llt = cmTarget::DEBUG;
+      haveLLT = true;
       }
-    else
+    else if(item == "optimized")
       {
-      // This is a direct dependency of the target being linked.
-      this->OriginalEntries.push_back(dependee_index);
+      llt = cmTarget::OPTIMIZED;
+      haveLLT = true;
       }
+    else if(item == "general")
+      {
+      llt = cmTarget::GENERAL;
+      haveLLT = true;
+      }
+    else if(!haveLLT || llt == cmTarget::GENERAL || llt == linkType ) 
+      {
+      haveLLT = false;
 
-    // Update the inferred dependencies for earlier items.
-    for(std::map<int, DependSet>::iterator dsi = dependSets.begin();
-        dsi != dependSets.end(); ++dsi)
-      {
-      // Add this item to the inferred dependencies of other items.
-      // Target items are never inferred dependees because unknown
-      // items are outside libraries that should not be depending on
-      // targets.
-      if(!this->EntryList[dependee_index].Target &&
-         dependee_index != dsi->first)
+      // Add a link entry for this item.
+      int dependee_index = this->AddLinkEntry(item);
+
+      // The depender must come before the dependee.
+      if(depender_index >= 0)
         {
-        dsi->second.insert(dependee_index);
+        this->EntryConstraintGraph[dependee_index].push_back(depender_index);
+        }
+      else
+        {
+        // This is a direct dependency of the target being linked.
+        this->OriginalEntries.push_back(dependee_index);
         }
-      }
 
-    // If this item needs to have dependencies inferred, do so.
-    if(this->InferredDependSets[dependee_index])
-      {
-      // Make sure an entry exists to hold the set for the item.
-      dependSets[dependee_index];
+      // Update the inferred dependencies for earlier items.
+      for(std::map<int, DependSet>::iterator dsi = dependSets.begin();
+          dsi != dependSets.end(); ++dsi)
+        {
+        // Add this item to the inferred dependencies of other items.
+        // Target items are never inferred dependees because unknown
+        // items are outside libraries that should not be depending on
+        // targets.
+        if(!this->EntryList[dependee_index].Target &&
+           dependee_index != dsi->first)
+          {
+          dsi->second.insert(dependee_index);
+          }
+        }
+      // If this item needs to have dependencies inferred, do so.
+      if(this->InferredDependSets[dependee_index])
+        {
+        // Make sure an entry exists to hold the set for the item.
+        dependSets[dependee_index];
+        }
       }
     }
 

