From 818df52c488a94628169811bddffe05f36c68b42 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 18 Jan 2019 10:13:55 -0500 Subject: 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 --- Source/cmGlobalGeneratorFactory.h | 10 ++++++++++ Source/cmGlobalVisualStudio10Generator.cxx | 9 +++++++++ Source/cmGlobalVisualStudio11Generator.cxx | 16 ++++++++++++++++ Source/cmGlobalVisualStudio12Generator.cxx | 9 +++++++++ Source/cmGlobalVisualStudio14Generator.cxx | 9 +++++++++ Source/cmGlobalVisualStudio9Generator.cxx | 16 ++++++++++++++++ Source/cmGlobalVisualStudioVersionedGenerator.cxx | 20 ++++++++++++++++++++ Source/cmGlobalXCodeGenerator.cxx | 5 +++++ Source/cmake.cxx | 1 + Source/cmake.h | 1 + 10 files changed, 96 insertions(+) diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h index 906ec9a..26c9545 100644 --- a/Source/cmGlobalGeneratorFactory.h +++ b/Source/cmGlobalGeneratorFactory.h @@ -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 GetKnownPlatforms() const = 0; }; template @@ -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 GetKnownPlatforms() const override + { + // default is no platform supported + return std::vector(); + } }; #endif diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index bf856ea..c439f68 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -91,6 +91,15 @@ public: bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return true; } + + std::vector GetKnownPlatforms() const override + { + std::vector platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("Itanium"); + return platforms; + } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index a44058b..0aaf2bb 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -93,6 +93,22 @@ public: bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return true; } + + std::vector GetKnownPlatforms() const override + { + std::vector platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("ARM"); + + std::set installedSDKs = + cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs(); + for (std::string const& i : installedSDKs) { + platforms.emplace_back(i); + } + + return platforms; + } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index cbd5085..1c202a8 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -75,6 +75,15 @@ public: bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return true; } + + std::vector GetKnownPlatforms() const override + { + std::vector platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("ARM"); + return platforms; + } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 47768a8..c87433e 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -75,6 +75,15 @@ public: bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return true; } + + std::vector GetKnownPlatforms() const override + { + std::vector platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("ARM"); + return platforms; + } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index d72b25b..15a83af 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -83,6 +83,22 @@ public: bool SupportsToolset() const override { return false; } bool SupportsPlatform() const override { return true; } + + std::vector GetKnownPlatforms() const override + { + std::vector platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("Itanium"); + cmVisualStudioWCEPlatformParser parser; + parser.ParseVersion("9.0"); + const std::vector& availablePlatforms = + parser.GetAvailablePlatforms(); + for (std::string const& i : availablePlatforms) { + platforms.emplace_back(i); + } + return platforms; + } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 0860294..4b08b11 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -149,6 +149,16 @@ public: bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return true; } + + std::vector GetKnownPlatforms() const override + { + std::vector 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 GetKnownPlatforms() const override + { + std::vector platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("ARM"); + platforms.emplace_back("ARM64"); + return platforms; + } }; cmGlobalGeneratorFactory* diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index e5ab0e1..ca5dafe 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -147,6 +147,11 @@ public: bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return false; } + + std::vector GetKnownPlatforms() const override + { + return std::vector(); + } }; cmGlobalXCodeGenerator::cmGlobalXCodeGenerator( diff --git a/Source/cmake.cxx b/Source/cmake.cxx index f320aff..927d39b 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -976,6 +976,7 @@ void cmake::GetRegisteredGenerators(std::vector& generators, GeneratorInfo info; info.supportsToolset = gen->SupportsToolset(); info.supportsPlatform = gen->SupportsPlatform(); + info.supportedPlatforms = gen->GetKnownPlatforms(); info.name = name; info.baseName = name; info.isAlias = false; diff --git a/Source/cmake.h b/Source/cmake.h index b37cccd..d67f835 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -104,6 +104,7 @@ public: std::string extraName; bool supportsToolset; bool supportsPlatform; + std::vector supportedPlatforms; bool isAlias; }; -- cgit v0.12