Commit cb1aceed authored by Gilles Khouzam's avatar Gilles Khouzam Committed by Brad King
Browse files

VS: Add VS_WINRT_COMPONENT property to enable CompileAsWinRT



Deprecate VS_WINRT_EXTENSIONS and document VS_WINRT_COMPONENT as for VS
generators only.  Also define _WINRT_DLL in SHARED libraries in order to
get a .lib produced.
Inspired-by: default avatarPaul Annetts <paul@lightunobscured.com>
parent 401269e4
......@@ -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
......
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.
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.
......@@ -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("<CharacterSet>Unicode</CharacterSet>\n", 2);
......@@ -611,7 +612,8 @@ void cmVisualStudio10TargetGenerator
pts += "</PlatformToolset>\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("<WindowsAppContainer>true"
"</WindowsAppContainer>\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;
}
......
......@@ -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
{
......
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment