From 7408cd39298dfce442d7aa539a90a227433865d5 Mon Sep 17 00:00:00 2001 From: Artur Ryt Date: Fri, 30 Nov 2018 19:00:57 +0100 Subject: cmake: Return generator docs directly The GetGeneratorDocumentation() function was not accurately named and required the vector to populate to be passed as a function argument. This commit makes the slightly renamed function return by value, making it a true getter as implied by its name. Some minor refactoring of the implementation also makes the steps of populating the vector clearer. --- Source/CursesDialog/ccmake.cxx | 5 ++--- Source/QtDialog/CMakeSetup.cxx | 3 +-- Source/cmake.cxx | 19 ++++++++++++++++--- Source/cmake.h | 5 ++++- Source/cmakemain.cxx | 6 ++---- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 6dc692e..44789b0 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -5,7 +5,7 @@ #include "cmCursesMainForm.h" #include "cmCursesStandardIncludes.h" #include "cmDocumentation.h" -#include "cmDocumentationEntry.h" +#include "cmDocumentationEntry.h" // IWYU pragma: keep #include "cmState.h" #include "cmSystemTools.h" #include "cmake.h" @@ -88,8 +88,7 @@ int main(int argc, char const* const* argv) hcm.SetHomeDirectory(""); hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); - std::vector generators; - hcm.GetGeneratorDocumentation(generators); + auto generators = hcm.GetGeneratorsDocumentation(); doc.SetName("ccmake"); doc.SetSection("Name", cmDocumentationName); doc.SetSection("Usage", cmDocumentationUsage); diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index b4307bb..9f4e48e 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -69,8 +69,7 @@ int main(int argc, char** argv) hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); - std::vector generators; - hcm.GetGeneratorDocumentation(generators); + auto generators = hcm.GetGeneratorsDocumentation(); doc.SetName("cmake"); doc.SetSection("Name", cmDocumentationName); doc.SetSection("Usage", cmDocumentationUsage); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9fcfbde..c53b597 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1924,13 +1924,19 @@ void cmake::SetIsInTryCompile(bool b) this->State->SetIsInTryCompile(b); } -void cmake::GetGeneratorDocumentation(std::vector& v) +void cmake::AppendGlobalGeneratorsDocumentation( + std::vector& v) { for (cmGlobalGeneratorFactory* g : this->Generators) { cmDocumentationEntry e; g->GetDocumentation(e); v.push_back(std::move(e)); } +} + +void cmake::AppendExtraGeneratorsDocumentation( + std::vector& v) +{ for (cmExternalMakefileProjectGeneratorFactory* eg : this->ExtraGenerators) { const std::string doc = eg->GetDocumentation(); const std::string name = eg->GetName(); @@ -1956,12 +1962,19 @@ void cmake::GetGeneratorDocumentation(std::vector& v) } } +std::vector cmake::GetGeneratorsDocumentation() +{ + std::vector v; + this->AppendGlobalGeneratorsDocumentation(v); + this->AppendExtraGeneratorsDocumentation(v); + return v; +} + void cmake::PrintGeneratorList() { #ifdef CMAKE_BUILD_WITH_CMAKE cmDocumentation doc; - std::vector generators; - this->GetGeneratorDocumentation(generators); + auto generators = this->GetGeneratorsDocumentation(); doc.AppendSection("Generators", generators); std::cerr << "\n"; doc.PrintDocumentation(cmDocumentation::ListGenerators, std::cerr); diff --git a/Source/cmake.h b/Source/cmake.h index cd8c622..1586845 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -292,7 +292,7 @@ public: cmVariableWatch* GetVariableWatch() { return this->VariableWatch; } #endif - void GetGeneratorDocumentation(std::vector&); + std::vector GetGeneratorsDocumentation(); ///! Set/Get a property of this target file void SetProperty(const std::string& prop, const char* value); @@ -533,6 +533,9 @@ private: void CreateDefaultGlobalGenerator(); + void AppendGlobalGeneratorsDocumentation(std::vector&); + void AppendExtraGeneratorsDocumentation(std::vector&); + /** * Convert a message type between a warning and an error, based on the state * of the error output CMake variables, in the cache. diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 84d1414..c1c9537 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAlgorithms.h" -#include "cmDocumentationEntry.h" +#include "cmDocumentationEntry.h" // IWYU pragma: keep #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmState.h" @@ -227,9 +227,7 @@ int do_cmake(int ac, char const* const* av) std::vector args(av, av + ac); hcm.SetCacheArgs(args); - std::vector generators; - - hcm.GetGeneratorDocumentation(generators); + auto generators = hcm.GetGeneratorsDocumentation(); doc.SetName("cmake"); doc.SetSection("Name", cmDocumentationName); -- cgit v0.12