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: Paul Annetts <paul@lightunobscured.com>
This commit is contained in:
parent
401269e43b
commit
cb1aceed8c
|
@ -235,6 +235,7 @@ Properties on Targets
|
||||||
/prop_tgt/VS_SCC_LOCALPATH
|
/prop_tgt/VS_SCC_LOCALPATH
|
||||||
/prop_tgt/VS_SCC_PROJECTNAME
|
/prop_tgt/VS_SCC_PROJECTNAME
|
||||||
/prop_tgt/VS_SCC_PROVIDER
|
/prop_tgt/VS_SCC_PROVIDER
|
||||||
|
/prop_tgt/VS_WINRT_COMPONENT
|
||||||
/prop_tgt/VS_WINRT_EXTENSIONS
|
/prop_tgt/VS_WINRT_EXTENSIONS
|
||||||
/prop_tgt/VS_WINRT_REFERENCES
|
/prop_tgt/VS_WINRT_REFERENCES
|
||||||
/prop_tgt/WIN32_EXECUTABLE
|
/prop_tgt/WIN32_EXECUTABLE
|
||||||
|
|
|
@ -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.
|
|
@ -1,6 +1,5 @@
|
||||||
VS_WINRT_EXTENSIONS
|
VS_WINRT_EXTENSIONS
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
Visual Studio project C++/CX language extensions for Windows Runtime
|
Deprecated. Use :prop_tgt:`VS_WINRT_COMPONENT` instead.
|
||||||
|
This property was an experimental partial implementation of that one.
|
||||||
Can be set to enable C++/CX language extensions.
|
|
||||||
|
|
|
@ -591,6 +591,7 @@ void cmVisualStudio10TargetGenerator
|
||||||
|
|
||||||
if((this->Target->GetType() <= cmTarget::OBJECT_LIBRARY &&
|
if((this->Target->GetType() <= cmTarget::OBJECT_LIBRARY &&
|
||||||
this->ClOptions[config]->UsingUnicode()) ||
|
this->ClOptions[config]->UsingUnicode()) ||
|
||||||
|
this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
|
||||||
this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
|
this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
|
||||||
{
|
{
|
||||||
this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
|
this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
|
||||||
|
@ -611,7 +612,8 @@ void cmVisualStudio10TargetGenerator
|
||||||
pts += "</PlatformToolset>\n";
|
pts += "</PlatformToolset>\n";
|
||||||
this->WriteString(pts.c_str(), 2);
|
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"
|
this->WriteString("<WindowsAppContainer>true"
|
||||||
"</WindowsAppContainer>\n", 2);
|
"</WindowsAppContainer>\n", 2);
|
||||||
|
@ -1604,6 +1606,29 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
||||||
clOptions.AddDefine(exportMacro);
|
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();
|
this->ClOptions[configName] = pOptions.release();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,12 @@ bool cmVisualStudioGeneratorOptions::IsDebug() const
|
||||||
return this->FlagMap.find("DebugInformationFormat") != this->FlagMap.end();
|
return this->FlagMap.find("DebugInformationFormat") != this->FlagMap.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool cmVisualStudioGeneratorOptions::IsWinRt() const
|
||||||
|
{
|
||||||
|
return this->FlagMap.find("CompileAsWinRT") != this->FlagMap.end();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmVisualStudioGeneratorOptions::UsingUnicode() const
|
bool cmVisualStudioGeneratorOptions::UsingUnicode() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
bool UsingSBCS() const;
|
bool UsingSBCS() const;
|
||||||
|
|
||||||
bool IsDebug() const;
|
bool IsDebug() const;
|
||||||
|
bool IsWinRt() const;
|
||||||
// Write options to output.
|
// Write options to output.
|
||||||
void OutputPreprocessorDefinitions(std::ostream& fout,
|
void OutputPreprocessorDefinitions(std::ostream& fout,
|
||||||
const char* prefix,
|
const char* prefix,
|
||||||
|
|
Loading…
Reference in New Issue