Add global generator factory method to get list of known platforms

Add a `cmGlobalGeneratorFactory::GetKnownPlatforms` method to return
a list of known possible values for `CMAKE_GENERATOR_PLATFORM`.
Implement the method for each generator by referencing the list of
possible values documented in `Help/generator/*.rst` for it.

Co-Author: Julien Jomier <julien.jomier@kitware.com>
This commit is contained in:
Brad King 2019-01-18 10:13:55 -05:00
parent 8144b00e32
commit 818df52c48
10 changed files with 96 additions and 0 deletions

View File

@ -38,6 +38,9 @@ public:
/** Determine whether or not this generator supports platforms */
virtual bool SupportsPlatform() const = 0;
/** Get the list of supported platforms name for this generator */
virtual std::vector<std::string> GetKnownPlatforms() const = 0;
};
template <class T>
@ -77,6 +80,13 @@ public:
/** Determine whether or not this generator supports platforms */
bool SupportsPlatform() const override { return T::SupportsPlatform(); }
/** Get the list of supported platforms name for this generator */
std::vector<std::string> GetKnownPlatforms() const override
{
// default is no platform supported
return std::vector<std::string>();
}
};
#endif

View File

@ -91,6 +91,15 @@ public:
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return true; }
std::vector<std::string> GetKnownPlatforms() const override
{
std::vector<std::string> platforms;
platforms.emplace_back("x64");
platforms.emplace_back("Win32");
platforms.emplace_back("Itanium");
return platforms;
}
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory()

View File

@ -93,6 +93,22 @@ public:
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return true; }
std::vector<std::string> GetKnownPlatforms() const override
{
std::vector<std::string> platforms;
platforms.emplace_back("x64");
platforms.emplace_back("Win32");
platforms.emplace_back("ARM");
std::set<std::string> installedSDKs =
cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
for (std::string const& i : installedSDKs) {
platforms.emplace_back(i);
}
return platforms;
}
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()

View File

@ -75,6 +75,15 @@ public:
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return true; }
std::vector<std::string> GetKnownPlatforms() const override
{
std::vector<std::string> platforms;
platforms.emplace_back("x64");
platforms.emplace_back("Win32");
platforms.emplace_back("ARM");
return platforms;
}
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory()

View File

@ -75,6 +75,15 @@ public:
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return true; }
std::vector<std::string> GetKnownPlatforms() const override
{
std::vector<std::string> platforms;
platforms.emplace_back("x64");
platforms.emplace_back("Win32");
platforms.emplace_back("ARM");
return platforms;
}
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory()

View File

@ -83,6 +83,22 @@ public:
bool SupportsToolset() const override { return false; }
bool SupportsPlatform() const override { return true; }
std::vector<std::string> GetKnownPlatforms() const override
{
std::vector<std::string> platforms;
platforms.emplace_back("x64");
platforms.emplace_back("Win32");
platforms.emplace_back("Itanium");
cmVisualStudioWCEPlatformParser parser;
parser.ParseVersion("9.0");
const std::vector<std::string>& availablePlatforms =
parser.GetAvailablePlatforms();
for (std::string const& i : availablePlatforms) {
platforms.emplace_back(i);
}
return platforms;
}
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()

View File

@ -149,6 +149,16 @@ public:
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return true; }
std::vector<std::string> GetKnownPlatforms() const override
{
std::vector<std::string> platforms;
platforms.emplace_back("x64");
platforms.emplace_back("Win32");
platforms.emplace_back("ARM");
platforms.emplace_back("ARM64");
return platforms;
}
};
cmGlobalGeneratorFactory*
@ -214,6 +224,16 @@ public:
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return true; }
std::vector<std::string> GetKnownPlatforms() const override
{
std::vector<std::string> platforms;
platforms.emplace_back("x64");
platforms.emplace_back("Win32");
platforms.emplace_back("ARM");
platforms.emplace_back("ARM64");
return platforms;
}
};
cmGlobalGeneratorFactory*

View File

@ -147,6 +147,11 @@ public:
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return false; }
std::vector<std::string> GetKnownPlatforms() const override
{
return std::vector<std::string>();
}
};
cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(

View File

@ -976,6 +976,7 @@ void cmake::GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
GeneratorInfo info;
info.supportsToolset = gen->SupportsToolset();
info.supportsPlatform = gen->SupportsPlatform();
info.supportedPlatforms = gen->GetKnownPlatforms();
info.name = name;
info.baseName = name;
info.isAlias = false;

View File

@ -104,6 +104,7 @@ public:
std::string extraName;
bool supportsToolset;
bool supportsPlatform;
std::vector<std::string> supportedPlatforms;
bool isAlias;
};