Преглед изворни кода

VS: Add a source file property to set the hlsl shader type

Create a VS_SHADER_TYPE source file property.

Inspired-by: Gilles Khouzam <[email protected]>
Brad King пре 11 година
родитељ
комит
6fe770e163

+ 1 - 0
Help/manual/cmake-properties.7.rst

@@ -288,6 +288,7 @@ Properties on Source Files
    /prop_sf/OBJECT_OUTPUTS
    /prop_sf/SYMBOLIC
    /prop_sf/VS_DEPLOYMENT_CONTENT
+   /prop_sf/VS_SHADER_TYPE
    /prop_sf/WRAP_EXCLUDE
    /prop_sf/XCODE_EXPLICIT_FILE_TYPE
    /prop_sf/XCODE_LAST_KNOWN_FILE_TYPE

+ 4 - 0
Help/prop_sf/VS_SHADER_TYPE.rst

@@ -0,0 +1,4 @@
+VS_SHADER_TYPE
+--------------
+
+Set the VS shader type of a ``.hlsl`` source file.

+ 17 - 0
Source/cmVisualStudio10TargetGenerator.cxx

@@ -1020,11 +1020,22 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
 {
   bool toolHasSettings = false;
   std::string tool = "None";
+  std::string shaderType;
   std::string const& ext = sf->GetExtension();
   if(ext == "appxmanifest")
     {
     tool = "AppxManifest";
     }
+  else if(ext == "hlsl")
+    {
+    tool = "FXCompile";
+    // Figure out the type of shader compiler to use.
+    if(const char* st = sf->GetProperty("VS_SHADER_TYPE"))
+      {
+      shaderType = st;
+      toolHasSettings = true;
+      }
+    }
   else if(ext == "jpg" ||
           ext == "png")
     {
@@ -1078,6 +1089,12 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
           }
         }
       }
+    if(!shaderType.empty())
+      {
+      this->WriteString("<ShaderType>", 3);
+      (*this->BuildFileStream) << cmVS10EscapeXML(shaderType)
+                               << "</ShaderType>\n";
+      }
 
     this->WriteString("</", 2);
     (*this->BuildFileStream) << tool << ">\n";