Browse Source

ENH: search for help modules in the correct place for install and source tree builds

Bill Hoffman 20 years ago
parent
commit
96a46bdb44
3 changed files with 11 additions and 8 deletions
  1. 4 6
      Source/cmDocumentation.cxx
  2. 4 1
      Source/cmDocumentation.h
  3. 3 1
      Source/cmakemain.cxx

+ 4 - 6
Source/cmDocumentation.cxx

@@ -217,8 +217,7 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
 bool cmDocumentation::CreateModulesSection()
 {
   this->ModulesSection.push_back(cmDocumentationModulesHeader[0]);
-#ifdef CMAKE_ROOT_DIR
-  std::string cmakeModules = CMAKE_ROOT_DIR;
+  std::string cmakeModules = this->CMakeRoot;
   cmakeModules += "/Modules";
   cmsys::Directory dir;
   dir.Load(cmakeModules.c_str());
@@ -237,7 +236,6 @@ bool cmDocumentation::CreateModulesSection()
         }
       }
     } 
-#endif
   cmDocumentationEntry e = { 0, 0, 0 };
   this->ModulesSection.push_back(e);
   return true;
@@ -997,8 +995,7 @@ bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os)
     os << "Argument --help-module needs a module name.\n";
     return false;
     }
-#ifdef CMAKE_ROOT_DIR
-  std::string cmakeModules = CMAKE_ROOT_DIR;
+  std::string cmakeModules = this->CMakeRoot;
   cmakeModules += "/Modules/";
   cmakeModules += this->SingleModuleName;
   cmakeModules += ".cmake";
@@ -1007,12 +1004,13 @@ bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os)
                                  this->SingleModuleName.c_str()))
     {
     this->PrintDocumentationCommand(os, &this->ModulesSection[0]);
+    os <<  "\n       Defined in: ";
+    os << cmakeModules << "\n";
     return true;
     }
   // Argument was not a module.  Complain.
   os << "Argument \"" << this->SingleModuleName.c_str()
      << "\" to --help-module is not a CMake module.";
-#endif
   return false;
 }
 

+ 4 - 1
Source/cmDocumentation.h

@@ -96,6 +96,9 @@ public:
   
   /** 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;}
 private:
   void PrintSection(std::ostream& os,
                     const cmDocumentationEntry* section,
@@ -161,7 +164,7 @@ private:
   std::string SeeAlsoString;
   std::string SingleCommand;
   std::string SingleModuleName;
-
+  std::string CMakeRoot;
   std::vector< char* > ModuleStrings;
   std::vector< const char* > Names;
   std::vector< const cmDocumentationEntry* > Sections;

+ 3 - 1
Source/cmakemain.cxx

@@ -141,9 +141,11 @@ int do_cmake(int ac, char** av)
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
   if(doc.CheckOptions(ac, av) || nocwd)
-    {
+    { 
     // Construct and print requested documentation.
     cmake hcm;
+    hcm.AddCMakePaths(av[0]);
+    doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT"));
     std::vector<cmDocumentationEntry> commands;
     std::vector<cmDocumentationEntry> generators;
     hcm.GetCommandDocumentation(commands);