From 8bba458ea5d6b792e165560d79efd8d8356f4329 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
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<std::string> GetKnownPlatforms() const = 0;
+
+  /** If the generator suports platforms, get its default.  */
+  virtual std::string GetDefaultPlatformName() const = 0;
 };
 
 template <class T>
@@ -87,6 +90,8 @@ public:
     // default is no platform supported
     return std::vector<std::string>();
   }
+
+  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>();
   }
+
+  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<GeneratorInfo>& 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<std::string> supportedPlatforms;
+    std::string defaultPlatform;
     bool isAlias;
   };
 
-- 
cgit v0.12