From 7ad002d75963c32195a8e0f1d7c4512776a65da5 Mon Sep 17 00:00:00 2001
From: Robert Goulet <robert.goulet@autodesk.com>
Date: Tue, 27 Jan 2015 14:47:05 -0500
Subject: [PATCH] Add target property to allow disabling Windows Store support
 for specific targets.

---
 Source/cmCustomCommandGenerator.cxx        |  2 +-
 Source/cmGlobalVisualStudio10Generator.h   |  4 ++--
 Source/cmVisualStudio10TargetGenerator.cxx | 18 +++++++++---------
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 162d7a1..0eac7a1 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -43,7 +43,7 @@ std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const
   std::string const& argv0 = this->CC.GetCommandLines()[c][0];
   cmTarget* target = this->Makefile->FindTargetToUse(argv0);
   if(target && target->GetType() == cmTarget::EXECUTABLE &&
-     (target->IsImported() || !this->Makefile->IsOn("CMAKE_CROSSCOMPILING")))
+     (target->IsImported() || !this->Makefile->IsOn("CMAKE_CROSSCOMPILING") || target->GetPropertyAsBool("VS_WINRT_DISABLE")))
     {
     return target->GetLocation(this->Config);
     }
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 3b0a5cf..78c181a 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -81,8 +81,8 @@ public:
     { return this->SystemIsWindowsPhone; }
 
   /** Return true if building for WindowsStore */
-  bool TargetsWindowsStore() const
-    { return this->SystemIsWindowsStore; }
+  bool TargetsWindowsStore(cmTarget* target) const
+    { return target ? this->SystemIsWindowsStore && !target->GetPropertyAsBool("VS_WINRT_DISABLE") : this->SystemIsWindowsStore; }
 
   /**
    * Where does this version of Visual Studio look for macros for the
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index d2f6ffd..974e4ce 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -708,7 +708,7 @@ void cmVisualStudio10TargetGenerator
       this->ClOptions[config]->UsingUnicode()) ||
      this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
      this->GlobalGenerator->TargetsWindowsPhone() ||
-     this->GlobalGenerator->TargetsWindowsStore() ||
+     this->GlobalGenerator->TargetsWindowsStore(Target) ||
      this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
     {
     this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
@@ -1276,7 +1276,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
   std::string deployContent;
   std::string deployLocation;
   if(this->GlobalGenerator->TargetsWindowsPhone() ||
-     this->GlobalGenerator->TargetsWindowsStore())
+     this->GlobalGenerator->TargetsWindowsStore(Target))
     {
     const char* content = sf->GetProperty("VS_DEPLOYMENT_CONTENT");
     if(content && *content)
@@ -1907,7 +1907,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
         clOptions.AddDefine("_WINRT_DLL");
         }
       }
-    else if (this->GlobalGenerator->TargetsWindowsStore() ||
+    else if (this->GlobalGenerator->TargetsWindowsStore(Target) ||
              this->GlobalGenerator->TargetsWindowsPhone())
       {
       if (!clOptions.IsWinRt())
@@ -2125,7 +2125,7 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
   // and WindowsStore tools look at GenerateWindowsMetadata in the
   // Link tool options even for static libraries.
   if(this->GlobalGenerator->TargetsWindowsPhone() ||
-     this->GlobalGenerator->TargetsWindowsStore())
+     this->GlobalGenerator->TargetsWindowsStore(Target))
     {
     this->WriteString("<Link>\n", 2);
     this->WriteString("<GenerateWindowsMetadata>false"
@@ -2401,7 +2401,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
       linkOptions.AddFlag("GenerateWindowsMetadata", "true");
       }
     else if (this->GlobalGenerator->TargetsWindowsPhone() ||
-             this->GlobalGenerator->TargetsWindowsStore())
+             this->GlobalGenerator->TargetsWindowsStore(Target))
       {
       // WindowsPhone and WindowsStore components are in an app container
       // and produce WindowsMetadata.  If we are not producing a WINRT
@@ -2677,7 +2677,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
 
 void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
 {
-  if((this->GlobalGenerator->TargetsWindowsStore() ||
+  if((this->GlobalGenerator->TargetsWindowsStore(Target) ||
       this->GlobalGenerator->TargetsWindowsPhone())
       && (cmTarget::EXECUTABLE == this->Target->GetType()))
     {
@@ -2751,7 +2751,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
 {
   bool isAppContainer = false;
   bool const isWindowsPhone = this->GlobalGenerator->TargetsWindowsPhone();
-  bool const isWindowsStore = this->GlobalGenerator->TargetsWindowsStore();
+  bool const isWindowsStore = this->GlobalGenerator->TargetsWindowsStore(Target);
   std::string const& v = this->GlobalGenerator->GetSystemVersion();
   if(isWindowsPhone || isWindowsStore)
     {
@@ -2847,7 +2847,7 @@ void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles()
             }
           }
         }
-      else if (this->GlobalGenerator->TargetsWindowsStore())
+      else if (this->GlobalGenerator->TargetsWindowsStore(Target))
         {
         if (manifestSources.empty())
           {
@@ -2879,7 +2879,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFiles()
       this->WriteMissingFilesWP81();
       }
     }
-  else if (this->GlobalGenerator->TargetsWindowsStore())
+  else if (this->GlobalGenerator->TargetsWindowsStore(Target))
    {
    if (v == "8.0")
      {
-- 
1.9.4.msysgit.0

