diff options
author | Artur Ryt <artur.ryt@gmail.com> | 2018-11-30 18:00:57 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-01-18 17:57:32 (GMT) |
commit | 7408cd39298dfce442d7aa539a90a227433865d5 (patch) | |
tree | 1910148c8048133dc1ff4c557d070c17940cbe9b /Source | |
parent | a61c061b6143cb6d8920b1b5796a867c0f104556 (diff) | |
download | CMake-7408cd39298dfce442d7aa539a90a227433865d5.zip CMake-7408cd39298dfce442d7aa539a90a227433865d5.tar.gz CMake-7408cd39298dfce442d7aa539a90a227433865d5.tar.bz2 |
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.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CursesDialog/ccmake.cxx | 5 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetup.cxx | 3 | ||||
-rw-r--r-- | Source/cmake.cxx | 19 | ||||
-rw-r--r-- | Source/cmake.h | 5 | ||||
-rw-r--r-- | 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<cmDocumentationEntry> 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<cmDocumentationEntry> 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<cmDocumentationEntry>& v) +void cmake::AppendGlobalGeneratorsDocumentation( + std::vector<cmDocumentationEntry>& v) { for (cmGlobalGeneratorFactory* g : this->Generators) { cmDocumentationEntry e; g->GetDocumentation(e); v.push_back(std::move(e)); } +} + +void cmake::AppendExtraGeneratorsDocumentation( + std::vector<cmDocumentationEntry>& 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<cmDocumentationEntry>& v) } } +std::vector<cmDocumentationEntry> cmake::GetGeneratorsDocumentation() +{ + std::vector<cmDocumentationEntry> v; + this->AppendGlobalGeneratorsDocumentation(v); + this->AppendExtraGeneratorsDocumentation(v); + return v; +} + void cmake::PrintGeneratorList() { #ifdef CMAKE_BUILD_WITH_CMAKE cmDocumentation doc; - std::vector<cmDocumentationEntry> 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<cmDocumentationEntry>&); + std::vector<cmDocumentationEntry> 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<cmDocumentationEntry>&); + void AppendExtraGeneratorsDocumentation(std::vector<cmDocumentationEntry>&); + /** * 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<std::string> args(av, av + ac); hcm.SetCacheArgs(args); - std::vector<cmDocumentationEntry> generators; - - hcm.GetGeneratorDocumentation(generators); + auto generators = hcm.GetGeneratorsDocumentation(); doc.SetName("cmake"); doc.SetSection("Name", cmDocumentationName); |