2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2003-02-14 18:53:37 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2003-02-14 18:53:37 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2003-02-14 18:53:37 +03:00
|
|
|
#include "cmDocumentation.h"
|
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmDocumentationEntry.h"
|
|
|
|
#include "cmDocumentationSection.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmRST.h"
|
2003-02-14 18:53:37 +03:00
|
|
|
#include "cmSystemTools.h"
|
2004-10-22 23:44:54 +04:00
|
|
|
#include "cmVersion.h"
|
2013-09-16 19:29:06 +04:00
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
#include <algorithm>
|
2014-01-04 09:47:13 +04:00
|
|
|
#include <cmsys/FStream.hxx>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <cmsys/Glob.hxx>
|
2013-09-16 19:29:06 +04:00
|
|
|
#include <ctype.h>
|
2016-09-01 21:59:28 +03:00
|
|
|
#include <string.h>
|
|
|
|
#include <utility>
|
2007-06-28 19:00:57 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* cmDocumentationStandardOptions[][2] = {
|
|
|
|
{ "--help,-help,-usage,-h,-H,/?", "Print usage information and exit." },
|
|
|
|
{ "--version,-version,/V [<f>]", "Print version number and exit." },
|
|
|
|
{ "--help-full [<f>]", "Print all help manuals and exit." },
|
|
|
|
{ "--help-manual <man> [<f>]", "Print one help manual and exit." },
|
|
|
|
{ "--help-manual-list [<f>]", "List help manuals available and exit." },
|
|
|
|
{ "--help-command <cmd> [<f>]", "Print help for one command and exit." },
|
|
|
|
{ "--help-command-list [<f>]",
|
|
|
|
"List commands with help available and exit." },
|
|
|
|
{ "--help-commands [<f>]", "Print cmake-commands manual and exit." },
|
|
|
|
{ "--help-module <mod> [<f>]", "Print help for one module and exit." },
|
|
|
|
{ "--help-module-list [<f>]", "List modules with help available and exit." },
|
|
|
|
{ "--help-modules [<f>]", "Print cmake-modules manual and exit." },
|
|
|
|
{ "--help-policy <cmp> [<f>]", "Print help for one policy and exit." },
|
|
|
|
{ "--help-policy-list [<f>]",
|
|
|
|
"List policies with help available and exit." },
|
|
|
|
{ "--help-policies [<f>]", "Print cmake-policies manual and exit." },
|
|
|
|
{ "--help-property <prop> [<f>]", "Print help for one property and exit." },
|
|
|
|
{ "--help-property-list [<f>]",
|
|
|
|
"List properties with help available and exit." },
|
|
|
|
{ "--help-properties [<f>]", "Print cmake-properties manual and exit." },
|
|
|
|
{ "--help-variable var [<f>]", "Print help for one variable and exit." },
|
|
|
|
{ "--help-variable-list [<f>]",
|
|
|
|
"List variables with help available and exit." },
|
|
|
|
{ "--help-variables [<f>]", "Print cmake-variables manual and exit." },
|
2016-06-27 23:44:16 +03:00
|
|
|
{ CM_NULLPTR, CM_NULLPTR }
|
2003-02-14 18:53:37 +03:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* cmDocumentationGeneratorsHeader[][2] = {
|
2016-06-27 23:44:16 +03:00
|
|
|
{ CM_NULLPTR, "The following generators are available on this platform:" },
|
|
|
|
{ CM_NULLPTR, CM_NULLPTR }
|
2003-07-08 05:52:10 +04:00
|
|
|
};
|
|
|
|
|
2003-02-14 18:53:37 +03:00
|
|
|
cmDocumentation::cmDocumentation()
|
|
|
|
{
|
2011-11-14 01:44:53 +04:00
|
|
|
this->addCommonStandardDocSections();
|
2009-11-24 19:46:06 +03:00
|
|
|
this->ShowGenerators = true;
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
2005-12-14 21:51:08 +03:00
|
|
|
cmDocumentation::~cmDocumentation()
|
|
|
|
{
|
2015-01-04 15:33:16 +03:00
|
|
|
cmDeleteAll(this->AllSections);
|
2005-12-14 21:51:08 +03:00
|
|
|
}
|
|
|
|
|
2004-04-14 22:25:43 +04:00
|
|
|
bool cmDocumentation::PrintVersion(std::ostream& os)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2013-11-20 01:27:53 +04:00
|
|
|
os <<
|
|
|
|
this->GetNameString() <<
|
|
|
|
" version " << cmVersion::GetCMakeVersion() << "\n"
|
|
|
|
"\n"
|
2014-06-03 17:34:38 +04:00
|
|
|
"CMake suite maintained and supported by Kitware (kitware.com/cmake).\n"
|
2013-11-20 01:27:53 +04:00
|
|
|
;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2004-04-14 22:25:43 +04:00
|
|
|
return true;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
2013-09-14 00:31:29 +04:00
|
|
|
bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (ht) {
|
2007-02-01 18:38:42 +03:00
|
|
|
case cmDocumentation::Usage:
|
2014-06-13 00:18:32 +04:00
|
|
|
return this->PrintUsage(os);
|
|
|
|
case cmDocumentation::Help:
|
|
|
|
return this->PrintHelp(os);
|
2014-04-24 23:05:38 +04:00
|
|
|
case cmDocumentation::Full:
|
|
|
|
return this->PrintHelpFull(os);
|
2013-09-16 19:29:06 +04:00
|
|
|
case cmDocumentation::OneManual:
|
|
|
|
return this->PrintHelpOneManual(os);
|
|
|
|
case cmDocumentation::OneCommand:
|
|
|
|
return this->PrintHelpOneCommand(os);
|
|
|
|
case cmDocumentation::OneModule:
|
|
|
|
return this->PrintHelpOneModule(os);
|
|
|
|
case cmDocumentation::OnePolicy:
|
|
|
|
return this->PrintHelpOnePolicy(os);
|
|
|
|
case cmDocumentation::OneProperty:
|
|
|
|
return this->PrintHelpOneProperty(os);
|
|
|
|
case cmDocumentation::OneVariable:
|
|
|
|
return this->PrintHelpOneVariable(os);
|
|
|
|
case cmDocumentation::ListManuals:
|
|
|
|
return this->PrintHelpListManuals(os);
|
|
|
|
case cmDocumentation::ListCommands:
|
|
|
|
return this->PrintHelpListCommands(os);
|
|
|
|
case cmDocumentation::ListModules:
|
|
|
|
return this->PrintHelpListModules(os);
|
|
|
|
case cmDocumentation::ListProperties:
|
|
|
|
return this->PrintHelpListProperties(os);
|
|
|
|
case cmDocumentation::ListVariables:
|
|
|
|
return this->PrintHelpListVariables(os);
|
|
|
|
case cmDocumentation::ListPolicies:
|
|
|
|
return this->PrintHelpListPolicies(os);
|
2015-03-29 21:28:30 +03:00
|
|
|
case cmDocumentation::ListGenerators:
|
|
|
|
return this->PrintHelpListGenerators(os);
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::Version:
|
2013-09-25 19:28:17 +04:00
|
|
|
return this->PrintVersion(os);
|
2014-01-08 20:14:06 +04:00
|
|
|
case cmDocumentation::OldCustomModules:
|
|
|
|
return this->PrintOldCustomModules(os);
|
2016-05-16 17:34:04 +03:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
2003-07-08 06:44:18 +04:00
|
|
|
bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
|
|
|
|
{
|
2013-09-16 19:29:06 +04:00
|
|
|
int count = 0;
|
2003-07-08 06:44:18 +04:00
|
|
|
bool result = true;
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2003-07-08 06:44:18 +04:00
|
|
|
// Loop over requested documentation types.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<RequestedHelpItem>::const_iterator i =
|
|
|
|
this->RequestedHelpItems.begin();
|
|
|
|
i != this->RequestedHelpItems.end(); ++i) {
|
2007-06-28 19:00:57 +04:00
|
|
|
this->CurrentArgument = i->Argument;
|
2003-07-08 06:44:18 +04:00
|
|
|
// If a file name was given, use it. Otherwise, default to the
|
|
|
|
// given stream.
|
2016-06-27 23:44:16 +03:00
|
|
|
cmsys::ofstream* fout = CM_NULLPTR;
|
2003-07-08 06:44:18 +04:00
|
|
|
std::ostream* s = &os;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!i->Filename.empty()) {
|
2016-06-13 23:56:48 +03:00
|
|
|
fout = new cmsys::ofstream(i->Filename.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (fout) {
|
2003-07-08 06:44:18 +04:00
|
|
|
s = fout;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2003-07-08 06:44:18 +04:00
|
|
|
result = false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (++count > 1) {
|
2013-09-16 19:29:06 +04:00
|
|
|
os << "\n\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2003-07-08 06:44:18 +04:00
|
|
|
// Print this documentation type to the stream.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->PrintDocumentation(i->HelpType, *s) || !*s) {
|
2003-07-08 06:44:18 +04:00
|
|
|
result = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2003-07-08 06:44:18 +04:00
|
|
|
// Close the file if we wrote one.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (fout) {
|
2003-07-08 06:44:18 +04:00
|
|
|
delete fout;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-07-08 06:44:18 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
#define GET_OPT_ARGUMENT(target) \
|
|
|
|
if ((i + 1 < argc) && !this->IsOption(argv[i + 1])) { \
|
2016-09-05 23:09:49 +03:00
|
|
|
(target) = argv[i + 1]; \
|
2016-05-16 17:34:04 +03:00
|
|
|
i = i + 1; \
|
|
|
|
};
|
2007-06-28 19:00:57 +04:00
|
|
|
|
2013-09-14 00:09:52 +04:00
|
|
|
void cmDocumentation::WarnFormFromFilename(
|
2013-11-19 19:58:16 +04:00
|
|
|
cmDocumentation::RequestedHelpItem& request, bool& result)
|
2007-06-28 19:00:57 +04:00
|
|
|
{
|
2013-09-14 00:09:52 +04:00
|
|
|
std::string ext = cmSystemTools::GetFilenameLastExtension(request.Filename);
|
2007-06-28 19:00:57 +04:00
|
|
|
ext = cmSystemTools::UpperCase(ext);
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((ext == ".HTM") || (ext == ".HTML")) {
|
2013-09-14 00:09:52 +04:00
|
|
|
request.HelpType = cmDocumentation::None;
|
2013-11-19 19:58:16 +04:00
|
|
|
result = true;
|
2013-09-14 00:09:52 +04:00
|
|
|
cmSystemTools::Message("Warning: HTML help format no longer supported");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (ext == ".DOCBOOK") {
|
2013-09-14 00:09:52 +04:00
|
|
|
request.HelpType = cmDocumentation::None;
|
2013-11-19 19:58:16 +04:00
|
|
|
result = true;
|
2013-09-14 00:09:52 +04:00
|
|
|
cmSystemTools::Message("Warning: Docbook help format no longer supported");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
// ".1" to ".9" should be manpages
|
2016-05-16 17:34:04 +03:00
|
|
|
else if ((ext.length() == 2) && (ext[1] >= '1') && (ext[1] <= '9')) {
|
2013-09-14 00:09:52 +04:00
|
|
|
request.HelpType = cmDocumentation::None;
|
2013-11-19 19:58:16 +04:00
|
|
|
result = true;
|
2013-09-14 00:09:52 +04:00
|
|
|
cmSystemTools::Message("Warning: Man help format no longer supported");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
}
|
|
|
|
|
2011-11-14 01:44:53 +04:00
|
|
|
void cmDocumentation::addCommonStandardDocSections()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmDocumentationSection* sec;
|
2011-11-14 01:44:53 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
sec = new cmDocumentationSection("Options", "OPTIONS");
|
|
|
|
sec->Append(cmDocumentationStandardOptions);
|
|
|
|
this->AllSections["Options"] = sec;
|
2011-11-14 01:44:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmDocumentation::addCMakeStandardDocSections()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmDocumentationSection* sec;
|
2011-11-14 01:44:53 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
sec = new cmDocumentationSection("Generators", "GENERATORS");
|
|
|
|
sec->Append(cmDocumentationGeneratorsHeader);
|
|
|
|
this->AllSections["Generators"] = sec;
|
2011-11-14 01:44:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmDocumentation::addCTestStandardDocSections()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
// This is currently done for backward compatibility reason
|
|
|
|
// We may suppress some of these.
|
|
|
|
addCMakeStandardDocSections();
|
2011-11-14 01:44:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmDocumentation::addCPackStandardDocSections()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmDocumentationSection* sec;
|
2011-11-14 01:44:53 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
sec = new cmDocumentationSection("Generators", "GENERATORS");
|
|
|
|
sec->Append(cmDocumentationGeneratorsHeader);
|
|
|
|
this->AllSections["Generators"] = sec;
|
2012-02-19 01:07:39 +04:00
|
|
|
}
|
2011-11-15 23:24:38 +04:00
|
|
|
|
2008-08-19 23:42:48 +04:00
|
|
|
bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
|
|
|
const char* exitOpt)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-04-03 07:44:42 +04:00
|
|
|
// Providing zero arguments gives usage information.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (argc == 1) {
|
2007-06-28 19:00:57 +04:00
|
|
|
RequestedHelpItem help;
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Usage;
|
2007-06-28 19:00:57 +04:00
|
|
|
this->RequestedHelpItems.push_back(help);
|
2003-07-08 06:44:18 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
|
2003-04-03 07:44:42 +04:00
|
|
|
// Search for supported help options.
|
2007-06-28 19:00:57 +04:00
|
|
|
|
2003-07-08 06:44:18 +04:00
|
|
|
bool result = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (int i = 1; i < argc; ++i) {
|
|
|
|
if (exitOpt && strcmp(argv[i], exitOpt) == 0) {
|
2008-08-19 23:42:48 +04:00
|
|
|
return result;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
RequestedHelpItem help;
|
2003-07-08 06:44:18 +04:00
|
|
|
// Check if this is a supported help option.
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0) ||
|
|
|
|
(strcmp(argv[i], "/?") == 0) || (strcmp(argv[i], "-usage") == 0) ||
|
|
|
|
(strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "-H") == 0)) {
|
2014-06-13 00:18:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Help;
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
2007-10-10 19:47:43 +04:00
|
|
|
help.Argument = cmSystemTools::LowerCase(help.Argument);
|
2007-06-28 19:00:57 +04:00
|
|
|
// special case for single command
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!help.Argument.empty()) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::OneCommand;
|
2003-07-08 06:44:18 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-properties") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::OneManual;
|
|
|
|
help.Argument = "cmake-properties.7";
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-11-19 19:58:16 +04:00
|
|
|
this->WarnFormFromFilename(help, result);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-policies") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::OneManual;
|
|
|
|
help.Argument = "cmake-policies.7";
|
2008-03-04 17:16:33 +03:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-11-19 19:58:16 +04:00
|
|
|
this->WarnFormFromFilename(help, result);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-variables") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::OneManual;
|
|
|
|
help.Argument = "cmake-variables.7";
|
2007-10-24 19:36:47 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-11-19 19:58:16 +04:00
|
|
|
this->WarnFormFromFilename(help, result);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-modules") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::OneManual;
|
|
|
|
help.Argument = "cmake-modules.7";
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-11-19 19:58:16 +04:00
|
|
|
this->WarnFormFromFilename(help, result);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-custom-modules") == 0) {
|
2007-09-19 21:14:25 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-09-14 00:31:29 +04:00
|
|
|
cmSystemTools::Message(
|
|
|
|
"Warning: --help-custom-modules no longer supported");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (help.Filename.empty()) {
|
2014-01-08 20:14:06 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-01-08 20:14:06 +04:00
|
|
|
// Avoid breaking old project builds completely by at least generating
|
|
|
|
// the output file. Abuse help.Argument to give the file name to
|
|
|
|
// PrintOldCustomModules without disrupting our internal API.
|
|
|
|
help.HelpType = cmDocumentation::OldCustomModules;
|
|
|
|
help.Argument = cmSystemTools::GetFilenameName(help.Filename);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-commands") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::OneManual;
|
|
|
|
help.Argument = "cmake-commands.7";
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-11-19 19:58:16 +04:00
|
|
|
this->WarnFormFromFilename(help, result);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-compatcommands") == 0) {
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-09-14 00:31:29 +04:00
|
|
|
cmSystemTools::Message(
|
|
|
|
"Warning: --help-compatcommands no longer supported");
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-full") == 0) {
|
2014-04-24 23:05:38 +04:00
|
|
|
help.HelpType = cmDocumentation::Full;
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2014-04-24 23:05:38 +04:00
|
|
|
this->WarnFormFromFilename(help, result);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-html") == 0) {
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-09-14 00:31:29 +04:00
|
|
|
cmSystemTools::Message("Warning: --help-html no longer supported");
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-man") == 0) {
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-09-14 00:31:29 +04:00
|
|
|
cmSystemTools::Message("Warning: --help-man no longer supported");
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-command") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::OneCommand;
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2007-10-10 19:47:43 +04:00
|
|
|
help.Argument = cmSystemTools::LowerCase(help.Argument);
|
2013-11-19 19:58:16 +04:00
|
|
|
this->WarnFormFromFilename(help, result);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-module") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::OneModule;
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-11-19 19:58:16 +04:00
|
|
|
this->WarnFormFromFilename(help, result);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-property") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::OneProperty;
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-11-19 19:58:16 +04:00
|
|
|
this->WarnFormFromFilename(help, result);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-policy") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::OnePolicy;
|
2008-03-04 17:16:33 +03:00
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-11-19 19:58:16 +04:00
|
|
|
this->WarnFormFromFilename(help, result);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-variable") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::OneVariable;
|
2007-10-24 19:36:47 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-11-19 19:58:16 +04:00
|
|
|
this->WarnFormFromFilename(help, result);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-manual") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::OneManual;
|
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-11-19 19:58:16 +04:00
|
|
|
this->WarnFormFromFilename(help, result);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-command-list") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::ListCommands;
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-module-list") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::ListModules;
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-property-list") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::ListProperties;
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-variable-list") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::ListVariables;
|
2007-10-24 19:36:47 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-policy-list") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::ListPolicies;
|
2013-09-23 21:42:49 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--help-manual-list") == 0) {
|
2013-09-16 19:29:06 +04:00
|
|
|
help.HelpType = cmDocumentation::ListManuals;
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(argv[i], "--copyright") == 0) {
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2013-09-14 00:31:29 +04:00
|
|
|
cmSystemTools::Message("Warning: --copyright no longer supported");
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if ((strcmp(argv[i], "--version") == 0) ||
|
|
|
|
(strcmp(argv[i], "-version") == 0) ||
|
|
|
|
(strcmp(argv[i], "/V") == 0)) {
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Version;
|
2007-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (help.HelpType != None) {
|
2003-07-08 06:44:18 +04:00
|
|
|
// This is a help option. See if there is a file name given.
|
|
|
|
result = true;
|
2007-06-28 19:00:57 +04:00
|
|
|
this->RequestedHelpItems.push_back(help);
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-07-08 06:44:18 +04:00
|
|
|
return result;
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
2014-02-08 00:35:30 +04:00
|
|
|
void cmDocumentation::SetName(const std::string& name)
|
2003-08-06 22:49:52 +04:00
|
|
|
{
|
2014-02-08 00:35:30 +04:00
|
|
|
this->NameString = name;
|
2003-08-06 22:49:52 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmDocumentation::SetSection(const char* name,
|
|
|
|
cmDocumentationSection* section)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->AllSections.find(name) != this->AllSections.end()) {
|
2007-10-22 20:49:09 +04:00
|
|
|
delete this->AllSections[name];
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AllSections[name] = section;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmDocumentation::SetSection(const char* name,
|
|
|
|
std::vector<cmDocumentationEntry>& docs)
|
2007-06-22 16:44:51 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmDocumentationSection* sec =
|
|
|
|
new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
|
2007-10-22 20:49:09 +04:00
|
|
|
sec->Append(docs);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetSection(name, sec);
|
2007-06-22 16:44:51 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmDocumentation::SetSection(const char* name, const char* docs[][2])
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmDocumentationSection* sec =
|
|
|
|
new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
|
2007-10-22 20:49:09 +04:00
|
|
|
sec->Append(docs);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetSection(name, sec);
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmDocumentation::SetSections(
|
|
|
|
std::map<std::string, cmDocumentationSection*>& sections)
|
2003-07-08 05:52:10 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::map<std::string, cmDocumentationSection*>::const_iterator it =
|
|
|
|
sections.begin();
|
|
|
|
it != sections.end(); ++it) {
|
|
|
|
this->SetSection(it->first.c_str(), it->second);
|
|
|
|
}
|
2003-07-08 05:52:10 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmDocumentation::PrependSection(const char* name, const char* docs[][2])
|
2007-10-22 23:33:19 +04:00
|
|
|
{
|
2016-06-27 23:44:16 +03:00
|
|
|
cmDocumentationSection* sec = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->AllSections.find(name) == this->AllSections.end()) {
|
|
|
|
sec =
|
|
|
|
new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
|
|
|
|
this->SetSection(name, sec);
|
|
|
|
} else {
|
2007-10-22 23:33:19 +04:00
|
|
|
sec = this->AllSections[name];
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-10-22 23:33:19 +04:00
|
|
|
sec->Prepend(docs);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmDocumentation::PrependSection(const char* name,
|
|
|
|
std::vector<cmDocumentationEntry>& docs)
|
2007-10-24 19:36:47 +04:00
|
|
|
{
|
2016-06-27 23:44:16 +03:00
|
|
|
cmDocumentationSection* sec = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->AllSections.find(name) == this->AllSections.end()) {
|
|
|
|
sec =
|
|
|
|
new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
|
|
|
|
this->SetSection(name, sec);
|
|
|
|
} else {
|
2007-10-24 19:36:47 +04:00
|
|
|
sec = this->AllSections[name];
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-10-24 19:36:47 +04:00
|
|
|
sec->Prepend(docs);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmDocumentation::AppendSection(const char* name, const char* docs[][2])
|
2007-10-22 23:33:19 +04:00
|
|
|
{
|
2016-06-27 23:44:16 +03:00
|
|
|
cmDocumentationSection* sec = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->AllSections.find(name) == this->AllSections.end()) {
|
|
|
|
sec =
|
|
|
|
new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
|
|
|
|
this->SetSection(name, sec);
|
|
|
|
} else {
|
2007-10-22 23:33:19 +04:00
|
|
|
sec = this->AllSections[name];
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-10-22 23:33:19 +04:00
|
|
|
sec->Append(docs);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmDocumentation::AppendSection(const char* name,
|
|
|
|
std::vector<cmDocumentationEntry>& docs)
|
2007-10-22 23:33:19 +04:00
|
|
|
{
|
2016-06-27 23:44:16 +03:00
|
|
|
cmDocumentationSection* sec = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->AllSections.find(name) == this->AllSections.end()) {
|
|
|
|
sec =
|
|
|
|
new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
|
|
|
|
this->SetSection(name, sec);
|
|
|
|
} else {
|
2007-10-22 23:33:19 +04:00
|
|
|
sec = this->AllSections[name];
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-10-22 23:33:19 +04:00
|
|
|
sec->Append(docs);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmDocumentation::AppendSection(const char* name,
|
|
|
|
cmDocumentationEntry& docs)
|
2007-10-24 19:36:47 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
std::vector<cmDocumentationEntry> docsVec;
|
|
|
|
docsVec.push_back(docs);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AppendSection(name, docsVec);
|
2007-10-24 19:36:47 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmDocumentation::PrependSection(const char* name,
|
|
|
|
cmDocumentationEntry& docs)
|
2007-10-24 19:36:47 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
std::vector<cmDocumentationEntry> docsVec;
|
|
|
|
docsVec.push_back(docs);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->PrependSection(name, docsVec);
|
2007-10-24 19:36:47 +04:00
|
|
|
}
|
|
|
|
|
2013-09-16 19:29:06 +04:00
|
|
|
void cmDocumentation::GlobHelp(std::vector<std::string>& files,
|
|
|
|
std::string const& pattern)
|
|
|
|
{
|
|
|
|
cmsys::Glob gl;
|
2013-11-08 00:30:59 +04:00
|
|
|
std::string findExpr =
|
|
|
|
cmSystemTools::GetCMakeRoot() + "/Help/" + pattern + ".rst";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (gl.FindFiles(findExpr)) {
|
2013-09-16 19:29:06 +04:00
|
|
|
files = gl.GetFiles();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-09-16 19:29:06 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmDocumentation::PrintNames(std::ostream& os, std::string const& pattern)
|
2013-09-16 19:29:06 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> files;
|
|
|
|
this->GlobHelp(files, pattern);
|
|
|
|
std::vector<std::string> names;
|
|
|
|
for (std::vector<std::string>::const_iterator i = files.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
i != files.end(); ++i) {
|
2013-09-16 19:29:06 +04:00
|
|
|
std::string line;
|
2014-01-04 09:47:13 +04:00
|
|
|
cmsys::ifstream fin(i->c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
while (fin && cmSystemTools::GetLineFromStream(fin, line)) {
|
|
|
|
if (!line.empty() && (isalnum(line[0]) || line[0] == '<')) {
|
2013-09-16 19:29:06 +04:00
|
|
|
names.push_back(line);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-09-16 19:29:06 +04:00
|
|
|
std::sort(names.begin(), names.end());
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator i = names.begin(); i != names.end();
|
|
|
|
++i) {
|
2013-09-16 19:29:06 +04:00
|
|
|
os << *i << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-09-16 19:29:06 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmDocumentation::PrintFiles(std::ostream& os, std::string const& pattern)
|
2013-09-16 19:29:06 +04:00
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
std::vector<std::string> files;
|
|
|
|
this->GlobHelp(files, pattern);
|
|
|
|
std::sort(files.begin(), files.end());
|
2013-11-08 00:30:59 +04:00
|
|
|
cmRST r(os, cmSystemTools::GetCMakeRoot() + "/Help");
|
2013-09-16 19:29:06 +04:00
|
|
|
for (std::vector<std::string>::const_iterator i = files.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
i != files.end(); ++i) {
|
2014-03-11 03:04:11 +04:00
|
|
|
found = r.ProcessFile(*i) || found;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-09-16 19:29:06 +04:00
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2014-04-24 23:05:38 +04:00
|
|
|
bool cmDocumentation::PrintHelpFull(std::ostream& os)
|
|
|
|
{
|
|
|
|
return this->PrintFiles(os, "index");
|
|
|
|
}
|
|
|
|
|
2013-09-16 19:29:06 +04:00
|
|
|
bool cmDocumentation::PrintHelpOneManual(std::ostream& os)
|
|
|
|
{
|
|
|
|
std::string mname = this->CurrentArgument;
|
|
|
|
std::string::size_type mlen = mname.length();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (mlen > 3 && mname[mlen - 3] == '(' && mname[mlen - 1] == ')') {
|
|
|
|
mname = mname.substr(0, mlen - 3) + "." + mname[mlen - 2];
|
|
|
|
}
|
|
|
|
if (this->PrintFiles(os, "manual/" + mname) ||
|
|
|
|
this->PrintFiles(os, "manual/" + mname + ".[0-9]")) {
|
2013-09-16 19:29:06 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-09-16 19:29:06 +04:00
|
|
|
// Argument was not a manual. Complain.
|
2014-03-11 16:35:32 +04:00
|
|
|
os << "Argument \"" << this->CurrentArgument
|
2013-09-16 19:29:06 +04:00
|
|
|
<< "\" to --help-manual is not an available manual. "
|
|
|
|
<< "Use --help-manual-list to see all available manuals.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmDocumentation::PrintHelpListManuals(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->PrintNames(os, "manual/*");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmDocumentation::PrintHelpOneCommand(std::ostream& os)
|
|
|
|
{
|
|
|
|
std::string cname = cmSystemTools::LowerCase(this->CurrentArgument);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->PrintFiles(os, "command/" + cname)) {
|
2013-09-16 19:29:06 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-09-16 19:29:06 +04:00
|
|
|
// Argument was not a command. Complain.
|
2014-03-11 16:35:32 +04:00
|
|
|
os << "Argument \"" << this->CurrentArgument
|
2013-09-16 19:29:06 +04:00
|
|
|
<< "\" to --help-command is not a CMake command. "
|
|
|
|
<< "Use --help-command-list to see all commands.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmDocumentation::PrintHelpListCommands(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->PrintNames(os, "command/*");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmDocumentation::PrintHelpOneModule(std::ostream& os)
|
|
|
|
{
|
|
|
|
std::string mname = this->CurrentArgument;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->PrintFiles(os, "module/" + mname)) {
|
2013-09-16 19:29:06 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-09-16 19:29:06 +04:00
|
|
|
// Argument was not a module. Complain.
|
2014-03-11 16:35:32 +04:00
|
|
|
os << "Argument \"" << this->CurrentArgument
|
2013-09-16 19:29:06 +04:00
|
|
|
<< "\" to --help-module is not a CMake module.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmDocumentation::PrintHelpListModules(std::ostream& os)
|
|
|
|
{
|
|
|
|
std::vector<std::string> files;
|
|
|
|
this->GlobHelp(files, "module/*");
|
|
|
|
std::vector<std::string> modules;
|
|
|
|
for (std::vector<std::string>::iterator fi = files.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
fi != files.end(); ++fi) {
|
2013-09-16 19:29:06 +04:00
|
|
|
std::string module = cmSystemTools::GetFilenameName(*fi);
|
2016-05-16 17:34:04 +03:00
|
|
|
modules.push_back(module.substr(0, module.size() - 4));
|
|
|
|
}
|
2013-09-16 19:29:06 +04:00
|
|
|
std::sort(modules.begin(), modules.end());
|
|
|
|
for (std::vector<std::string>::iterator i = modules.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
i != modules.end(); ++i) {
|
2013-09-16 19:29:06 +04:00
|
|
|
os << *i << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-09-16 19:29:06 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmDocumentation::PrintHelpOneProperty(std::ostream& os)
|
|
|
|
{
|
|
|
|
std::string pname = cmSystemTools::HelpFileName(this->CurrentArgument);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->PrintFiles(os, "prop_*/" + pname)) {
|
2013-09-16 19:29:06 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-09-16 19:29:06 +04:00
|
|
|
// Argument was not a property. Complain.
|
2014-03-11 16:35:32 +04:00
|
|
|
os << "Argument \"" << this->CurrentArgument
|
2013-09-16 19:29:06 +04:00
|
|
|
<< "\" to --help-property is not a CMake property. "
|
|
|
|
<< "Use --help-property-list to see all properties.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmDocumentation::PrintHelpListProperties(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->PrintNames(os, "prop_*/*");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmDocumentation::PrintHelpOnePolicy(std::ostream& os)
|
|
|
|
{
|
|
|
|
std::string pname = this->CurrentArgument;
|
|
|
|
std::vector<std::string> files;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->PrintFiles(os, "policy/" + pname)) {
|
2013-09-16 19:29:06 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-09-16 19:29:06 +04:00
|
|
|
|
|
|
|
// Argument was not a policy. Complain.
|
2014-03-11 16:35:32 +04:00
|
|
|
os << "Argument \"" << this->CurrentArgument
|
2013-09-16 19:29:06 +04:00
|
|
|
<< "\" to --help-policy is not a CMake policy.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmDocumentation::PrintHelpListPolicies(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->PrintNames(os, "policy/*");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-29 21:28:30 +03:00
|
|
|
bool cmDocumentation::PrintHelpListGenerators(std::ostream& os)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::map<std::string, cmDocumentationSection*>::iterator si;
|
2015-03-29 21:28:30 +03:00
|
|
|
si = this->AllSections.find("Generators");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (si != this->AllSections.end()) {
|
2015-03-29 21:28:30 +03:00
|
|
|
this->Formatter.SetIndent(" ");
|
|
|
|
this->Formatter.PrintSection(os, *si->second);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-03-29 21:28:30 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-16 19:29:06 +04:00
|
|
|
bool cmDocumentation::PrintHelpOneVariable(std::ostream& os)
|
|
|
|
{
|
|
|
|
std::string vname = cmSystemTools::HelpFileName(this->CurrentArgument);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->PrintFiles(os, "variable/" + vname)) {
|
2013-09-16 19:29:06 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-09-16 19:29:06 +04:00
|
|
|
// Argument was not a variable. Complain.
|
2014-03-11 16:35:32 +04:00
|
|
|
os << "Argument \"" << this->CurrentArgument
|
2013-09-16 19:29:06 +04:00
|
|
|
<< "\" to --help-variable is not a defined variable. "
|
|
|
|
<< "Use --help-variable-list to see all defined variables.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmDocumentation::PrintHelpListVariables(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->PrintNames(os, "variable/*");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-13 00:18:32 +04:00
|
|
|
bool cmDocumentation::PrintUsage(std::ostream& os)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::map<std::string, cmDocumentationSection*>::iterator si;
|
2014-06-13 00:18:32 +04:00
|
|
|
si = this->AllSections.find("Usage");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (si != this->AllSections.end()) {
|
2014-06-13 00:18:32 +04:00
|
|
|
this->Formatter.PrintSection(os, *si->second);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-06-13 00:18:32 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmDocumentation::PrintHelp(std::ostream& os)
|
2004-04-14 22:25:43 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::map<std::string, cmDocumentationSection*>::iterator si;
|
2013-09-14 00:09:52 +04:00
|
|
|
si = this->AllSections.find("Usage");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (si != this->AllSections.end()) {
|
2013-09-14 00:09:52 +04:00
|
|
|
this->Formatter.PrintSection(os, *si->second);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-09-14 00:09:52 +04:00
|
|
|
si = this->AllSections.find("Options");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (si != this->AllSections.end()) {
|
2013-09-14 00:09:52 +04:00
|
|
|
this->Formatter.PrintSection(os, *si->second);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->ShowGenerators) {
|
2013-09-14 00:09:52 +04:00
|
|
|
si = this->AllSections.find("Generators");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (si != this->AllSections.end()) {
|
2013-09-14 00:09:52 +04:00
|
|
|
this->Formatter.PrintSection(os, *si->second);
|
2009-11-24 19:46:06 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-14 22:25:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-01-22 18:52:24 +03:00
|
|
|
const char* cmDocumentation::GetNameString() const
|
2003-08-06 22:49:52 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->NameString.empty()) {
|
2003-08-06 22:49:52 +04:00
|
|
|
return this->NameString.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-08-18 21:36:29 +03:00
|
|
|
return "CMake";
|
2003-08-06 22:49:52 +04:00
|
|
|
}
|
2004-04-14 22:25:43 +04:00
|
|
|
|
2007-01-22 18:52:24 +03:00
|
|
|
bool cmDocumentation::IsOption(const char* arg) const
|
2004-04-14 22:25:43 +04:00
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) ||
|
2004-04-14 22:25:43 +04:00
|
|
|
(strcmp(arg, "/?") == 0));
|
|
|
|
}
|
2014-01-08 20:14:06 +04:00
|
|
|
|
|
|
|
bool cmDocumentation::PrintOldCustomModules(std::ostream& os)
|
|
|
|
{
|
|
|
|
// CheckOptions abuses the Argument field to give us the file name.
|
|
|
|
std::string filename = this->CurrentArgument;
|
|
|
|
std::string ext = cmSystemTools::UpperCase(
|
|
|
|
cmSystemTools::GetFilenameLastExtension(filename));
|
|
|
|
std::string name = cmSystemTools::GetFilenameWithoutLastExtension(filename);
|
|
|
|
|
|
|
|
const char* summary = "cmake --help-custom-modules no longer supported\n";
|
|
|
|
const char* detail =
|
|
|
|
"CMake versions prior to 3.0 exposed their internal module help page\n"
|
|
|
|
"generation functionality through the --help-custom-modules option.\n"
|
|
|
|
"CMake versions 3.0 and above use other means to generate their module\n"
|
|
|
|
"help pages so this functionality is no longer available to be exposed.\n"
|
|
|
|
"\n"
|
2016-05-16 17:34:04 +03:00
|
|
|
"This file was generated as a placeholder to provide this information.\n";
|
|
|
|
if ((ext == ".HTM") || (ext == ".HTML")) {
|
2014-01-08 20:14:06 +04:00
|
|
|
os << "<html><title>" << name << "</title><body>\n"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< summary << "<p/>\n"
|
|
|
|
<< detail << "</body></html>\n";
|
|
|
|
} else if ((ext.length() == 2) && (ext[1] >= '1') && (ext[1] <= '9')) {
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2014-01-08 20:14:06 +04:00
|
|
|
os <<
|
|
|
|
".TH " << name << " " << ext[1] << " \"" <<
|
|
|
|
cmSystemTools::GetCurrentDateTime("%B %d, %Y") <<
|
|
|
|
"\" \"cmake " << cmVersion::GetCMakeVersion() << "\"\n"
|
|
|
|
".SH NAME\n"
|
|
|
|
".PP\n" <<
|
|
|
|
name << " \\- " << summary <<
|
|
|
|
"\n"
|
|
|
|
".SH DESCRIPTION\n"
|
|
|
|
".PP\n" <<
|
|
|
|
detail
|
|
|
|
;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-01-08 20:14:06 +04:00
|
|
|
os << name << "\n\n" << summary << "\n" << detail;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-01-08 20:14:06 +04:00
|
|
|
return true;
|
|
|
|
}
|