diff options
author | Artur Ryt <artur.ryt@gmail.com> | 2018-11-30 18:43:22 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-01-18 17:57:34 (GMT) |
commit | dfd5ae7da71ed9330eca7e352b8f9b42babdf3dd (patch) | |
tree | cc08e60849d92faed7790abf994ebd5196d80a0e /Source | |
parent | 6023fe7ff22848bc29ee67395eeb10f066758c06 (diff) | |
download | CMake-dfd5ae7da71ed9330eca7e352b8f9b42babdf3dd.zip CMake-dfd5ae7da71ed9330eca7e352b8f9b42babdf3dd.tar.gz CMake-dfd5ae7da71ed9330eca7e352b8f9b42babdf3dd.tar.bz2 |
Help: Mark default CMake generator with asterisk
Required extracting default generator evaluation
to explicit function, as Visual Studio generators
get validated during their construction.
Fixes: #18544
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmDocumentation.cxx | 15 | ||||
-rw-r--r-- | Source/cmDocumentationEntry.h | 1 | ||||
-rw-r--r-- | Source/cmDocumentationFormatter.cxx | 3 | ||||
-rw-r--r-- | Source/cmake.cxx | 26 | ||||
-rw-r--r-- | Source/cmake.h | 1 |
5 files changed, 38 insertions, 8 deletions
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 6a817b4..d4628fa 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -43,11 +43,18 @@ static const char* cmDocumentationStandardOptions[][2] = { { nullptr, nullptr } }; -static const char* cmDocumentationGeneratorsHeader[][2] = { +static const char* cmDocumentationCPackGeneratorsHeader[][2] = { { nullptr, "The following generators are available on this platform:" }, { nullptr, nullptr } }; +static const char* cmDocumentationCMakeGeneratorsHeader[][2] = { + { nullptr, + "The following generators are available on this platform (* marks " + "default):" }, + { nullptr, nullptr } +}; + cmDocumentation::cmDocumentation() { this->addCommonStandardDocSections(); @@ -178,7 +185,7 @@ void cmDocumentation::addCommonStandardDocSections() void cmDocumentation::addCMakeStandardDocSections() { cmDocumentationSection sec{ "Generators" }; - sec.Append(cmDocumentationGeneratorsHeader); + sec.Append(cmDocumentationCMakeGeneratorsHeader); this->AllSections.emplace("Generators", std::move(sec)); } @@ -191,7 +198,9 @@ void cmDocumentation::addCTestStandardDocSections() void cmDocumentation::addCPackStandardDocSections() { - addCMakeStandardDocSections(); + cmDocumentationSection sec{ "Generators" }; + sec.Append(cmDocumentationCPackGeneratorsHeader); + this->AllSections.emplace("Generators", std::move(sec)); } bool cmDocumentation::CheckOptions(int argc, const char* const* argv, diff --git a/Source/cmDocumentationEntry.h b/Source/cmDocumentationEntry.h index ea43b88..ca323cc 100644 --- a/Source/cmDocumentationEntry.h +++ b/Source/cmDocumentationEntry.h @@ -12,6 +12,7 @@ struct cmDocumentationEntry { std::string Name; std::string Brief; + char CustomNamePrefix = ' '; cmDocumentationEntry() {} cmDocumentationEntry(const char* doc[2]) { diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx index 678e408..e573c04 100644 --- a/Source/cmDocumentationFormatter.cxx +++ b/Source/cmDocumentationFormatter.cxx @@ -5,6 +5,7 @@ #include "cmDocumentationEntry.h" #include "cmDocumentationSection.h" +#include <iomanip> #include <ostream> #include <string.h> #include <string> @@ -168,7 +169,7 @@ void cmDocumentationFormatter::PrintSection( const std::vector<cmDocumentationEntry>& entries = section.GetEntries(); for (cmDocumentationEntry const& entry : entries) { if (!entry.Name.empty()) { - os << " " << entry.Name; + os << std::setw(2) << std::left << entry.CustomNamePrefix << entry.Name; this->TextIndent = " "; int align = static_cast<int>(strlen(this->TextIndent)) - 4; for (int i = static_cast<int>(entry.Name.size()); i < align; ++i) { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index c53b597..619fd3e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1519,7 +1519,7 @@ int cmake::ActualConfigure() return 0; } -void cmake::CreateDefaultGlobalGenerator() +std::unique_ptr<cmGlobalGenerator> cmake::EvaluateDefaultGlobalGenerator() { #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) std::string found; @@ -1572,11 +1572,20 @@ void cmake::CreateDefaultGlobalGenerator() if (!gen) { gen = new cmGlobalNMakeMakefileGenerator(this); } - this->SetGlobalGenerator(gen); - std::cout << "-- Building for: " << gen->GetName() << "\n"; + return std::unique_ptr<cmGlobalGenerator>(gen); #else - this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator3(this)); + return cm::make_unique<cmGlobalUnixMakefileGenerator3>(this); +#endif +} + +void cmake::CreateDefaultGlobalGenerator() +{ + auto gen = this->EvaluateDefaultGlobalGenerator(); +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) + // This print could be unified for all platforms + std::cout << "-- Building for: " << gen->GetName() << "\n"; #endif + this->SetGlobalGenerator(gen.release()); } void cmake::PreLoadCMakeFiles() @@ -1927,9 +1936,18 @@ void cmake::SetIsInTryCompile(bool b) void cmake::AppendGlobalGeneratorsDocumentation( std::vector<cmDocumentationEntry>& v) { + const auto defaultGenerator = this->EvaluateDefaultGlobalGenerator(); + const std::string defaultName = defaultGenerator->GetName(); + bool foundDefaultOne = false; + for (cmGlobalGeneratorFactory* g : this->Generators) { cmDocumentationEntry e; g->GetDocumentation(e); + if (!foundDefaultOne && + cmSystemTools::StringStartsWith(e.Name, defaultName.c_str())) { + e.CustomNamePrefix = '*'; + foundDefaultOne = true; + } v.push_back(std::move(e)); } } diff --git a/Source/cmake.h b/Source/cmake.h index 1586845..31cd97d 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -531,6 +531,7 @@ private: // Print a list of valid generators to stderr. void PrintGeneratorList(); + std::unique_ptr<cmGlobalGenerator> EvaluateDefaultGlobalGenerator(); void CreateDefaultGlobalGenerator(); void AppendGlobalGeneratorsDocumentation(std::vector<cmDocumentationEntry>&); |