diff options
-rw-r--r-- | Help/manual/cmake-properties.7.rst | 1 | ||||
-rw-r--r-- | Help/prop_tgt/VS_WINRT_COMPONENT.rst | 14 | ||||
-rw-r--r-- | Help/prop_tgt/VS_WINRT_EXTENSIONS.rst | 5 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 27 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.cxx | 6 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.h | 1 |
6 files changed, 50 insertions, 4 deletions
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 5b0673a..d28229a 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 0000000..a017f0e --- /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 cc6fb16..d1cba34 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 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, |