Browse Source

Merge topic 'add-vs-shader-properties'

49dab3eb VS: Add VS_SHADER_OUTPUT_HEADER_FILE and VS_SHADER_VARIABLE_NAME properties.

Acked-by: Kitware Robot <[email protected]>
Merge-request: !1319
Brad King 8 years ago
parent
commit
59285ee58e

File diff suppressed because it is too large
+ 0 - 0
Auxiliary/vim/syntax/cmake.vim


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

@@ -392,7 +392,9 @@ Properties on Source Files
    /prop_sf/VS_SHADER_ENTRYPOINT
    /prop_sf/VS_SHADER_FLAGS
    /prop_sf/VS_SHADER_MODEL
+   /prop_sf/VS_SHADER_OUTPUT_HEADER_FILE
    /prop_sf/VS_SHADER_TYPE
+   /prop_sf/VS_SHADER_VARIABLE_NAME
    /prop_sf/VS_TOOL_OVERRIDE.rst
    /prop_sf/VS_XAML_TYPE
    /prop_sf/WRAP_EXCLUDE

+ 5 - 0
Help/prop_sf/VS_SHADER_OUTPUT_HEADER_FILE.rst

@@ -0,0 +1,5 @@
+VS_SHADER_OUTPUT_HEADER_FILE
+----------------------------
+
+Set filename for output header file containing object code of a ``.hlsl``
+source file.

+ 5 - 0
Help/prop_sf/VS_SHADER_VARIABLE_NAME.rst

@@ -0,0 +1,5 @@
+VS_SHADER_VARIABLE_NAME
+-----------------------
+
+Set name of variable in header file containing object code of a ``.hlsl``
+source file.

+ 6 - 0
Help/release/dev/add-vs-shader-properties.rst

@@ -0,0 +1,6 @@
+add-vs-shader-properties
+------------------------
+
+* Source file properties :prop_sf:`VS_SHADER_OUTPUT_HEADER_FILE` and
+  :prop_sf:`VS_SHADER_VARIABLE_NAME` have been added to specify more
+  details of ``.hlsl`` sources with :ref:`Visual Studio Generators`.

+ 34 - 0
Source/cmVisualStudio10TargetGenerator.cxx

@@ -1592,6 +1592,8 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
   std::string shaderEntryPoint;
   std::string shaderModel;
   std::string shaderAdditionalFlags;
+  std::string outputHeaderFile;
+  std::string variableName;
   std::string settingsGenerator;
   std::string settingsLastGenOutput;
   std::string sourceLink;
@@ -1641,6 +1643,16 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
       shaderModel = sm;
       toolHasSettings = true;
     }
+    // Figure out which output header file to use if any
+    if (const char* ohf = sf->GetProperty("VS_SHADER_OUTPUT_HEADER_FILE")) {
+      outputHeaderFile = ohf;
+      toolHasSettings = true;
+    }
+    // Figure out which variable name to use if any
+    if (const char* vn = sf->GetProperty("VS_SHADER_VARIABLE_NAME")) {
+      variableName = vn;
+      toolHasSettings = true;
+    }
     // Figure out if there's any additional flags to use
     if (const char* saf = sf->GetProperty("VS_SHADER_FLAGS")) {
       shaderAdditionalFlags = saf;
@@ -1766,6 +1778,28 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
       (*this->BuildFileStream) << cmVS10EscapeXML(shaderModel)
                                << "</ShaderModel>\n";
     }
+    if (!outputHeaderFile.empty()) {
+      for (size_t i = 0; i != this->Configurations.size(); ++i) {
+        this->WriteString("<HeaderFileOutput Condition=\""
+                          "'$(Configuration)|$(Platform)'=='",
+                          3);
+        (*this->BuildFileStream) << this->Configurations[i] << "|"
+                                 << this->Platform << "'\">"
+                                 << cmVS10EscapeXML(outputHeaderFile);
+        this->WriteString("</HeaderFileOutput>\n", 0);
+      }
+    }
+    if (!variableName.empty()) {
+      for (size_t i = 0; i != this->Configurations.size(); ++i) {
+        this->WriteString("<VariableName Condition=\""
+                          "'$(Configuration)|$(Platform)'=='",
+                          3);
+        (*this->BuildFileStream) << this->Configurations[i] << "|"
+                                 << this->Platform << "'\">"
+                                 << cmVS10EscapeXML(variableName);
+        this->WriteString("</VariableName>\n", 0);
+      }
+    }
     if (!shaderAdditionalFlags.empty()) {
       this->WriteString("<AdditionalOptions>", 3);
       (*this->BuildFileStream) << cmVS10EscapeXML(shaderAdditionalFlags)

+ 4 - 2
Tests/VSWinStorePhone/CMakeLists.txt

@@ -116,12 +116,14 @@ set_property(SOURCE ${RELEASE_CONTENT_FILES} PROPERTY
 set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel)
 set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainPS)
 set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3)
-set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED /Fh \"$(OutDir)%(Filename).h\"")
+set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED")
+set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h")
 
 set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_TYPE Vertex)
 set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainVS)
 set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3)
-set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED /Fh \"$(OutDir)%(Filename).h\"")
+set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED")
+set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h")
 
 
 source_group("Source Files" FILES ${SOURCE_FILES})

Some files were not shown because too many files changed in this diff