cmDocumentation.cxx 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmDocumentation.h"
  14. #include "cmSystemTools.h"
  15. #include "cmVersion.h"
  16. #include <cmsys/Directory.hxx>
  17. //----------------------------------------------------------------------------
  18. static const char *cmDocumentationStandardOptions[][3] =
  19. {
  20. {"--copyright [file]", "Print the CMake copyright and exit.",
  21. "If a file is specified, the copyright is written into it."},
  22. {"--help", "Print usage information and exit.",
  23. "Usage describes the basic command line interface and its options."},
  24. {"--help-full [file]", "Print full help and exit.",
  25. "Full help displays most of the documentation provided by the UNIX "
  26. "man page. It is provided for use on non-UNIX platforms, but is "
  27. "also convenient if the man page is not installed. If a file is "
  28. "specified, the help is written into it."},
  29. {"--help-html [file]", "Print full help in HTML format.",
  30. "This option is used by CMake authors to help produce web pages. "
  31. "If a file is specified, the help is written into it."},
  32. {"--help-man [file]", "Print full help as a UNIX man page and exit.",
  33. "This option is used by the cmake build to generate the UNIX man page. "
  34. "If a file is specified, the help is written into it."},
  35. {"--version [file]", "Show program name/version banner and exit.",
  36. "If a file is specified, the version is written into it."},
  37. {0,0,0}
  38. };
  39. //----------------------------------------------------------------------------
  40. static const char *cmModulesDocumentationDescription[][3] =
  41. {
  42. {0,
  43. " CMake Modules - Modules coming with CMake, the Cross-Platform Makefile "
  44. "Generator.", 0},
  45. // CMAKE_DOCUMENTATION_OVERVIEW,
  46. {0,
  47. "This is the documentation for the modules and scripts coming with CMake. "
  48. "Using these modules you can check the computer system for "
  49. "installed software packages, features of the compiler and the "
  50. "existance of headers to name just a few.", 0},
  51. {0,0,0}
  52. };
  53. //----------------------------------------------------------------------------
  54. static const char *cmCustomModulesDocumentationDescription[][3] =
  55. {
  56. {0,
  57. " Custom CMake Modules - Additional Modules for CMake.", 0},
  58. // CMAKE_DOCUMENTATION_OVERVIEW,
  59. {0,
  60. "This is the documentation for additional modules and scripts for CMake. "
  61. "Using these modules you can check the computer system for "
  62. "installed software packages, features of the compiler and the "
  63. "existance of headers to name just a few.", 0},
  64. {0,0,0}
  65. };
  66. //----------------------------------------------------------------------------
  67. static const char *cmPropertiesDocumentationDescription[][3] =
  68. {
  69. {0,
  70. " CMake Properties - Properties supported by CMake, "
  71. "the Cross-Platform Makefile Generator.", 0},
  72. // CMAKE_DOCUMENTATION_OVERVIEW,
  73. {0,
  74. "This is the documentation for the properties supported by CMake. "
  75. "Properties can have different scopes. They can either be assigned to a "
  76. "source file, a directory, a target or globally to CMake. By modifying the "
  77. "values of properties the behaviour of the buildsystem can be customized.",
  78. 0},
  79. {0,0,0}
  80. };
  81. //----------------------------------------------------------------------------
  82. static const char *cmCompatCommandsDocumentationDescription[][3] =
  83. {
  84. {0,
  85. " CMake Compatibility Listfile Commands - "
  86. "Obsolete commands supported by CMake for compatibility.", 0},
  87. // CMAKE_DOCUMENTATION_OVERVIEW,
  88. {0,
  89. "This is the documentation for now obsolete listfile commands from previous "
  90. "CMake versions, which are still supported for compatibility reasons. You "
  91. "should instead use the newer, faster and shinier new commands. ;-)", 0},
  92. {0,0,0}
  93. };
  94. //----------------------------------------------------------------------------
  95. static const char *cmDocumentationModulesHeader[][3] =
  96. {
  97. {0,
  98. "The following modules are provided with CMake. "
  99. "They can be used with INCLUDE(ModuleName).", 0},
  100. {0,0,0}
  101. };
  102. //----------------------------------------------------------------------------
  103. static const char *cmDocumentationCustomModulesHeader[][3] =
  104. {
  105. {0,
  106. "The following modules are also available for CMake. "
  107. "They can be used with INCLUDE(ModuleName).", 0},
  108. {0,0,0}
  109. };
  110. //----------------------------------------------------------------------------
  111. static const char *cmDocumentationGeneratorsHeader[][3] =
  112. {
  113. {0,
  114. "The following generators are available on this platform:", 0},
  115. {0,0,0}
  116. };
  117. //----------------------------------------------------------------------------
  118. static const char *cmDocumentationStandardSeeAlso[][3] =
  119. {
  120. {0,
  121. "The following resources are available to get help using CMake:", 0},
  122. {"Home Page",
  123. "http://www.cmake.org",
  124. "The primary starting point for learning about CMake."},
  125. {"Frequently Asked Questions",
  126. "http://www.cmake.org/Wiki/CMake_FAQ",
  127. "A Wiki is provided containing answers to frequently asked questions. "},
  128. {"Online Documentation",
  129. "http://www.cmake.org/HTML/Documentation.html",
  130. "Links to available documentation may be found on this web page."},
  131. {"Mailing List",
  132. "http://www.cmake.org/HTML/MailingLists.html",
  133. "For help and discussion about using cmake, a mailing list is provided at "
  134. "[email protected]. "
  135. "The list is member-post-only but one may sign up on the CMake web page. "
  136. "Please first read the full documentation at "
  137. "http://www.cmake.org before posting questions to the list."},
  138. {0,
  139. "Summary of helpful links:\n"
  140. " Home: http://www.cmake.org\n"
  141. " Docs: http://www.cmake.org/HTML/Documentation.html\n"
  142. " Mail: http://www.cmake.org/HTML/MailingLists.html\n"
  143. " FAQ: http://www.cmake.org/Wiki/CMake_FAQ\n"
  144. , 0},
  145. {0,0,0}
  146. };
  147. //----------------------------------------------------------------------------
  148. static const char *cmDocumentationCopyright[][3] =
  149. {
  150. {0,
  151. "Copyright (c) 2002 Kitware, Inc., Insight Consortium. "
  152. "All rights reserved.", 0},
  153. {0,
  154. "Redistribution and use in source and binary forms, with or without "
  155. "modification, are permitted provided that the following conditions are "
  156. "met:", 0},
  157. {"",
  158. "Redistributions of source code must retain the above copyright notice, "
  159. "this list of conditions and the following disclaimer.", 0},
  160. {"",
  161. "Redistributions in binary form must reproduce the above copyright "
  162. "notice, this list of conditions and the following disclaimer in the "
  163. "documentation and/or other materials provided with the distribution.",
  164. 0},
  165. {"",
  166. "The names of Kitware, Inc., the Insight Consortium, or the names of "
  167. "any consortium members, or of any contributors, may not be used to "
  168. "endorse or promote products derived from this software without "
  169. "specific prior written permission.", 0},
  170. {"",
  171. "Modified source versions must be plainly marked as such, and must "
  172. "not be misrepresented as being the original software.", 0},
  173. {0,
  174. "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "
  175. "``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "
  176. "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR "
  177. "A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR "
  178. "CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, "
  179. "EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, "
  180. "PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR "
  181. "PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF "
  182. "LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING "
  183. "NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS "
  184. "SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.", 0},
  185. {0, 0, 0}
  186. };
  187. //----------------------------------------------------------------------------
  188. cmDocumentation::cmDocumentation()
  189. :CurrentFormatter(0)
  190. {
  191. this->SetForm(TextForm);
  192. cmDocumentationSection *sec;
  193. sec = new cmDocumentationSection("Author","AUTHOR");
  194. sec->Append(cmDocumentationEntry
  195. (0,
  196. "This manual page was generated by the \"--help-man\" option.",
  197. 0));
  198. this->AllSections["Author"] = sec;
  199. sec = new cmDocumentationSection("Copyright","COPYRIGHT");
  200. sec->Append(cmDocumentationCopyright);
  201. this->AllSections["Copyright"] = sec;
  202. sec = new cmDocumentationSection("See Also","SEE ALSO");
  203. sec->Append(cmDocumentationStandardSeeAlso);
  204. this->AllSections["Standard See Also"] = sec;
  205. sec = new cmDocumentationSection("Options","OPTIONS");
  206. sec->Append(cmDocumentationStandardOptions);
  207. this->AllSections["Options"] = sec;
  208. sec = new cmDocumentationSection("Properties","PROPERTIES");
  209. sec->Append(cmPropertiesDocumentationDescription);
  210. this->AllSections["Properties Description"] = sec;
  211. sec = new cmDocumentationSection("Generators","GENERATORS");
  212. sec->Append(cmDocumentationGeneratorsHeader);
  213. this->AllSections["Generators"] = sec;
  214. }
  215. //----------------------------------------------------------------------------
  216. cmDocumentation::~cmDocumentation()
  217. {
  218. for(std::vector< char* >::iterator i = this->ModuleStrings.begin();
  219. i != this->ModuleStrings.end(); ++i)
  220. {
  221. delete [] *i;
  222. }
  223. for(std::map<std::string,cmDocumentationSection *>::iterator i =
  224. this->AllSections.begin();
  225. i != this->AllSections.end(); ++i)
  226. {
  227. delete i->second;
  228. }
  229. }
  230. //----------------------------------------------------------------------------
  231. bool cmDocumentation::PrintCopyright(std::ostream& os)
  232. {
  233. cmDocumentationSection *sec = this->AllSections["Copyright"];
  234. const std::vector<cmDocumentationEntry> &entries = sec->GetEntries();
  235. for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
  236. op != entries.end(); ++op)
  237. {
  238. if(op->Name.size())
  239. {
  240. os << " * ";
  241. this->TextFormatter.SetIndent(" ");
  242. this->TextFormatter.PrintColumn(os, op->Brief.c_str());
  243. }
  244. else
  245. {
  246. this->TextFormatter.SetIndent("");
  247. this->TextFormatter.PrintColumn(os, op->Brief.c_str());
  248. }
  249. os << "\n";
  250. }
  251. return true;
  252. }
  253. //----------------------------------------------------------------------------
  254. bool cmDocumentation::PrintVersion(std::ostream& os)
  255. {
  256. os << this->GetNameString() << " version "
  257. << cmVersion::GetCMakeVersion() << "\n";
  258. return true;
  259. }
  260. //----------------------------------------------------------------------------
  261. void cmDocumentation::AddSectionToPrint(const char *section)
  262. {
  263. if (this->AllSections.find(section) != this->AllSections.end())
  264. {
  265. this->PrintSections.push_back(this->AllSections[section]);
  266. }
  267. }
  268. //----------------------------------------------------------------------------
  269. void cmDocumentation::ClearSections()
  270. {
  271. this->PrintSections.erase(this->PrintSections.begin(),
  272. this->PrintSections.end());
  273. }
  274. //----------------------------------------------------------------------------
  275. bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
  276. {
  277. if ((this->CurrentFormatter->GetForm() != HTMLForm)
  278. && (this->CurrentFormatter->GetForm() != ManForm))
  279. {
  280. this->PrintVersion(os);
  281. }
  282. switch (ht)
  283. {
  284. case cmDocumentation::Usage:
  285. return this->PrintDocumentationUsage(os);
  286. case cmDocumentation::Single:
  287. return this->PrintDocumentationSingle(os);
  288. case cmDocumentation::SingleModule:
  289. return this->PrintDocumentationSingleModule(os);
  290. case cmDocumentation::SingleProperty:
  291. return this->PrintDocumentationSingleProperty(os);
  292. case cmDocumentation::List:
  293. this->PrintDocumentationList(os,"Commands");
  294. this->PrintDocumentationList(os,"Compatibility Commands");
  295. return true;
  296. case cmDocumentation::ModuleList:
  297. this->PrintDocumentationList(os,"Modules");
  298. return true;
  299. case cmDocumentation::PropertyList:
  300. this->PrintDocumentationList(os,"Properties Description");
  301. this->PrintDocumentationList(os,"Properties of Global Scope");
  302. this->PrintDocumentationList(os,"Properties on Directories");
  303. this->PrintDocumentationList(os,"Properties on Targets");
  304. this->PrintDocumentationList(os,"Properties on Tests");
  305. this->PrintDocumentationList(os,"Properties on Source Files");
  306. return true;
  307. case cmDocumentation::Full:
  308. return this->PrintDocumentationFull(os);
  309. case cmDocumentation::Modules:
  310. return this->PrintDocumentationModules(os);
  311. case cmDocumentation::CustomModules:
  312. return this->PrintDocumentationCustomModules(os);
  313. case cmDocumentation::Properties:
  314. return this->PrintDocumentationProperties(os);
  315. case cmDocumentation::Commands:
  316. return this->PrintDocumentationCurrentCommands(os);
  317. case cmDocumentation::CompatCommands:
  318. return this->PrintDocumentationCompatCommands(os);
  319. case cmDocumentation::Copyright:
  320. return this->PrintCopyright(os);
  321. case cmDocumentation::Version:
  322. return true;
  323. default: return false;
  324. }
  325. }
  326. //----------------------------------------------------------------------------
  327. bool cmDocumentation::CreateModulesSection()
  328. {
  329. cmDocumentationSection *sec =
  330. new cmDocumentationSection("Standard CMake Modules", "MODULES");
  331. this->AllSections["Modules"] = sec;
  332. std::string cmakeModules = this->CMakeRoot;
  333. cmakeModules += "/Modules";
  334. cmsys::Directory dir;
  335. dir.Load(cmakeModules.c_str());
  336. if (dir.GetNumberOfFiles() > 0)
  337. {
  338. sec->Append(cmDocumentationModulesHeader[0]);
  339. sec->Append(cmModulesDocumentationDescription);
  340. this->CreateModuleDocsForDir(dir, *this->AllSections["Modules"]);
  341. }
  342. return true;
  343. }
  344. //----------------------------------------------------------------------------
  345. bool cmDocumentation::CreateCustomModulesSection()
  346. {
  347. bool sectionHasHeader = false;
  348. std::vector<std::string> dirs;
  349. cmSystemTools::ExpandListArgument(this->CMakeModulePath, dirs);
  350. for(std::vector<std::string>::const_iterator dirIt = dirs.begin();
  351. dirIt != dirs.end();
  352. ++dirIt)
  353. {
  354. cmsys::Directory dir;
  355. dir.Load(dirIt->c_str());
  356. if (dir.GetNumberOfFiles() > 0)
  357. {
  358. if (!sectionHasHeader)
  359. {
  360. cmDocumentationSection *sec =
  361. new cmDocumentationSection("Custom CMake Modules","CUSTOM MODULES");
  362. this->AllSections["Custom CMake Modules"] = sec;
  363. sec->Append(cmDocumentationCustomModulesHeader[0]);
  364. sec->Append(cmCustomModulesDocumentationDescription);
  365. sectionHasHeader = true;
  366. }
  367. this->CreateModuleDocsForDir
  368. (dir, *this->AllSections["Custom CMake Modules"]);
  369. }
  370. }
  371. return true;
  372. }
  373. //----------------------------------------------------------------------------
  374. void cmDocumentation
  375. ::CreateModuleDocsForDir(cmsys::Directory& dir,
  376. cmDocumentationSection &moduleSection)
  377. {
  378. for(unsigned int i = 0; i < dir.GetNumberOfFiles(); ++i)
  379. {
  380. std::string fname = dir.GetFile(i);
  381. if(fname.length() > 6)
  382. {
  383. if(fname.substr(fname.length()-6, 6) == ".cmake")
  384. {
  385. std::string moduleName = fname.substr(0, fname.length()-6);
  386. if (this->ModulesFound.find(moduleName) == this->ModulesFound.end())
  387. {
  388. this->ModulesFound.insert(moduleName);
  389. std::string path = dir.GetPath();
  390. path += "/";
  391. path += fname;
  392. this->CreateSingleModule(path.c_str(), moduleName.c_str(),
  393. moduleSection);
  394. }
  395. }
  396. }
  397. }
  398. }
  399. //----------------------------------------------------------------------------
  400. bool cmDocumentation::CreateSingleModule(const char* fname,
  401. const char* moduleName,
  402. cmDocumentationSection &moduleSection)
  403. {
  404. std::ifstream fin(fname);
  405. if(!fin)
  406. {
  407. std::cerr << "Internal error: can not open module." << fname << std::endl;
  408. return false;
  409. }
  410. std::string line;
  411. std::string text;
  412. std::string brief;
  413. brief = " ";
  414. bool newParagraph = true;
  415. while ( fin && cmSystemTools::GetLineFromStream(fin, line) )
  416. {
  417. if(line.size() && line[0] == '#')
  418. {
  419. // blank line
  420. if(line.size() <= 2)
  421. {
  422. text += "\n";
  423. newParagraph = true;
  424. }
  425. else if(line[2] == '-')
  426. {
  427. brief = line.c_str()+4;
  428. }
  429. else
  430. {
  431. // two spaces
  432. if(line[1] == ' ' && line[2] == ' ')
  433. {
  434. if(!newParagraph)
  435. {
  436. text += "\n";
  437. newParagraph = true;
  438. }
  439. // Skip #, and leave space for preformatted
  440. text += line.c_str()+1;
  441. text += "\n";
  442. }
  443. else if(line[1] == ' ')
  444. {
  445. if(!newParagraph)
  446. {
  447. text += " ";
  448. }
  449. newParagraph = false;
  450. // skip # and space
  451. text += line.c_str()+2;
  452. }
  453. else
  454. {
  455. if(!newParagraph)
  456. {
  457. text += " ";
  458. }
  459. newParagraph = false;
  460. // skip #
  461. text += line.c_str()+1;
  462. }
  463. }
  464. }
  465. else
  466. {
  467. if(text.length() < 2 && brief.length() == 1)
  468. {
  469. return false;
  470. }
  471. char* pname = strcpy(new char[strlen(moduleName)+1], moduleName);
  472. char* ptext = strcpy(new char[text.length()+1], text.c_str());
  473. this->ModuleStrings.push_back(pname);
  474. this->ModuleStrings.push_back(ptext);
  475. char* pbrief = strcpy(new char[brief.length()+1], brief.c_str());
  476. this->ModuleStrings.push_back(pbrief);
  477. moduleSection.Append(pname, pbrief, ptext);
  478. return true;
  479. }
  480. }
  481. return true;
  482. }
  483. //----------------------------------------------------------------------------
  484. bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
  485. {
  486. bool result = true;
  487. // Loop over requested documentation types.
  488. for(std::vector<RequestedHelpItem>::const_iterator
  489. i = this->RequestedHelpItems.begin();
  490. i != this->RequestedHelpItems.end();
  491. ++i)
  492. {
  493. this->SetForm(i->HelpForm);
  494. this->CurrentArgument = i->Argument;
  495. // If a file name was given, use it. Otherwise, default to the
  496. // given stream.
  497. std::ofstream* fout = 0;
  498. std::ostream* s = &os;
  499. if(i->Filename.length() > 0)
  500. {
  501. fout = new std::ofstream(i->Filename.c_str(), std::ios::out);
  502. if(fout)
  503. {
  504. s = fout;
  505. }
  506. else
  507. {
  508. result = false;
  509. }
  510. }
  511. // Print this documentation type to the stream.
  512. if(!this->PrintDocumentation(i->HelpType, *s) || !*s)
  513. {
  514. result = false;
  515. }
  516. // Close the file if we wrote one.
  517. if(fout)
  518. {
  519. delete fout;
  520. }
  521. }
  522. return result;
  523. }
  524. #define GET_OPT_ARGUMENT(target) \
  525. if((i+1 < argc) && !this->IsOption(argv[i+1])) \
  526. { \
  527. target = argv[i+1]; \
  528. i = i+1; \
  529. };
  530. cmDocumentation::Form cmDocumentation::GetFormFromFilename(
  531. const std::string& filename)
  532. {
  533. std::string ext = cmSystemTools::GetFilenameExtension(filename);
  534. ext = cmSystemTools::UpperCase(ext);
  535. if ((ext == ".HTM") || (ext == ".HTML"))
  536. {
  537. return cmDocumentation::HTMLForm;
  538. }
  539. // ".1" to ".9" should be manpages
  540. if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9'))
  541. {
  542. return cmDocumentation::ManForm;
  543. }
  544. return cmDocumentation::TextForm;
  545. }
  546. //----------------------------------------------------------------------------
  547. bool cmDocumentation::CheckOptions(int argc, const char* const* argv)
  548. {
  549. // Providing zero arguments gives usage information.
  550. if(argc == 1)
  551. {
  552. RequestedHelpItem help;
  553. help.HelpType = cmDocumentation::Usage;
  554. help.HelpForm = cmDocumentation::UsageForm;
  555. this->RequestedHelpItems.push_back(help);
  556. return true;
  557. }
  558. // Search for supported help options.
  559. bool result = false;
  560. for(int i=1; i < argc; ++i)
  561. {
  562. RequestedHelpItem help;
  563. // Check if this is a supported help option.
  564. if((strcmp(argv[i], "-help") == 0) ||
  565. (strcmp(argv[i], "--help") == 0) ||
  566. (strcmp(argv[i], "/?") == 0) ||
  567. (strcmp(argv[i], "-usage") == 0) ||
  568. (strcmp(argv[i], "-h") == 0) ||
  569. (strcmp(argv[i], "-H") == 0))
  570. {
  571. help.HelpType = cmDocumentation::Usage;
  572. help.HelpForm = cmDocumentation::UsageForm;
  573. GET_OPT_ARGUMENT(help.Argument);
  574. help.Argument = cmSystemTools::LowerCase(help.Argument);
  575. // special case for single command
  576. if (!help.Argument.empty())
  577. {
  578. help.HelpType = cmDocumentation::Single;
  579. }
  580. }
  581. else if(strcmp(argv[i], "--help-properties") == 0)
  582. {
  583. help.HelpType = cmDocumentation::Properties;
  584. GET_OPT_ARGUMENT(help.Filename);
  585. help.HelpForm = this->GetFormFromFilename(help.Filename);
  586. }
  587. else if(strcmp(argv[i], "--help-modules") == 0)
  588. {
  589. help.HelpType = cmDocumentation::Modules;
  590. GET_OPT_ARGUMENT(help.Filename);
  591. help.HelpForm = this->GetFormFromFilename(help.Filename);
  592. }
  593. else if(strcmp(argv[i], "--help-custom-modules") == 0)
  594. {
  595. help.HelpType = cmDocumentation::CustomModules;
  596. GET_OPT_ARGUMENT(help.Filename);
  597. help.HelpForm = this->GetFormFromFilename(help.Filename);
  598. }
  599. else if(strcmp(argv[i], "--help-commands") == 0)
  600. {
  601. help.HelpType = cmDocumentation::Commands;
  602. GET_OPT_ARGUMENT(help.Filename);
  603. help.HelpForm = this->GetFormFromFilename(help.Filename);
  604. }
  605. else if(strcmp(argv[i], "--help-compatcommands") == 0)
  606. {
  607. help.HelpType = cmDocumentation::CompatCommands;
  608. GET_OPT_ARGUMENT(help.Filename);
  609. help.HelpForm = this->GetFormFromFilename(help.Filename);
  610. }
  611. else if(strcmp(argv[i], "--help-full") == 0)
  612. {
  613. help.HelpType = cmDocumentation::Full;
  614. GET_OPT_ARGUMENT(help.Filename);
  615. help.HelpForm = this->GetFormFromFilename(help.Filename);
  616. }
  617. else if(strcmp(argv[i], "--help-html") == 0)
  618. {
  619. help.HelpType = cmDocumentation::Full;
  620. GET_OPT_ARGUMENT(help.Filename);
  621. help.HelpForm = cmDocumentation::HTMLForm;
  622. }
  623. else if(strcmp(argv[i], "--help-man") == 0)
  624. {
  625. help.HelpType = cmDocumentation::Full;
  626. GET_OPT_ARGUMENT(help.Filename);
  627. help.HelpForm = cmDocumentation::ManForm;
  628. }
  629. else if(strcmp(argv[i], "--help-command") == 0)
  630. {
  631. help.HelpType = cmDocumentation::Single;
  632. GET_OPT_ARGUMENT(help.Argument);
  633. GET_OPT_ARGUMENT(help.Filename);
  634. help.Argument = cmSystemTools::LowerCase(help.Argument);
  635. help.HelpForm = this->GetFormFromFilename(help.Filename);
  636. }
  637. else if(strcmp(argv[i], "--help-module") == 0)
  638. {
  639. help.HelpType = cmDocumentation::SingleModule;
  640. GET_OPT_ARGUMENT(help.Argument);
  641. GET_OPT_ARGUMENT(help.Filename);
  642. help.HelpForm = this->GetFormFromFilename(help.Filename);
  643. }
  644. else if(strcmp(argv[i], "--help-property") == 0)
  645. {
  646. help.HelpType = cmDocumentation::SingleProperty;
  647. GET_OPT_ARGUMENT(help.Argument);
  648. GET_OPT_ARGUMENT(help.Filename);
  649. help.HelpForm = this->GetFormFromFilename(help.Filename);
  650. }
  651. else if(strcmp(argv[i], "--help-command-list") == 0)
  652. {
  653. help.HelpType = cmDocumentation::List;
  654. GET_OPT_ARGUMENT(help.Filename);
  655. help.HelpForm = cmDocumentation::TextForm;
  656. }
  657. else if(strcmp(argv[i], "--help-module-list") == 0)
  658. {
  659. help.HelpType = cmDocumentation::ModuleList;
  660. GET_OPT_ARGUMENT(help.Filename);
  661. help.HelpForm = cmDocumentation::TextForm;
  662. }
  663. else if(strcmp(argv[i], "--help-property-list") == 0)
  664. {
  665. help.HelpType = cmDocumentation::PropertyList;
  666. GET_OPT_ARGUMENT(help.Filename);
  667. help.HelpForm = cmDocumentation::TextForm;
  668. }
  669. else if(strcmp(argv[i], "--copyright") == 0)
  670. {
  671. help.HelpType = cmDocumentation::Copyright;
  672. GET_OPT_ARGUMENT(help.Filename);
  673. help.HelpForm = cmDocumentation::UsageForm;
  674. }
  675. else if((strcmp(argv[i], "--version") == 0) ||
  676. (strcmp(argv[i], "-version") == 0) ||
  677. (strcmp(argv[i], "/V") == 0))
  678. {
  679. help.HelpType = cmDocumentation::Version;
  680. GET_OPT_ARGUMENT(help.Filename);
  681. help.HelpForm = cmDocumentation::UsageForm;
  682. }
  683. if(help.HelpType != None)
  684. {
  685. // This is a help option. See if there is a file name given.
  686. result = true;
  687. this->RequestedHelpItems.push_back(help);
  688. }
  689. }
  690. return result;
  691. }
  692. //----------------------------------------------------------------------------
  693. void cmDocumentation::Print(Form f, std::ostream& os)
  694. {
  695. this->SetForm(f);
  696. this->Print(os);
  697. }
  698. //----------------------------------------------------------------------------
  699. void cmDocumentation::Print(std::ostream& os)
  700. {
  701. for(unsigned int i=0; i < this->PrintSections.size(); ++i)
  702. {
  703. std::string name = this->PrintSections[i]->
  704. GetName((this->CurrentFormatter->GetForm()));
  705. this->CurrentFormatter->PrintSection(os,*this->PrintSections[i],
  706. name.c_str());
  707. }
  708. }
  709. //----------------------------------------------------------------------------
  710. void cmDocumentation::SetName(const char* name)
  711. {
  712. this->NameString = name?name:"";
  713. }
  714. //----------------------------------------------------------------------------
  715. void cmDocumentation::SetSection(const char *name,
  716. cmDocumentationSection *section)
  717. {
  718. if (this->AllSections.find(name) != this->AllSections.end())
  719. {
  720. delete this->AllSections[name];
  721. }
  722. this->AllSections[name] = section;
  723. }
  724. //----------------------------------------------------------------------------
  725. void cmDocumentation::SetSection(const char *name,
  726. std::vector<cmDocumentationEntry> &docs)
  727. {
  728. cmDocumentationSection *sec =
  729. new cmDocumentationSection(name,
  730. cmSystemTools::UpperCase(name).c_str());
  731. sec->Append(docs);
  732. this->SetSection(name,sec);
  733. }
  734. //----------------------------------------------------------------------------
  735. void cmDocumentation::SetSection(const char *name,
  736. const char *docs[][3])
  737. {
  738. cmDocumentationSection *sec =
  739. new cmDocumentationSection(name,
  740. cmSystemTools::UpperCase(name).c_str());
  741. sec->Append(docs);
  742. this->SetSection(name,sec);
  743. }
  744. //----------------------------------------------------------------------------
  745. void cmDocumentation
  746. ::SetSections(std::map<std::string,cmDocumentationSection *> &sections)
  747. {
  748. for (std::map<std::string,cmDocumentationSection *>::const_iterator
  749. it = sections.begin(); it != sections.end(); ++it)
  750. {
  751. this->SetSection(it->first.c_str(),it->second);
  752. }
  753. }
  754. //----------------------------------------------------------------------------
  755. void cmDocumentation::PrependSection(const char *name,
  756. const char *docs[][3])
  757. {
  758. cmDocumentationSection *sec = 0;
  759. if (this->AllSections.find(name) == this->AllSections.end())
  760. {
  761. cmDocumentationSection *sec =
  762. new cmDocumentationSection(name,
  763. cmSystemTools::UpperCase(name).c_str());
  764. this->SetSection(name,sec);
  765. }
  766. else
  767. {
  768. sec = this->AllSections[name];
  769. }
  770. sec->Prepend(docs);
  771. }
  772. //----------------------------------------------------------------------------
  773. void cmDocumentation::AppendSection(const char *name,
  774. const char *docs[][3])
  775. {
  776. cmDocumentationSection *sec = 0;
  777. if (this->AllSections.find(name) == this->AllSections.end())
  778. {
  779. cmDocumentationSection *sec =
  780. new cmDocumentationSection(name,
  781. cmSystemTools::UpperCase(name).c_str());
  782. this->SetSection(name,sec);
  783. }
  784. else
  785. {
  786. sec = this->AllSections[name];
  787. }
  788. sec->Append(docs);
  789. }
  790. //----------------------------------------------------------------------------
  791. void cmDocumentation::AppendSection(const char *name,
  792. std::vector<cmDocumentationEntry> &docs)
  793. {
  794. cmDocumentationSection *sec = 0;
  795. if (this->AllSections.find(name) == this->AllSections.end())
  796. {
  797. cmDocumentationSection *sec =
  798. new cmDocumentationSection(name,
  799. cmSystemTools::UpperCase(name).c_str());
  800. this->SetSection(name,sec);
  801. }
  802. else
  803. {
  804. sec = this->AllSections[name];
  805. }
  806. sec->Append(docs);
  807. }
  808. //----------------------------------------------------------------------------
  809. void cmDocumentation::SetSeeAlsoList(const char *data[][3])
  810. {
  811. cmDocumentationSection *sec =
  812. new cmDocumentationSection("See Also", "SEE ALSO");
  813. this->AllSections["See Also"] = sec;
  814. this->SeeAlsoString = ".B ";
  815. int i = 0;
  816. while(data[i][1])
  817. {
  818. this->SeeAlsoString += data[i][1];
  819. this->SeeAlsoString += data[i+1][1]? "(1), ":"(1)";
  820. ++i;
  821. }
  822. sec->Append(0,this->SeeAlsoString.c_str(),0);
  823. sec->Append(cmDocumentationStandardSeeAlso);
  824. }
  825. //----------------------------------------------------------------------------
  826. bool cmDocumentation::PrintDocumentationGeneric(std::ostream& os,
  827. const char *section)
  828. {
  829. if(this->AllSections.find(section) == this->AllSections.end())
  830. {
  831. os << "Internal error: " << section << " list is empty." << std::endl;
  832. return false;
  833. }
  834. if(this->CurrentArgument.length() == 0)
  835. {
  836. os << "Required argument missing.\n";
  837. return false;
  838. }
  839. const std::vector<cmDocumentationEntry> &entries =
  840. this->AllSections[section]->GetEntries();
  841. for(std::vector<cmDocumentationEntry>::const_iterator ei =
  842. entries.begin();
  843. ei != entries.end(); ++ei)
  844. {
  845. if(this->CurrentArgument == ei->Name)
  846. {
  847. this->PrintDocumentationCommand(os, *ei);
  848. return true;
  849. }
  850. }
  851. return false;
  852. }
  853. //----------------------------------------------------------------------------
  854. bool cmDocumentation::PrintDocumentationSingle(std::ostream& os)
  855. {
  856. if (this->PrintDocumentationGeneric(os,"Commands"))
  857. {
  858. return true;
  859. }
  860. if (this->PrintDocumentationGeneric(os,"Compatibility Commands"))
  861. {
  862. return true;
  863. }
  864. // Argument was not a command. Complain.
  865. os << "Argument \"" << this->CurrentArgument.c_str()
  866. << "\" to --help-command is not a CMake command. "
  867. << "Use --help-command-list to see all commands.\n";
  868. return false;
  869. }
  870. //----------------------------------------------------------------------------
  871. bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os)
  872. {
  873. if(this->CurrentArgument.length() == 0)
  874. {
  875. os << "Argument --help-module needs a module name.\n";
  876. return false;
  877. }
  878. std::string moduleName;
  879. // find the module
  880. std::vector<std::string> dirs;
  881. cmSystemTools::ExpandListArgument(this->CMakeModulePath, dirs);
  882. for(std::vector<std::string>::const_iterator dirIt = dirs.begin();
  883. dirIt != dirs.end();
  884. ++dirIt)
  885. {
  886. moduleName = *dirIt;
  887. moduleName += "/";
  888. moduleName += this->CurrentArgument;
  889. moduleName += ".cmake";
  890. if(cmSystemTools::FileExists(moduleName.c_str()))
  891. {
  892. break;
  893. }
  894. moduleName = "";
  895. }
  896. if (moduleName.empty())
  897. {
  898. moduleName = this->CMakeRoot;
  899. moduleName += "/Modules/";
  900. moduleName += this->CurrentArgument;
  901. moduleName += ".cmake";
  902. if(!cmSystemTools::FileExists(moduleName.c_str()))
  903. {
  904. moduleName = "";
  905. }
  906. }
  907. if(!moduleName.empty()
  908. && this->CreateSingleModule(moduleName.c_str(),
  909. this->CurrentArgument.c_str(),
  910. *this->AllSections["Modules"]))
  911. {
  912. this->PrintDocumentationCommand
  913. (os, this->AllSections["Modules"]->GetEntries()[0]);
  914. os << "\n Defined in: ";
  915. os << moduleName << "\n";
  916. return true;
  917. }
  918. // Argument was not a module. Complain.
  919. os << "Argument \"" << this->CurrentArgument.c_str()
  920. << "\" to --help-module is not a CMake module.\n";
  921. return false;
  922. }
  923. //----------------------------------------------------------------------------
  924. bool cmDocumentation::PrintDocumentationSingleProperty(std::ostream& os)
  925. {
  926. if (this->PrintDocumentationGeneric(os,"Properties of Global Scope"))
  927. {
  928. return true;
  929. }
  930. if (this->PrintDocumentationGeneric(os,"Properties on Directories"))
  931. {
  932. return true;
  933. }
  934. if (this->PrintDocumentationGeneric(os,"Properties on Targets"))
  935. {
  936. return true;
  937. }
  938. if (this->PrintDocumentationGeneric(os,"Properties on Tests"))
  939. {
  940. return true;
  941. }
  942. if (this->PrintDocumentationGeneric(os,"Properties on Source Files"))
  943. {
  944. return true;
  945. }
  946. // Argument was not a command. Complain.
  947. os << "Argument \"" << this->CurrentArgument.c_str()
  948. << "\" to --help-property is not a CMake property. "
  949. << "Use --help-property-list to see all properties.\n";
  950. return false;
  951. }
  952. //----------------------------------------------------------------------------
  953. bool cmDocumentation::PrintDocumentationList(std::ostream& os,
  954. const char *section)
  955. {
  956. if(this->AllSections.find(section) == this->AllSections.end())
  957. {
  958. os << "Internal error: " << section << " list is empty." << std::endl;
  959. return false;
  960. }
  961. const std::vector<cmDocumentationEntry> &entries =
  962. this->AllSections[section]->GetEntries();
  963. for(std::vector<cmDocumentationEntry>::const_iterator ei =
  964. entries.begin();
  965. ei != entries.end(); ++ei)
  966. {
  967. if(ei->Name.size())
  968. {
  969. os << ei->Name << std::endl;
  970. }
  971. }
  972. return true;
  973. }
  974. //----------------------------------------------------------------------------
  975. bool cmDocumentation::PrintDocumentationUsage(std::ostream& os)
  976. {
  977. this->ClearSections();
  978. this->AddSectionToPrint("Usage");
  979. this->AddSectionToPrint("Options");
  980. this->AddSectionToPrint("Generators");
  981. this->Print(os);
  982. return true;
  983. }
  984. //----------------------------------------------------------------------------
  985. bool cmDocumentation::PrintDocumentationFull(std::ostream& os)
  986. {
  987. this->CreateFullDocumentation();
  988. this->CurrentFormatter->PrintHeader(GetNameString(), os);
  989. this->Print(os);
  990. this->CurrentFormatter->PrintFooter(os);
  991. return true;
  992. }
  993. //----------------------------------------------------------------------------
  994. bool cmDocumentation::PrintDocumentationModules(std::ostream& os)
  995. {
  996. this->ClearSections();
  997. this->CreateModulesSection();
  998. this->AddSectionToPrint("Description");
  999. this->AddSectionToPrint("Modules");
  1000. this->AddSectionToPrint("Copyright");
  1001. this->AddSectionToPrint("See Also");
  1002. this->CurrentFormatter->PrintHeader(this->GetNameString(), os);
  1003. this->Print(os);
  1004. this->CurrentFormatter->PrintFooter(os);
  1005. return true;
  1006. }
  1007. //----------------------------------------------------------------------------
  1008. bool cmDocumentation::PrintDocumentationCustomModules(std::ostream& os)
  1009. {
  1010. this->ClearSections();
  1011. this->CreateCustomModulesSection();
  1012. this->AddSectionToPrint("Description");
  1013. this->AddSectionToPrint("Custom Modules");
  1014. this->AddSectionToPrint("Copyright");
  1015. this->AddSectionToPrint("See Also");
  1016. this->CurrentFormatter->PrintHeader(this->GetNameString(), os);
  1017. this->Print(os);
  1018. this->CurrentFormatter->PrintFooter(os);
  1019. return true;
  1020. }
  1021. //----------------------------------------------------------------------------
  1022. bool cmDocumentation::PrintDocumentationProperties(std::ostream& os)
  1023. {
  1024. this->ClearSections();
  1025. this->AddSectionToPrint("Properties Description");
  1026. this->AddSectionToPrint("Properties of Global Scope");
  1027. this->AddSectionToPrint("Properties on Directories");
  1028. this->AddSectionToPrint("Properties on Targets");
  1029. this->AddSectionToPrint("Properties on Tests");
  1030. this->AddSectionToPrint("Properties on Source Files");
  1031. this->AddSectionToPrint("Copyright");
  1032. this->AddSectionToPrint("Standard See Also");
  1033. this->CurrentFormatter->PrintHeader(this->GetNameString(), os);
  1034. this->Print(os);
  1035. this->CurrentFormatter->PrintFooter(os);
  1036. return true;
  1037. }
  1038. //----------------------------------------------------------------------------
  1039. bool cmDocumentation::PrintDocumentationCurrentCommands(std::ostream& os)
  1040. {
  1041. this->ClearSections();
  1042. this->AddSectionToPrint("Commands");
  1043. this->AddSectionToPrint("Copyright");
  1044. this->AddSectionToPrint("Standard See Also");
  1045. this->CurrentFormatter->PrintHeader(this->GetNameString(), os);
  1046. this->Print(os);
  1047. this->CurrentFormatter->PrintFooter(os);
  1048. return true;
  1049. }
  1050. //----------------------------------------------------------------------------
  1051. bool cmDocumentation::PrintDocumentationCompatCommands(std::ostream& os)
  1052. {
  1053. this->ClearSections();
  1054. this->AddSectionToPrint("Compatibility Commands Description");
  1055. this->AddSectionToPrint("Compatibility Commands");
  1056. this->AddSectionToPrint("Copyright");
  1057. this->AddSectionToPrint("Standard See Also");
  1058. this->CurrentFormatter->PrintHeader(GetNameString(), os);
  1059. this->Print(os);
  1060. this->CurrentFormatter->PrintFooter(os);
  1061. return true;
  1062. }
  1063. //----------------------------------------------------------------------------
  1064. void cmDocumentation
  1065. ::PrintDocumentationCommand(std::ostream& os,
  1066. const cmDocumentationEntry &entry)
  1067. {
  1068. cmDocumentationSection *sec = new cmDocumentationSection("","");
  1069. sec->Append(entry);
  1070. this->AllSections["temp"] = sec;
  1071. this->ClearSections();
  1072. this->AddSectionToPrint("temp");
  1073. this->Print(os);
  1074. this->AllSections.erase("temp");
  1075. delete sec;
  1076. }
  1077. //----------------------------------------------------------------------------
  1078. void cmDocumentation::CreateFullDocumentation()
  1079. {
  1080. this->ClearSections();
  1081. this->CreateCustomModulesSection();
  1082. this->CreateModulesSection();
  1083. std::set<std::string> emitted;
  1084. this->AddSectionToPrint("Name");
  1085. emitted.insert("Name");
  1086. this->AddSectionToPrint("Usage");
  1087. emitted.insert("Usage");
  1088. this->AddSectionToPrint("Description");
  1089. emitted.insert("Description");
  1090. this->AddSectionToPrint("Options");
  1091. emitted.insert("Options");
  1092. this->AddSectionToPrint("Generators");
  1093. emitted.insert("Generators");
  1094. this->AddSectionToPrint("Commands");
  1095. emitted.insert("Commands");
  1096. this->AddSectionToPrint("Properties Description");
  1097. emitted.insert("Properties Description");
  1098. this->AddSectionToPrint("Properties of Global Scope");
  1099. emitted.insert("Properties of Global Scope");
  1100. this->AddSectionToPrint("Properties on Directories");
  1101. emitted.insert("Properties on Directories");
  1102. this->AddSectionToPrint("Properties on Targets");
  1103. emitted.insert("Properties on Targets");
  1104. this->AddSectionToPrint("Properties on Tests");
  1105. emitted.insert("Properties on Tests");
  1106. this->AddSectionToPrint("Properties on Source Files");
  1107. emitted.insert("Properties on Source Files");
  1108. emitted.insert("Copyright");
  1109. emitted.insert("See Also");
  1110. emitted.insert("Standard See Also");
  1111. emitted.insert("Author");
  1112. // add any sections not yet written out, or to be written out
  1113. for (std::map<std::string, cmDocumentationSection*>::iterator i =
  1114. this->AllSections.begin();
  1115. i != this->AllSections.end(); ++i)
  1116. {
  1117. if (emitted.find(i->first) == emitted.end())
  1118. {
  1119. this->AddSectionToPrint(i->first.c_str());
  1120. }
  1121. }
  1122. this->AddSectionToPrint("Copyright");
  1123. if(this->CurrentFormatter->GetForm() == ManForm)
  1124. {
  1125. this->AddSectionToPrint("See Also");
  1126. this->AddSectionToPrint("Author");
  1127. }
  1128. else
  1129. {
  1130. this->AddSectionToPrint("Standard See Also");
  1131. }
  1132. }
  1133. //----------------------------------------------------------------------------
  1134. void cmDocumentation::SetForm(Form f)
  1135. {
  1136. switch(f)
  1137. {
  1138. case HTMLForm:
  1139. this->CurrentFormatter = &this->HTMLFormatter;
  1140. break;
  1141. case ManForm:
  1142. this->CurrentFormatter = &this->ManFormatter;
  1143. break;
  1144. case TextForm:
  1145. this->CurrentFormatter = &this->TextFormatter;
  1146. break;
  1147. case UsageForm:
  1148. this->CurrentFormatter = & this->UsageFormatter;
  1149. break;
  1150. }
  1151. }
  1152. //----------------------------------------------------------------------------
  1153. const char* cmDocumentation::GetNameString() const
  1154. {
  1155. if(this->NameString.length() > 0)
  1156. {
  1157. return this->NameString.c_str();
  1158. }
  1159. else
  1160. {
  1161. return "CMake";
  1162. }
  1163. }
  1164. //----------------------------------------------------------------------------
  1165. bool cmDocumentation::IsOption(const char* arg) const
  1166. {
  1167. return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) ||
  1168. (strcmp(arg, "/?") == 0));
  1169. }