Split global generator factory list with and without platforms

Replace `cmGlobalGeneratorFactory::GetGenerators` with a pair of methods
to split the list of generator names into those that have platforms in
the name and those that do not.
This commit is contained in:
Brad King 2019-01-18 11:08:45 -05:00
parent b70c0aed5c
commit 8144b00e32
10 changed files with 92 additions and 15 deletions

View File

@ -30,7 +30,8 @@ public:
virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
/** Get the names of the current registered generators */
virtual void GetGenerators(std::vector<std::string>& names) const = 0;
virtual std::vector<std::string> GetGeneratorNames() const = 0;
virtual std::vector<std::string> GetGeneratorNamesWithPlatform() const = 0;
/** Determine whether or not this generator supports toolsets */
virtual bool SupportsToolset() const = 0;
@ -60,9 +61,15 @@ public:
}
/** Get the names of the current registered generators */
void GetGenerators(std::vector<std::string>& names) const override
std::vector<std::string> GetGeneratorNames() const override
{
std::vector<std::string> names;
names.push_back(T::GetActualName());
return names;
}
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
return std::vector<std::string>();
}
/** Determine whether or not this generator supports toolsets */

View File

@ -74,11 +74,19 @@ public:
"Optional [arch] can be \"Win64\" or \"IA64\".";
}
void GetGenerators(std::vector<std::string>& names) const override
std::vector<std::string> GetGeneratorNames() const override
{
std::vector<std::string> names;
names.push_back(vs10generatorName);
return names;
}
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
std::vector<std::string> names;
names.push_back(vs10generatorName + std::string(" IA64"));
names.push_back(vs10generatorName + std::string(" Win64"));
return names;
}
bool SupportsToolset() const override { return true; }

View File

@ -69,9 +69,16 @@ public:
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
void GetGenerators(std::vector<std::string>& names) const override
std::vector<std::string> GetGeneratorNames() const override
{
std::vector<std::string> names;
names.push_back(vs11generatorName);
return names;
}
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
std::vector<std::string> names;
names.push_back(vs11generatorName + std::string(" ARM"));
names.push_back(vs11generatorName + std::string(" Win64"));
@ -80,6 +87,8 @@ public:
for (std::string const& i : installedSDKs) {
names.push_back(std::string(vs11generatorName) + " " + i);
}
return names;
}
bool SupportsToolset() const override { return true; }

View File

@ -58,11 +58,19 @@ public:
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
void GetGenerators(std::vector<std::string>& names) const override
std::vector<std::string> GetGeneratorNames() const override
{
std::vector<std::string> names;
names.push_back(vs12generatorName);
return names;
}
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
std::vector<std::string> names;
names.push_back(vs12generatorName + std::string(" ARM"));
names.push_back(vs12generatorName + std::string(" Win64"));
return names;
}
bool SupportsToolset() const override { return true; }

View File

@ -58,11 +58,19 @@ public:
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
void GetGenerators(std::vector<std::string>& names) const override
std::vector<std::string> GetGeneratorNames() const override
{
std::vector<std::string> names;
names.push_back(vs14generatorName);
return names;
}
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
std::vector<std::string> names;
names.push_back(vs14generatorName + std::string(" ARM"));
names.push_back(vs14generatorName + std::string(" Win64"));
return names;
}
bool SupportsToolset() const override { return true; }

View File

@ -59,9 +59,16 @@ public:
"Optional [arch] can be \"Win64\" or \"IA64\".";
}
void GetGenerators(std::vector<std::string>& names) const override
std::vector<std::string> GetGeneratorNames() const override
{
std::vector<std::string> names;
names.push_back(vs9generatorName);
return names;
}
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
std::vector<std::string> names;
names.push_back(vs9generatorName + std::string(" Win64"));
names.push_back(vs9generatorName + std::string(" IA64"));
cmVisualStudioWCEPlatformParser parser;
@ -71,6 +78,7 @@ public:
for (std::string const& i : availablePlatforms) {
names.push_back("Visual Studio 9 2008 " + i);
}
return names;
}
bool SupportsToolset() const override { return false; }

View File

@ -132,11 +132,19 @@ public:
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
void GetGenerators(std::vector<std::string>& names) const override
std::vector<std::string> GetGeneratorNames() const override
{
std::vector<std::string> names;
names.push_back(vs15generatorName);
return names;
}
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
std::vector<std::string> names;
names.push_back(vs15generatorName + std::string(" ARM"));
names.push_back(vs15generatorName + std::string(" Win64"));
return names;
}
bool SupportsToolset() const override { return true; }
@ -192,9 +200,16 @@ public:
"Use -A option to specify architecture.";
}
virtual void GetGenerators(std::vector<std::string>& names) const
std::vector<std::string> GetGeneratorNames() const override
{
std::vector<std::string> names;
names.push_back(vs16generatorName);
return names;
}
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
return std::vector<std::string>();
}
bool SupportsToolset() const override { return true; }

View File

@ -133,9 +133,16 @@ public:
cmGlobalXCodeGenerator::GetDocumentation(entry);
}
void GetGenerators(std::vector<std::string>& names) const override
std::vector<std::string> GetGeneratorNames() const override
{
std::vector<std::string> names;
names.push_back(cmGlobalXCodeGenerator::GetActualName());
return names;
}
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
return std::vector<std::string>();
}
bool SupportsToolset() const override { return true; }

View File

@ -959,12 +959,18 @@ void cmake::AddDefaultExtraGenerators()
#endif
}
void cmake::GetRegisteredGenerators(
std::vector<GeneratorInfo>& generators) const
void cmake::GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
bool includeNamesWithPlatform) const
{
for (cmGlobalGeneratorFactory* gen : this->Generators) {
std::vector<std::string> names;
gen->GetGenerators(names);
std::vector<std::string> names = gen->GetGeneratorNames();
if (includeNamesWithPlatform) {
std::vector<std::string> namesWithPlatform =
gen->GetGeneratorNamesWithPlatform();
names.insert(names.end(), namesWithPlatform.begin(),
namesWithPlatform.end());
}
for (std::string const& name : names) {
GeneratorInfo info;

View File

@ -196,7 +196,8 @@ public:
void SetGlobalGenerator(cmGlobalGenerator*);
///! Get the names of the current registered generators
void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators) const;
void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
bool includeNamesWithPlatform = true) const;
///! Set the name of the selected generator-specific instance.
void SetGeneratorInstance(std::string const& instance)