Browse Source

VS10: Define CMAKE_VS_PLATFORM_TOOLSET variable

When the VS 10 generator selects a non-default PlatformToolset to
specify for MSBuild, report the selected name in this variable.
Brad King 13 years ago
parent
commit
89595d6bce

+ 10 - 0
Source/cmDocumentVariables.cxx

@@ -282,6 +282,16 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
      "This variable is around for backwards compatibility, "
      "see CMAKE_BUILD_TOOL.",false,
      "Variables that Provide Information");
+  cm->DefineProperty
+    ("CMAKE_VS_PLATFORM_TOOLSET", cmProperty::VARIABLE,
+     "Visual Studio Platform Toolset name.",
+     "VS 10 and above use MSBuild under the hood and support multiple "
+     "compiler toolchains.  "
+     "CMake may specify a toolset explicitly, such as \"v110\" for "
+     "VS 11 or \"Windows7.1SDK\" for 64-bit support in VS 10 Express.  "
+     "CMake provides the name of the chosen toolset in this variable."
+     ,false,
+     "Variables that Provide Information");
   cm->DefineProperty
     ("CMAKE_MINOR_VERSION", cmProperty::VARIABLE,
      "The Minor version of cmake (i.e. the 4 in X.4.X).",

+ 11 - 0
Source/cmGlobalVisualStudio10Generator.cxx

@@ -27,6 +27,17 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator()
     "ProductDir", vc10Express, cmSystemTools::KeyWOW64_32);
 }
 
+//----------------------------------------------------------------------------
+void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf)
+{
+  cmGlobalVisualStudio8Generator::AddPlatformDefinitions(mf);
+  if(!this->PlatformToolset.empty())
+    {
+    mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET",
+                      this->PlatformToolset.c_str());
+    }
+}
+
 //----------------------------------------------------------------------------
 void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
 {

+ 1 - 0
Source/cmGlobalVisualStudio10Generator.h

@@ -38,6 +38,7 @@ public:
   virtual const char* GetName() const {
     return cmGlobalVisualStudio10Generator::GetActualName();}
   static const char* GetActualName() {return "Visual Studio 10";}
+  virtual void AddPlatformDefinitions(cmMakefile* mf);
 
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry) const;