diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 8c17536a8..4f3475536 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -138,6 +138,8 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os) return this->PrintHelpListVariables(os); case cmDocumentation::ListPolicies: return this->PrintHelpListPolicies(os); + case cmDocumentation::ListGenerators: + return this->PrintHelpListGenerators(os); case cmDocumentation::Version: return this->PrintVersion(os); case cmDocumentation::OldCustomModules: @@ -816,6 +818,19 @@ bool cmDocumentation::PrintHelpListPolicies(std::ostream& os) return true; } +//---------------------------------------------------------------------------- +bool cmDocumentation::PrintHelpListGenerators(std::ostream& os) +{ + std::map::iterator si; + si = this->AllSections.find("Generators"); + if(si != this->AllSections.end()) + { + this->Formatter.SetIndent(" "); + this->Formatter.PrintSection(os, *si->second); + } + return true; +} + //---------------------------------------------------------------------------- bool cmDocumentation::PrintHelpOneVariable(std::ostream& os) { diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index b72b5fe27..8854c3618 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -117,6 +117,7 @@ private: bool PrintHelpListProperties(std::ostream& os); bool PrintHelpListVariables(std::ostream& os); bool PrintHelpListPolicies(std::ostream& os); + bool PrintHelpListGenerators(std::ostream& os); bool PrintOldCustomModules(std::ostream& os); const char* GetNameString() const; diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h index 59513ccb5..6e19b7d72 100644 --- a/Source/cmDocumentationFormatter.h +++ b/Source/cmDocumentationFormatter.h @@ -26,8 +26,8 @@ public: /** Types of help provided. */ enum Type { - None, Version, Usage, Help, Full, ListManuals, - ListCommands, ListModules, ListProperties, ListVariables, ListPolicies, + None, Version, Usage, Help, Full, ListManuals, ListCommands, + ListModules, ListProperties, ListVariables, ListPolicies, ListGenerators, OneManual, OneCommand, OneModule, OneProperty, OneVariable, OnePolicy, OldCustomModules }; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 7595155b0..3654aa78d 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -818,6 +818,7 @@ void cmake::SetArgs(const std::vector& args, if(i >= args.size()) { cmSystemTools::Error("No generator specified for -G"); + this->PrintGeneratorList(); return; } value = args[i]; @@ -828,6 +829,7 @@ void cmake::SetArgs(const std::vector& args, { cmSystemTools::Error("Could not create named generator ", value.c_str()); + this->PrintGeneratorList(); } else { @@ -1961,6 +1963,18 @@ void cmake::GetGeneratorDocumentation(std::vector& v) } } +void cmake::PrintGeneratorList() +{ +#ifdef CMAKE_BUILD_WITH_CMAKE + cmDocumentation doc; + std::vector generators; + this->GetGeneratorDocumentation(generators); + doc.AppendSection("Generators",generators); + std::cerr << "\n"; + doc.PrintDocumentation(cmDocumentation::ListGenerators, std::cerr); +#endif +} + void cmake::UpdateConversionPathTable() { // Update the path conversion table with any specified file: @@ -2438,6 +2452,7 @@ int cmake::GetSystemInformation(std::vector& args) if(i >= args.size()) { cmSystemTools::Error("No generator specified for -G"); + this->PrintGeneratorList(); return -1; } value = args[i]; @@ -2448,6 +2463,7 @@ int cmake::GetSystemInformation(std::vector& args) { cmSystemTools::Error("Could not create named generator ", value.c_str()); + this->PrintGeneratorList(); } else { diff --git a/Source/cmake.h b/Source/cmake.h index 3acf4a82f..0715d74f9 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -476,6 +476,9 @@ private: InstalledFilesMap InstalledFiles; void UpdateConversionPathTable(); + + // Print a list of valid generators to stderr. + void PrintGeneratorList(); }; #define CMAKE_STANDARD_OPTIONS_TABLE \ diff --git a/Tests/RunCMake/CommandLine/G_bad-arg-stderr.txt b/Tests/RunCMake/CommandLine/G_bad-arg-stderr.txt index 511208f58..07f2b5294 100644 --- a/Tests/RunCMake/CommandLine/G_bad-arg-stderr.txt +++ b/Tests/RunCMake/CommandLine/G_bad-arg-stderr.txt @@ -1 +1,3 @@ -^CMake Error: Could not create named generator NoSuchGenerator$ +^CMake Error: Could not create named generator NoSuchGenerator + +Generators diff --git a/Tests/RunCMake/CommandLine/G_no-arg-stderr.txt b/Tests/RunCMake/CommandLine/G_no-arg-stderr.txt index 56d23c2ee..2f491a224 100644 --- a/Tests/RunCMake/CommandLine/G_no-arg-stderr.txt +++ b/Tests/RunCMake/CommandLine/G_no-arg-stderr.txt @@ -1 +1,3 @@ -^CMake Error: No generator specified for -G$ +^CMake Error: No generator specified for -G + +Generators