diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 5b0673ac0..d28229a3a 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -235,6 +235,7 @@ Properties on Targets
/prop_tgt/VS_SCC_LOCALPATH
/prop_tgt/VS_SCC_PROJECTNAME
/prop_tgt/VS_SCC_PROVIDER
+ /prop_tgt/VS_WINRT_COMPONENT
/prop_tgt/VS_WINRT_EXTENSIONS
/prop_tgt/VS_WINRT_REFERENCES
/prop_tgt/WIN32_EXECUTABLE
diff --git a/Help/prop_tgt/VS_WINRT_COMPONENT.rst b/Help/prop_tgt/VS_WINRT_COMPONENT.rst
new file mode 100644
index 000000000..a017f0ea7
--- /dev/null
+++ b/Help/prop_tgt/VS_WINRT_COMPONENT.rst
@@ -0,0 +1,14 @@
+VS_WINRT_COMPONENT
+------------------
+
+Mark a target as a Windows Runtime component for the Visual Studio generator.
+Compile the target with ``C++/CX`` language extensions for Windows Runtime.
+For ``SHARED`` and ``MODULE`` libraries, this also defines the
+``_WINRT_DLL`` preprocessor macro.
+
+.. note::
+ Behavior is not defined for targets with source files that compile as
+ any language other than ``CXX``.
+
+ Currently this is implemented only by Visual Studio generators.
+ Support may be added to other generators in the future.
diff --git a/Help/prop_tgt/VS_WINRT_EXTENSIONS.rst b/Help/prop_tgt/VS_WINRT_EXTENSIONS.rst
index cc6fb16b0..d1cba3471 100644
--- a/Help/prop_tgt/VS_WINRT_EXTENSIONS.rst
+++ b/Help/prop_tgt/VS_WINRT_EXTENSIONS.rst
@@ -1,6 +1,5 @@
VS_WINRT_EXTENSIONS
-------------------
-Visual Studio project C++/CX language extensions for Windows Runtime
-
-Can be set to enable C++/CX language extensions.
+Deprecated. Use :prop_tgt:`VS_WINRT_COMPONENT` instead.
+This property was an experimental partial implementation of that one.
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index b1dec6487..b4ece20a8 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -591,6 +591,7 @@ void cmVisualStudio10TargetGenerator
if((this->Target->GetType() <= cmTarget::OBJECT_LIBRARY &&
this->ClOptions[config]->UsingUnicode()) ||
+ this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
{
this->WriteString("Unicode\n", 2);
@@ -611,7 +612,8 @@ void cmVisualStudio10TargetGenerator
pts += "\n";
this->WriteString(pts.c_str(), 2);
}
- if(this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
+ if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
+ this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
{
this->WriteString("true"
"\n", 2);
@@ -1604,6 +1606,29 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
clOptions.AddDefine(exportMacro);
}
+ if (this->MSTools)
+ {
+ // If we have the VS_WINRT_COMPONENT set then force Compile as WinRT.
+ if (this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT"))
+ {
+ clOptions.AddFlag("CompileAsWinRT", "true");
+ // For WinRT components, add the _WINRT_DLL define to produce a lib
+ if (this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
+ this->Target->GetType() == cmTarget::MODULE_LIBRARY )
+ {
+ clOptions.AddDefine("_WINRT_DLL");
+ }
+ }
+ else if (this->GlobalGenerator->TargetsWindowsStore() ||
+ this->GlobalGenerator->TargetsWindowsPhone())
+ {
+ if (!clOptions.IsWinRt())
+ {
+ clOptions.AddFlag("CompileAsWinRT", "false");
+ }
+ }
+ }
+
this->ClOptions[configName] = pOptions.release();
return true;
}
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index b14fc45c0..eeaf1261f 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -106,6 +106,12 @@ bool cmVisualStudioGeneratorOptions::IsDebug() const
return this->FlagMap.find("DebugInformationFormat") != this->FlagMap.end();
}
+//----------------------------------------------------------------------------
+bool cmVisualStudioGeneratorOptions::IsWinRt() const
+{
+ return this->FlagMap.find("CompileAsWinRT") != this->FlagMap.end();
+}
+
//----------------------------------------------------------------------------
bool cmVisualStudioGeneratorOptions::UsingUnicode() const
{
diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h
index 47a7c62c6..5829e173c 100644
--- a/Source/cmVisualStudioGeneratorOptions.h
+++ b/Source/cmVisualStudioGeneratorOptions.h
@@ -52,6 +52,7 @@ public:
bool UsingSBCS() const;
bool IsDebug() const;
+ bool IsWinRt() const;
// Write options to output.
void OutputPreprocessorDefinitions(std::ostream& fout,
const char* prefix,