From 6fe770e163daf005cd151798c18b89ad50c17125 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Jul 2014 14:48:20 -0400 Subject: [PATCH] VS: Add a source file property to set the hlsl shader type Create a VS_SHADER_TYPE source file property. Inspired-by: Gilles Khouzam --- Help/manual/cmake-properties.7.rst | 1 + Help/prop_sf/VS_SHADER_TYPE.rst | 4 ++++ Source/cmVisualStudio10TargetGenerator.cxx | 17 +++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 Help/prop_sf/VS_SHADER_TYPE.rst diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 3b7436a3c..81b00fa07 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/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 diff --git a/Help/prop_sf/VS_SHADER_TYPE.rst b/Help/prop_sf/VS_SHADER_TYPE.rst new file mode 100644 index 000000000..688025608 --- /dev/null +++ b/Help/prop_sf/VS_SHADER_TYPE.rst @@ -0,0 +1,4 @@ +VS_SHADER_TYPE +-------------- + +Set the VS shader type of a ``.hlsl`` source file. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 01a3b373e..6989c5154 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/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("", 3); + (*this->BuildFileStream) << cmVS10EscapeXML(shaderType) + << "\n"; + } this->WriteString("BuildFileStream) << tool << ">\n";