Browse Source

VS: Add support for .NET target framework version

Teach CMake to generate the TargetFrameworkVersion XML node as
documented at

 http://msdn.microsoft.com/en-us/library/vstudio/ff770576.aspx

from target property VS_DOTNET_TARGET_FRAMEWORK_VERSION.
Christian Maaser 12 years ago
parent
commit
cfe6300a41
2 changed files with 12 additions and 0 deletions
  1. 5 0
      Source/cmTarget.cxx
  2. 7 0
      Source/cmVisualStudio10TargetGenerator.cxx

+ 5 - 0
Source/cmTarget.cxx

@@ -1402,6 +1402,11 @@ void cmTarget::DefineProperties(cmake *cm)
      "Visual Studio project root namespace.",
      "Visual Studio project root namespace.",
      "Sets the \"RootNamespace\" attribute for a generated Visual Studio "
      "Sets the \"RootNamespace\" attribute for a generated Visual Studio "
      "project.  The attribute will be generated only if this is set.");
      "project.  The attribute will be generated only if this is set.");
+  cm->DefineProperty
+    ("VS_DOTNET_TARGET_FRAMEWORK_VERSION", cmProperty::TARGET,
+     "Specify the .NET target framework version.",
+     "Used to specify the .NET target framework version for C++/CLI. "
+     "For example, \"v4.5\".");
   cm->DefineProperty
   cm->DefineProperty
     ("VS_DOTNET_REFERENCES", cmProperty::TARGET,
     ("VS_DOTNET_REFERENCES", cmProperty::TARGET,
      "Visual Studio managed project .NET references",
      "Visual Studio managed project .NET references",

+ 7 - 0
Source/cmVisualStudio10TargetGenerator.cxx

@@ -280,6 +280,13 @@ void cmVisualStudio10TargetGenerator::Generate()
     }
     }
   this->WriteString("<ProjectName>", 2);
   this->WriteString("<ProjectName>", 2);
   (*this->BuildFileStream) << projLabel << "</ProjectName>\n";
   (*this->BuildFileStream) << projLabel << "</ProjectName>\n";
+  if(const char* targetFrameworkVersion = this->Target->GetProperty(
+       "VS_DOTNET_TARGET_FRAMEWORK_VERSION"))
+    {
+    this->WriteString("<TargetFrameworkVersion>", 2);
+    (*this->BuildFileStream) << targetFrameworkVersion
+                             << "</TargetFrameworkVersion>\n";
+    }
   this->WriteString("</PropertyGroup>\n", 1);
   this->WriteString("</PropertyGroup>\n", 1);
   this->WriteString("<Import Project="
   this->WriteString("<Import Project="
                     "\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n",
                     "\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n",