From b70c0aed5c616edce5cbc803c7de92580f835f90 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 18 Jan 2019 11:41:31 -0500 Subject: VS: Factor out helper function to compute host platform name --- Source/cmGlobalVisualStudioVersionedGenerator.cxx | 25 ++++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 99f9503..15e52fe 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -19,6 +19,20 @@ # include "cmsys/SystemInformation.hxx" #endif +static std::string VSHostPlatformName() +{ +#ifdef HOST_PLATFORM_NAME + return HOST_PLATFORM_NAME; +#else + cmsys::SystemInformation info; + if (info.Is64Bits()) { + return "x64"; + } else { + return "Win32"; + } +#endif +} + static unsigned int VSVersionToMajor( cmGlobalVisualStudioGenerator::VSVersion v) { @@ -206,16 +220,7 @@ cmGlobalVisualStudioVersionedGenerator::cmGlobalVisualStudioVersionedGenerator( this->DefaultCSharpFlagTableName = VSVersionToToolset(this->Version); this->DefaultLinkFlagTableName = VSVersionToToolset(this->Version); if (this->Version >= cmGlobalVisualStudioGenerator::VS16) { -#ifdef HOST_PLATFORM_NAME - this->DefaultPlatformName = HOST_PLATFORM_NAME; -#else - cmsys::SystemInformation info; - if (info.Is64Bits()) { - this->DefaultPlatformName = "x64"; - } else { - this->DefaultPlatformName = "Win32"; - } -#endif + this->DefaultPlatformName = VSHostPlatformName(); } } -- cgit v0.12 From 8144b00e32cf1e24daf41353cbcd1806311ceac9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 18 Jan 2019 11:08:45 -0500 Subject: 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. --- Source/cmGlobalGeneratorFactory.h | 11 +++++++++-- Source/cmGlobalVisualStudio10Generator.cxx | 10 +++++++++- Source/cmGlobalVisualStudio11Generator.cxx | 11 ++++++++++- Source/cmGlobalVisualStudio12Generator.cxx | 10 +++++++++- Source/cmGlobalVisualStudio14Generator.cxx | 10 +++++++++- Source/cmGlobalVisualStudio9Generator.cxx | 10 +++++++++- Source/cmGlobalVisualStudioVersionedGenerator.cxx | 19 +++++++++++++++++-- Source/cmGlobalXCodeGenerator.cxx | 9 ++++++++- Source/cmake.cxx | 14 ++++++++++---- Source/cmake.h | 3 ++- 10 files changed, 92 insertions(+), 15 deletions(-) diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h index 4e3e770..906ec9a 100644 --- a/Source/cmGlobalGeneratorFactory.h +++ b/Source/cmGlobalGeneratorFactory.h @@ -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& names) const = 0; + virtual std::vector GetGeneratorNames() const = 0; + virtual std::vector 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& names) const override + std::vector GetGeneratorNames() const override { + std::vector names; names.push_back(T::GetActualName()); + return names; + } + std::vector GetGeneratorNamesWithPlatform() const override + { + return std::vector(); } /** Determine whether or not this generator supports toolsets */ diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 79757a8..bf856ea 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -74,11 +74,19 @@ public: "Optional [arch] can be \"Win64\" or \"IA64\"."; } - void GetGenerators(std::vector& names) const override + std::vector GetGeneratorNames() const override { + std::vector names; names.push_back(vs10generatorName); + return names; + } + + std::vector GetGeneratorNamesWithPlatform() const override + { + std::vector names; names.push_back(vs10generatorName + std::string(" IA64")); names.push_back(vs10generatorName + std::string(" Win64")); + return names; } bool SupportsToolset() const override { return true; } diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 36eb492..a44058b 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -69,9 +69,16 @@ public: "Optional [arch] can be \"Win64\" or \"ARM\"."; } - void GetGenerators(std::vector& names) const override + std::vector GetGeneratorNames() const override { + std::vector names; names.push_back(vs11generatorName); + return names; + } + + std::vector GetGeneratorNamesWithPlatform() const override + { + std::vector 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; } diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 61034a7..cbd5085 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -58,11 +58,19 @@ public: "Optional [arch] can be \"Win64\" or \"ARM\"."; } - void GetGenerators(std::vector& names) const override + std::vector GetGeneratorNames() const override { + std::vector names; names.push_back(vs12generatorName); + return names; + } + + std::vector GetGeneratorNamesWithPlatform() const override + { + std::vector names; names.push_back(vs12generatorName + std::string(" ARM")); names.push_back(vs12generatorName + std::string(" Win64")); + return names; } bool SupportsToolset() const override { return true; } diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 5ea5e67..47768a8 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -58,11 +58,19 @@ public: "Optional [arch] can be \"Win64\" or \"ARM\"."; } - void GetGenerators(std::vector& names) const override + std::vector GetGeneratorNames() const override { + std::vector names; names.push_back(vs14generatorName); + return names; + } + + std::vector GetGeneratorNamesWithPlatform() const override + { + std::vector names; names.push_back(vs14generatorName + std::string(" ARM")); names.push_back(vs14generatorName + std::string(" Win64")); + return names; } bool SupportsToolset() const override { return true; } diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 445b40c..d72b25b 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -59,9 +59,16 @@ public: "Optional [arch] can be \"Win64\" or \"IA64\"."; } - void GetGenerators(std::vector& names) const override + std::vector GetGeneratorNames() const override { + std::vector names; names.push_back(vs9generatorName); + return names; + } + + std::vector GetGeneratorNamesWithPlatform() const override + { + std::vector 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; } diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 15e52fe..0860294 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -132,11 +132,19 @@ public: "Optional [arch] can be \"Win64\" or \"ARM\"."; } - void GetGenerators(std::vector& names) const override + std::vector GetGeneratorNames() const override { + std::vector names; names.push_back(vs15generatorName); + return names; + } + + std::vector GetGeneratorNamesWithPlatform() const override + { + std::vector 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& names) const + std::vector GetGeneratorNames() const override { + std::vector names; names.push_back(vs16generatorName); + return names; + } + + std::vector GetGeneratorNamesWithPlatform() const override + { + return std::vector(); } bool SupportsToolset() const override { return true; } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6618351..e5ab0e1 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -133,9 +133,16 @@ public: cmGlobalXCodeGenerator::GetDocumentation(entry); } - void GetGenerators(std::vector& names) const override + std::vector GetGeneratorNames() const override { + std::vector names; names.push_back(cmGlobalXCodeGenerator::GetActualName()); + return names; + } + + std::vector GetGeneratorNamesWithPlatform() const override + { + return std::vector(); } bool SupportsToolset() const override { return true; } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9fcfbde..f320aff 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -959,12 +959,18 @@ void cmake::AddDefaultExtraGenerators() #endif } -void cmake::GetRegisteredGenerators( - std::vector& generators) const +void cmake::GetRegisteredGenerators(std::vector& generators, + bool includeNamesWithPlatform) const { for (cmGlobalGeneratorFactory* gen : this->Generators) { - std::vector names; - gen->GetGenerators(names); + std::vector names = gen->GetGeneratorNames(); + + if (includeNamesWithPlatform) { + std::vector namesWithPlatform = + gen->GetGeneratorNamesWithPlatform(); + names.insert(names.end(), namesWithPlatform.begin(), + namesWithPlatform.end()); + } for (std::string const& name : names) { GeneratorInfo info; diff --git a/Source/cmake.h b/Source/cmake.h index cd8c622..b37cccd 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -196,7 +196,8 @@ public: void SetGlobalGenerator(cmGlobalGenerator*); ///! Get the names of the current registered generators - void GetRegisteredGenerators(std::vector& generators) const; + void GetRegisteredGenerators(std::vector& generators, + bool includeNamesWithPlatform = true) const; ///! Set the name of the selected generator-specific instance. void SetGeneratorInstance(std::string const& instance) -- cgit v0.12 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 From 8bba458ea5d6b792e165560d79efd8d8356f4329 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 18 Jan 2019 11:45:33 -0500 Subject: Add global generator factory method to get default platform name --- Source/cmGlobalGeneratorFactory.h | 5 +++++ Source/cmGlobalVisualStudio10Generator.cxx | 2 ++ Source/cmGlobalVisualStudio11Generator.cxx | 2 ++ Source/cmGlobalVisualStudio12Generator.cxx | 2 ++ Source/cmGlobalVisualStudio14Generator.cxx | 2 ++ Source/cmGlobalVisualStudio9Generator.cxx | 2 ++ Source/cmGlobalVisualStudioVersionedGenerator.cxx | 7 +++++++ Source/cmGlobalXCodeGenerator.cxx | 2 ++ Source/cmake.cxx | 1 + Source/cmake.h | 1 + 10 files changed, 26 insertions(+) diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h index 26c9545..d4f772b 100644 --- a/Source/cmGlobalGeneratorFactory.h +++ b/Source/cmGlobalGeneratorFactory.h @@ -41,6 +41,9 @@ public: /** Get the list of supported platforms name for this generator */ virtual std::vector GetKnownPlatforms() const = 0; + + /** If the generator suports platforms, get its default. */ + virtual std::string GetDefaultPlatformName() const = 0; }; template @@ -87,6 +90,8 @@ public: // default is no platform supported return std::vector(); } + + std::string GetDefaultPlatformName() const override { return std::string(); } }; #endif diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index c439f68..dbe582b 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -100,6 +100,8 @@ public: platforms.emplace_back("Itanium"); return platforms; } + + std::string GetDefaultPlatformName() const override { return "Win32"; } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 0aaf2bb..4eb78ba 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -109,6 +109,8 @@ public: return platforms; } + + std::string GetDefaultPlatformName() const override { return "Win32"; } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 1c202a8..8b50684 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -84,6 +84,8 @@ public: platforms.emplace_back("ARM"); return platforms; } + + std::string GetDefaultPlatformName() const override { return "Win32"; } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index c87433e..a0a9558 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -84,6 +84,8 @@ public: platforms.emplace_back("ARM"); return platforms; } + + std::string GetDefaultPlatformName() const override { return "Win32"; } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 15a83af..6e61d26 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -99,6 +99,8 @@ public: } return platforms; } + + std::string GetDefaultPlatformName() const override { return "Win32"; } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 4b08b11..31f585c 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -159,6 +159,8 @@ public: platforms.emplace_back("ARM64"); return platforms; } + + std::string GetDefaultPlatformName() const override { return "Win32"; } }; cmGlobalGeneratorFactory* @@ -234,6 +236,11 @@ public: platforms.emplace_back("ARM64"); return platforms; } + + std::string GetDefaultPlatformName() const override + { + return VSHostPlatformName(); + } }; cmGlobalGeneratorFactory* diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index ca5dafe..4dd1a87 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -152,6 +152,8 @@ public: { return std::vector(); } + + std::string GetDefaultPlatformName() const override { return std::string(); } }; cmGlobalXCodeGenerator::cmGlobalXCodeGenerator( diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 927d39b..2ac1b00 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -977,6 +977,7 @@ void cmake::GetRegisteredGenerators(std::vector& generators, info.supportsToolset = gen->SupportsToolset(); info.supportsPlatform = gen->SupportsPlatform(); info.supportedPlatforms = gen->GetKnownPlatforms(); + info.defaultPlatform = gen->GetDefaultPlatformName(); info.name = name; info.baseName = name; info.isAlias = false; diff --git a/Source/cmake.h b/Source/cmake.h index d67f835..38d0c62 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -105,6 +105,7 @@ public: bool supportsToolset; bool supportsPlatform; std::vector supportedPlatforms; + std::string defaultPlatform; bool isAlias; }; -- cgit v0.12 From 48ec0bc1401b99e5a2d07392fb98f96d5fec9e50 Mon Sep 17 00:00:00 2001 From: Julien Jomier Date: Fri, 4 Jan 2019 12:41:01 +0100 Subject: cmake-gui: Add field for generator platform selection Extend the "first configure" dialog with a field for the user to select a value for `CMAKE_GENERATOR_PLATFORM`. Fixes: #17343 --- Source/QtDialog/CMakeSetupDialog.cxx | 1 + Source/QtDialog/FirstConfigure.cxx | 70 ++++++++++++++++++++++++++++++++++-- Source/QtDialog/FirstConfigure.h | 8 +++++ Source/QtDialog/QCMake.cxx | 21 +++++++++-- Source/QtDialog/QCMake.h | 5 +++ 5 files changed, 101 insertions(+), 4 deletions(-) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 444a980..72cce9f 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -751,6 +751,7 @@ bool CMakeSetupDialog::setupFirstConfigure() if (dialog.exec() == QDialog::Accepted) { dialog.saveToSettings(); this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator()); + this->CMakeThread->cmakeInstance()->setPlatform(dialog.getPlatform()); this->CMakeThread->cmakeInstance()->setToolset(dialog.getToolset()); QCMakeCacheModel* m = this->CacheValues->cacheModel(); diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx index 88ce7cb..66707d6 100644 --- a/Source/QtDialog/FirstConfigure.cxx +++ b/Source/QtDialog/FirstConfigure.cxx @@ -16,8 +16,12 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p) this->GeneratorOptions = new QComboBox(this); l->addWidget(this->GeneratorOptions); + // Add the generator platform + this->PlatformFrame = CreatePlatformWidgets(); + l->addWidget(PlatformFrame); + // Add the ability to specify toolset (-T parameter) - ToolsetFrame = CreateToolsetWidgets(); + this->ToolsetFrame = CreateToolsetWidgets(); l->addWidget(ToolsetFrame); l->addSpacing(6); @@ -45,7 +49,7 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p) SLOT(onSelectionChanged(bool))); QObject::connect(this->CompilerSetupOptions[3], SIGNAL(toggled(bool)), this, SLOT(onSelectionChanged(bool))); - QObject::connect(GeneratorOptions, + QObject::connect(this->GeneratorOptions, SIGNAL(currentIndexChanged(QString const&)), this, SLOT(onGeneratorChanged(QString const&))); } @@ -65,6 +69,24 @@ QFrame* StartCompilerSetup::CreateToolsetWidgets() return frame; } +QFrame* StartCompilerSetup::CreatePlatformWidgets() +{ + QFrame* frame = new QFrame(this); + QVBoxLayout* l = new QVBoxLayout(frame); + l->setContentsMargins(0, 0, 0, 0); + + this->PlatformLabel = + new QLabel(tr("Specify the platform for this generator")); + l->addWidget(this->PlatformLabel); + + this->PlatformOptions = new QComboBox(frame); + this->PlatformOptions->setEditable(true); + + l->addWidget(this->PlatformOptions); + + return frame; +} + StartCompilerSetup::~StartCompilerSetup() { } @@ -80,6 +102,22 @@ void StartCompilerSetup::setGenerators( for (it = gens.begin(); it != gens.end(); ++it) { generator_list.append(QString::fromLocal8Bit(it->name.c_str())); + if (it->supportsPlatform) { + this->GeneratorsSupportingPlatform.append( + QString::fromLocal8Bit(it->name.c_str())); + + std::vector::const_iterator platformIt = + it->supportedPlatforms.cbegin(); + while (platformIt != it->supportedPlatforms.cend()) { + + this->GeneratorSupportedPlatforms.insert( + QString::fromLocal8Bit(it->name.c_str()), + QString::fromLocal8Bit((*platformIt).c_str())); + + platformIt++; + } + } + if (it->supportsToolset) { this->GeneratorsSupportingToolset.append( QString::fromLocal8Bit(it->name.c_str())); @@ -102,6 +140,11 @@ QString StartCompilerSetup::getGenerator() const return this->GeneratorOptions->currentText(); }; +QString StartCompilerSetup::getPlatform() const +{ + return this->PlatformOptions->currentText(); +}; + QString StartCompilerSetup::getToolset() const { return this->Toolset->text(); @@ -136,6 +179,24 @@ void StartCompilerSetup::onSelectionChanged(bool on) void StartCompilerSetup::onGeneratorChanged(QString const& name) { + // Display the generator platform for the generators supporting it + if (GeneratorsSupportingPlatform.contains(name)) { + + // Regenerate the list of supported platform + this->PlatformOptions->clear(); + QStringList platform_list; + platform_list.append(""); + + QList platforms = this->GeneratorSupportedPlatforms.values(name); + platform_list.append(platforms); + + this->PlatformOptions->addItems(platform_list); + PlatformFrame->show(); + } else { + PlatformFrame->hide(); + } + + // Display the toolset box for the generators supporting it if (GeneratorsSupportingToolset.contains(name)) { ToolsetFrame->show(); } else { @@ -390,6 +451,11 @@ QString FirstConfigure::getGenerator() const return this->mStartCompilerSetupPage->getGenerator(); } +QString FirstConfigure::getPlatform() const +{ + return this->mStartCompilerSetupPage->getPlatform(); +} + QString FirstConfigure::getToolset() const { return this->mStartCompilerSetupPage->getToolset(); diff --git a/Source/QtDialog/FirstConfigure.h b/Source/QtDialog/FirstConfigure.h index abfa03f..133f422 100644 --- a/Source/QtDialog/FirstConfigure.h +++ b/Source/QtDialog/FirstConfigure.h @@ -35,6 +35,7 @@ public: void setCurrentGenerator(const QString& gen); QString getGenerator() const; QString getToolset() const; + QString getPlatform() const; bool defaultSetup() const; bool compilerSetup() const; @@ -56,10 +57,16 @@ protected: QFrame* ToolsetFrame; QLineEdit* Toolset; QLabel* ToolsetLabel; + QFrame* PlatformFrame; + QComboBox* PlatformOptions; + QLabel* PlatformLabel; QStringList GeneratorsSupportingToolset; + QStringList GeneratorsSupportingPlatform; + QMultiMap GeneratorSupportedPlatforms; private: QFrame* CreateToolsetWidgets(); + QFrame* CreatePlatformWidgets(); }; //! the page that gives basic options for native compilers @@ -159,6 +166,7 @@ public: void setGenerators(std::vector const& gens); QString getGenerator() const; + QString getPlatform() const; QString getToolset() const; bool defaultSetup() const; diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 9a6784e..2eecce6 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -35,7 +35,8 @@ QCMake::QCMake(QObject* p) cmSystemTools::SetInterruptCallback(QCMake::interruptCallback, this); std::vector generators; - this->CMakeInstance->GetRegisteredGenerators(generators); + this->CMakeInstance->GetRegisteredGenerators( + generators, /*includeNamesWithPlatform=*/false); std::vector::const_iterator it; for (it = generators.begin(); it != generators.end(); ++it) { @@ -74,6 +75,7 @@ void QCMake::setBinaryDirectory(const QString& _dir) cmState* state = this->CMakeInstance->GetState(); this->setGenerator(QString()); this->setToolset(QString()); + this->setPlatform(QString()); if (!this->CMakeInstance->LoadCache( this->BinaryDirectory.toLocal8Bit().data())) { QDir testDir(this->BinaryDirectory); @@ -102,6 +104,12 @@ void QCMake::setBinaryDirectory(const QString& _dir) this->setGenerator(QString::fromLocal8Bit(curGen.c_str())); } + const char* platform = + state->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM"); + if (platform) { + this->setPlatform(QString::fromLocal8Bit(platform)); + } + const char* toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET"); if (toolset) { this->setToolset(QString::fromLocal8Bit(toolset)); @@ -119,6 +127,14 @@ void QCMake::setGenerator(const QString& gen) } } +void QCMake::setPlatform(const QString& platform) +{ + if (this->Platform != platform) { + this->Platform = platform; + emit this->platformChanged(this->Platform); + } +} + void QCMake::setToolset(const QString& toolset) { if (this->Toolset != toolset) { @@ -140,7 +156,8 @@ void QCMake::configure() this->CMakeInstance->SetGlobalGenerator( this->CMakeInstance->CreateGlobalGenerator( this->Generator.toLocal8Bit().data())); - this->CMakeInstance->SetGeneratorPlatform(""); + this->CMakeInstance->SetGeneratorPlatform( + this->Platform.toLocal8Bit().data()); this->CMakeInstance->SetGeneratorToolset(this->Toolset.toLocal8Bit().data()); this->CMakeInstance->LoadCache(); this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode); diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index 4b3920a..c84da58 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -75,6 +75,8 @@ public slots: /// set the desired generator to use void setGenerator(const QString& generator); /// set the desired generator to use + void setPlatform(const QString& platform); + /// set the desired generator to use void setToolset(const QString& toolset); /// do the configure step void configure(); @@ -155,6 +157,8 @@ signals: void debugOutputChanged(bool); /// signal when the toolset changes void toolsetChanged(const QString& toolset); + /// signal when the platform changes + void platformChanged(const QString& platform); /// signal when open is done void openDone(bool successful); /// signal when open is done @@ -175,6 +179,7 @@ protected: QString SourceDirectory; QString BinaryDirectory; QString Generator; + QString Platform; QString Toolset; std::vector AvailableGenerators; QString CMakeExecutable; -- cgit v0.12 From 67bced8a26348e1cc05d8c04ed90633c642bf3a3 Mon Sep 17 00:00:00 2001 From: Julien Jomier Date: Mon, 21 Jan 2019 13:18:26 +0100 Subject: cmake-gui: Improve label for default platform Specify the default platform to be used when the platform field is empty --- Source/QtDialog/FirstConfigure.cxx | 14 ++++++++++++-- Source/QtDialog/FirstConfigure.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx index 66707d6..ae5179c 100644 --- a/Source/QtDialog/FirstConfigure.cxx +++ b/Source/QtDialog/FirstConfigure.cxx @@ -75,8 +75,7 @@ QFrame* StartCompilerSetup::CreatePlatformWidgets() QVBoxLayout* l = new QVBoxLayout(frame); l->setContentsMargins(0, 0, 0, 0); - this->PlatformLabel = - new QLabel(tr("Specify the platform for this generator")); + this->PlatformLabel = new QLabel(tr("Optional platform for generator")); l->addWidget(this->PlatformLabel); this->PlatformOptions = new QComboBox(frame); @@ -106,6 +105,10 @@ void StartCompilerSetup::setGenerators( this->GeneratorsSupportingPlatform.append( QString::fromLocal8Bit(it->name.c_str())); + this + ->GeneratorDefaultPlatform[QString::fromLocal8Bit(it->name.c_str())] = + QString::fromLocal8Bit(it->defaultPlatform.c_str()); + std::vector::const_iterator platformIt = it->supportedPlatforms.cbegin(); while (platformIt != it->supportedPlatforms.cend()) { @@ -182,6 +185,13 @@ void StartCompilerSetup::onGeneratorChanged(QString const& name) // Display the generator platform for the generators supporting it if (GeneratorsSupportingPlatform.contains(name)) { + // Change the label title to include the default platform + std::string label = "Optional platform for generator"; + label += "(if empty, generator uses: "; + label += this->GeneratorDefaultPlatform[name].toStdString(); + label += ")"; + this->PlatformLabel->setText(tr(label.c_str())); + // Regenerate the list of supported platform this->PlatformOptions->clear(); QStringList platform_list; diff --git a/Source/QtDialog/FirstConfigure.h b/Source/QtDialog/FirstConfigure.h index 133f422..d1db5bf 100644 --- a/Source/QtDialog/FirstConfigure.h +++ b/Source/QtDialog/FirstConfigure.h @@ -63,6 +63,7 @@ protected: QStringList GeneratorsSupportingToolset; QStringList GeneratorsSupportingPlatform; QMultiMap GeneratorSupportedPlatforms; + QMap GeneratorDefaultPlatform; private: QFrame* CreateToolsetWidgets(); -- cgit v0.12