diff options
author | Gilles Khouzam <gillesk@microsoft.com> | 2014-08-11 18:21:16 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-08-21 13:28:20 (GMT) |
commit | cb1aceed8ceb29d5f01f6444133060e603297fec (patch) | |
tree | b3957663dbf5fa324b165a2b9f1c28b6710f46c8 /Source | |
parent | 401269e43b49ce25e247efb1fa3503b32eafa411 (diff) | |
download | CMake-cb1aceed8ceb29d5f01f6444133060e603297fec.zip CMake-cb1aceed8ceb29d5f01f6444133060e603297fec.tar.gz CMake-cb1aceed8ceb29d5f01f6444133060e603297fec.tar.bz2 |
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>
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 27 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.cxx | 6 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.h | 1 |
3 files changed, 33 insertions, 1 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index b1dec64..b4ece20 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("<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; } diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index b14fc45..eeaf126 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -107,6 +107,12 @@ bool cmVisualStudioGeneratorOptions::IsDebug() const } //---------------------------------------------------------------------------- +bool cmVisualStudioGeneratorOptions::IsWinRt() const +{ + return this->FlagMap.find("CompileAsWinRT") != this->FlagMap.end(); +} + +//---------------------------------------------------------------------------- bool cmVisualStudioGeneratorOptions::UsingUnicode() const { // Look for the a _UNICODE definition. diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index 47a7c62..5829e17 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, |