From 16b65d86c9842b04cf1abda0604a23956f5a7e33 Mon Sep 17 00:00:00 2001
From: Bill Hoffman <bill.hoffman@kitware.com>
Date: Thu, 3 Mar 2005 18:46:52 -0500
Subject: ENH: try and debug the failed test on the continuous

---
 Source/cmOrderLinkDirectories.cxx                 | 20 +++++++++++++++-----
 Source/cmOrderLinkDirectories.h                   |  8 +++++++-
 Tests/Complex/Executable/complex.cxx              |  1 +
 Tests/ComplexOneConfig/Executable/complex.cxx     |  1 +
 Tests/ComplexRelativePaths/Executable/complex.cxx |  1 +
 5 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/Source/cmOrderLinkDirectories.cxx b/Source/cmOrderLinkDirectories.cxx
index df466e1..5c98b82 100644
--- a/Source/cmOrderLinkDirectories.cxx
+++ b/Source/cmOrderLinkDirectories.cxx
@@ -5,6 +5,12 @@
 
 
 //-------------------------------------------------------------------
+cmOrderLinkDirectories::cmOrderLinkDirectories()
+{
+  m_Debug = false;
+}
+
+//-------------------------------------------------------------------
 bool cmOrderLinkDirectories::LibraryInDirectory(const char* dir, 
                                                 const char* libIn)
 {
@@ -272,7 +278,11 @@ bool cmOrderLinkDirectories::DetermineLibraryPathOrder()
     }
   this->FindIndividualLibraryOrders();
   m_SortedSearchPaths.clear();
-  
+  if(m_Debug)
+    {
+    this->PrintMap("m_LibraryToDirectories", m_LibraryToDirectories);
+    this->PrintMap("m_DirectoryToAfterList", m_DirectoryToAfterList);
+    }
   this->OrderPaths(m_SortedSearchPaths); 
   // now turn libfoo.a into foo and foo.a into foo
   // This will prepare the link items for -litem 
@@ -317,18 +327,18 @@ void
 cmOrderLinkDirectories::PrintMap(const char* name,
                        std::map<cmStdString, std::vector<cmStdString> >& m)
 {
-  std::cerr << name << "\n";
+  std::cout << name << "\n";
   for(std::map<cmStdString, std::vector<cmStdString> >::iterator i =
         m.begin(); i != m.end();
       ++i)
     {
-    std::cerr << i->first << ":  ";
+    std::cout << i->first << ":  ";
     for(std::vector<cmStdString>::iterator l = i->second.begin();
         l != i->second.end(); ++l)
       {
-      std::cerr << *l << " ";
+      std::cout << *l << " ";
       }
-    std::cerr << "\n";
+    std::cout << "\n";
     }
 }
 
diff --git a/Source/cmOrderLinkDirectories.h b/Source/cmOrderLinkDirectories.h
index 09441b9..61e3823 100644
--- a/Source/cmOrderLinkDirectories.h
+++ b/Source/cmOrderLinkDirectories.h
@@ -47,6 +47,7 @@
 class cmOrderLinkDirectories
 {
 public:
+  cmOrderLinkDirectories();
   ///! set link information from the target
   void SetLinkInformation(const cmTarget&, cmTarget::LinkLibraryType,
                           const char* targetLibrary);
@@ -79,6 +80,11 @@ public:
     cmStdString Path;
   };
   friend struct cmOrderLinkDirectoriesCompare;
+  void DebugOn() 
+    {
+      m_Debug = true;
+    }
+  
 private:
   void CreateRegularExpressions();
   void DetermineLibraryPathOrder(std::vector<cmStdString>& searchPaths,
@@ -119,7 +125,7 @@ private:
   cmsys::RegularExpression m_RemoveLibraryExtension;
   cmsys::RegularExpression m_ExtractBaseLibraryName;
   cmsys::RegularExpression m_ExtractBaseLibraryNameNoPrefix;
-  
+  bool m_Debug;
 };
 
 #endif
diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx
index 3a9f150..6c62da3 100644
--- a/Tests/Complex/Executable/complex.cxx
+++ b/Tests/Complex/Executable/complex.cxx
@@ -52,6 +52,7 @@ bool TestLibraryOrder(bool shouldFail)
   std::vector<cmStdString> sortedpaths;
   std::vector<cmStdString> linkItems;
   cmOrderLinkDirectories orderLibs;
+  orderLibs.DebugOn();
   orderLibs.AddLinkExtension(".so");
   orderLibs.AddLinkExtension(".a");
   orderLibs.SetLinkInformation(target, cmTarget::GENERAL, "A");
diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx
index 3a9f150..6c62da3 100644
--- a/Tests/ComplexOneConfig/Executable/complex.cxx
+++ b/Tests/ComplexOneConfig/Executable/complex.cxx
@@ -52,6 +52,7 @@ bool TestLibraryOrder(bool shouldFail)
   std::vector<cmStdString> sortedpaths;
   std::vector<cmStdString> linkItems;
   cmOrderLinkDirectories orderLibs;
+  orderLibs.DebugOn();
   orderLibs.AddLinkExtension(".so");
   orderLibs.AddLinkExtension(".a");
   orderLibs.SetLinkInformation(target, cmTarget::GENERAL, "A");
diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx
index 3a9f150..6c62da3 100644
--- a/Tests/ComplexRelativePaths/Executable/complex.cxx
+++ b/Tests/ComplexRelativePaths/Executable/complex.cxx
@@ -52,6 +52,7 @@ bool TestLibraryOrder(bool shouldFail)
   std::vector<cmStdString> sortedpaths;
   std::vector<cmStdString> linkItems;
   cmOrderLinkDirectories orderLibs;
+  orderLibs.DebugOn();
   orderLibs.AddLinkExtension(".so");
   orderLibs.AddLinkExtension(".a");
   orderLibs.SetLinkInformation(target, cmTarget::GENERAL, "A");
-- 
cgit v0.12