Index: Source/cmDocumentation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentation.cxx,v
retrieving revision 1.49
diff -u -r1.49 cmDocumentation.cxx
--- Source/cmDocumentation.cxx	9 Aug 2007 12:48:56 -0000	1.49
+++ Source/cmDocumentation.cxx	18 Sep 2007 16:19:53 -0000
@@ -303,6 +303,21 @@
     {
     delete [] *i;
     }
+
+  for(std::vector< char* >::iterator i = this->RootPaths.begin();
+      i != this->RootPaths.end(); ++i)
+    {
+    delete [] *i;
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmDocumentation::AddRootPath(const char* _root)
+{
+  std::cerr << __FUNCTION__ << " " << _root << "\n" << std::endl;
+
+  char* proot = strcpy(new char[strlen(_root)+1], _root);
+  this->RootPaths.push_back(proot);
 }
 
 //----------------------------------------------------------------------------
@@ -407,30 +422,34 @@
 //----------------------------------------------------------------------------
 bool cmDocumentation::CreateModulesSection()
 {
-  std::string cmakeModules = this->CMakeRoot;
-  cmakeModules += "/Modules";
-  cmsys::Directory dir;
-  dir.Load(cmakeModules.c_str());
-  if (dir.GetNumberOfFiles() > 0)
+  for(std::vector< char* >::iterator i = RootPaths.begin();
+      i != RootPaths.end(); ++i)
     {
-    this->ModulesSection.Append(cmDocumentationModulesHeader[0]);
-    for(unsigned int i = 0; i < dir.GetNumberOfFiles(); ++i)
-      {
-      std::string fname = dir.GetFile(i);
-      if(fname.length() > 6)
+      std::string cmakeModules = *i;
+      cmakeModules += "/Modules";
+      cmsys::Directory dir;
+      dir.Load(cmakeModules.c_str());
+      if (dir.GetNumberOfFiles() > 0)
         {
-        if(fname.substr(fname.length()-6, 6) == ".cmake")
+        this->ModulesSection.Append(cmDocumentationModulesHeader[0]);
+        for(unsigned int i = 0; i < dir.GetNumberOfFiles(); ++i)
           {
-          std::string moduleName = fname.substr(0, fname.length()-6);
-          std::string path = cmakeModules;
-          path += "/";
-          path += fname;
-          this->CreateSingleModule(path.c_str(), moduleName.c_str());
-          }
+          std::string fname = dir.GetFile(i);
+          if(fname.length() > 6)
+            {
+            if(fname.substr(fname.length()-6, 6) == ".cmake")
+              {
+              std::string moduleName = fname.substr(0, fname.length()-6);
+              std::string path = cmakeModules;
+              path += "/";
+              path += fname;
+              this->CreateSingleModule(path.c_str(), moduleName.c_str());
+              }
+            }
+          } 
+        cmDocumentationEntry e = { 0, 0, 0, 0 };
+        this->ModulesSection.Append(e);
         }
-      } 
-    cmDocumentationEntry e = { 0, 0, 0 };
-    this->ModulesSection.Append(e);
     }
   return true;
 }
@@ -508,11 +527,13 @@
         }
       char* pname = strcpy(new char[strlen(moduleName)+1], moduleName);
       char* ptext = strcpy(new char[text.length()+1], text.c_str());
+      char* ppath = strcpy(new char[strlen(fname)+1], fname);
       this->ModuleStrings.push_back(pname);
       this->ModuleStrings.push_back(ptext);
       char* pbrief = strcpy(new char[brief.length()+1], brief.c_str());
       this->ModuleStrings.push_back(pbrief);
-      cmDocumentationEntry e = { pname, pbrief, ptext };
+      this->ModuleStrings.push_back(ppath);
+      cmDocumentationEntry e = { pname, pbrief, ptext , ppath};
       this->ModulesSection.Append(e);
       return true;
       }
@@ -1391,23 +1412,32 @@
     os << "Argument --help-module needs a module name.\n";
     return false;
     }
-  std::string cmakeModules = this->CMakeRoot;
-  cmakeModules += "/Modules/";
-  cmakeModules += this->CurrentArgument;
-  cmakeModules += ".cmake";
-  if(cmSystemTools::FileExists(cmakeModules.c_str())
-     && this->CreateSingleModule(cmakeModules.c_str(), 
-                                 this->CurrentArgument.c_str()))
-    {
-    this->PrintDocumentationCommand(os, this->ModulesSection.GetEntries());
-    os <<  "\n       Defined in: ";
-    os << cmakeModules << "\n";
-    return true;
+  bool found = false;
+  for(std::vector< char* >::iterator i = RootPaths.begin();
+      i != RootPaths.end(); ++i)
+    {
+      std::string cmakeModules = *i;
+      cmakeModules += "/Modules/";
+      cmakeModules += this->CurrentArgument;
+      cmakeModules += ".cmake";
+      if(cmSystemTools::FileExists(cmakeModules.c_str())
+         && this->CreateSingleModule(cmakeModules.c_str(), 
+                                     this->CurrentArgument.c_str()))
+        {
+          this->PrintDocumentationCommand(os, this->ModulesSection.GetEntries());
+          os <<  "\n       Defined in: ";
+          os << cmakeModules << "\n";
+          found = true;
+        }
+    }
+  if (!found) 
+    {
+      // Argument was not a module.  Complain.
+      os << "Argument \"" << this->CurrentArgument.c_str()
+         << "\" to --help-module is not a CMake module.";
+      return false;
     }
-  // Argument was not a module.  Complain.
-  os << "Argument \"" << this->CurrentArgument.c_str()
-     << "\" to --help-module is not a CMake module.";
-  return false;
+  return true;
 }
 
 //----------------------------------------------------------------------------
@@ -1527,7 +1557,9 @@
     {
     if(entry->name)
       {
-      os << entry->name << std::endl;
+      char buf[1024];
+      sprintf(buf,"%-20s %s",entry->name,entry->path);
+      os << buf << std::endl;
       }
     }
   return true;
Index: Source/cmDocumentation.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentation.h,v
retrieving revision 1.26
diff -u -r1.26 cmDocumentation.h
--- Source/cmDocumentation.h	11 Jul 2007 19:53:58 -0000	1.26
+++ Source/cmDocumentation.h	6 Aug 2007 19:28:05 -0000
@@ -170,8 +170,8 @@
   /** Clear all previously added sections of help.  */
   void ClearSections();  
   
-  /** Set cmake root so we can find installed files */
-  void SetCMakeRoot(const char* root)  { this->CMakeRoot = root;}
+  /** add root path so we can find installed files */ 
+  void AddRootPath(const char* root);                            
   
   static Form GetFormFromFilename(const std::string& filename);
 
@@ -260,7 +260,7 @@
   std::map<cmProperty::ScopeType, cmSection*> PropertySections;
   
   std::string SeeAlsoString;
-  std::string CMakeRoot;
+  std::vector< char* > RootPaths;
   std::vector< char* > ModuleStrings;
   std::vector< const char* > Names;
   std::vector< const cmDocumentationEntry* > Sections;
Index: Source/cmStandardIncludes.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmStandardIncludes.h,v
retrieving revision 1.67
diff -u -r1.67 cmStandardIncludes.h
--- Source/cmStandardIncludes.h	29 Aug 2006 14:27:50 -0000	1.67
+++ Source/cmStandardIncludes.h	18 Sep 2007 16:27:47 -0000
@@ -319,6 +319,7 @@
   const char* name;
   const char* brief;
   const char* full;
+  const char* path;
 };
 
 /** Data structure to represent a single command line.  */
Index: Source/cmakemain.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmakemain.cxx,v
retrieving revision 1.66
diff -u -r1.66 cmakemain.cxx
--- Source/cmakemain.cxx	19 Jul 2007 15:13:01 -0000	1.66
+++ Source/cmakemain.cxx	18 Sep 2007 16:09:04 -0000
@@ -276,7 +276,34 @@
     // Construct and print requested documentation.
     cmake hcm;
     hcm.AddCMakePaths(av[0]);
-    doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT"));
+
+    std::string rootPath;
+    rootPath = cmSystemTools::GetCurrentWorkingDirectory();
+    doc.AddRootPath(rootPath.c_str());
+    rootPath += "/cmake";
+    doc.AddRootPath(rootPath.c_str());
+
+    std::string cachePath;
+    cachePath = cmSystemTools::GetCurrentWorkingDirectory();
+    std::string path = cmSystemTools::CollapseFullPath(cachePath.c_str());
+    cmSystemTools::ConvertToUnixSlashes(path);
+    std::string cacheFile = path;
+    cacheFile += "/CMakeCache.txt";
+    if(cmSystemTools::FileExists(cacheFile.c_str()))
+      {
+        cmCacheManager cachem;
+        cmCacheManager::CacheIterator it = cachem.NewIterator();
+        if(cachem.LoadCache(cachePath.c_str()) &&
+            it.Find("CMAKE_HOME_DIRECTORY"))
+          {
+            rootPath = it.GetValue();
+            doc.AddRootPath(rootPath.c_str());
+            rootPath += "/cmake";
+            doc.AddRootPath(rootPath.c_str());
+         }
+      }
+    doc.AddRootPath(hcm.GetCacheDefinition("CMAKE_ROOT"));
+   
     std::vector<cmDocumentationEntry> commands;
     std::vector<cmDocumentationEntry> compatCommands;
     std::vector<cmDocumentationEntry> globalProperties;
