From 83ed65cdde4bebc138d31ae80c39cfdbf42a12c2 Mon Sep 17 00:00:00 2001 From: Jeremiah van Oosten Date: Tue, 24 Apr 2018 11:25:13 +0200 Subject: Add generator expressions for VS_SHADER_ source file properties. --- .../dev/vs-shader-generator-expressions.rst | 8 +++++ Source/cmVisualStudio10TargetGenerator.cxx | 39 ++++++++++++++++++---- 2 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 Help/release/dev/vs-shader-generator-expressions.rst diff --git a/Help/release/dev/vs-shader-generator-expressions.rst b/Help/release/dev/vs-shader-generator-expressions.rst new file mode 100644 index 0000000..085be23 --- /dev/null +++ b/Help/release/dev/vs-shader-generator-expressions.rst @@ -0,0 +1,8 @@ +vs-shader-generator-expressions +------------------------------- + +* Added support for generator expressions for the following source file + properties: + + - :prop_sf:`VS_SHADER_DISABLE_OPTIMIZATIONS` + - :prop_sf:`VS_SHADER_ENABLE_DEBUG` diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 5c3b134..d766cb5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1696,12 +1696,12 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) } // Figure out if debug information should be generated if (const char* sed = sf->GetProperty("VS_SHADER_ENABLE_DEBUG")) { - shaderEnableDebug = cmSystemTools::IsOn(sed) ? "true" : "false"; + shaderEnableDebug = sed; toolHasSettings = true; } // Figure out if optimizations should be disabled if (const char* sdo = sf->GetProperty("VS_SHADER_DISABLE_OPTIMIZATIONS")) { - shaderDisableOptimizations = cmSystemTools::IsOn(sdo) ? "true" : "false"; + shaderDisableOptimizations = sdo; toolHasSettings = true; } if (const char* sofn = sf->GetProperty("VS_SHADER_OBJECT_FILE_NAME")) { @@ -1843,12 +1843,39 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) } } if (!shaderEnableDebug.empty()) { - this->WriteElemEscapeXML("EnableDebuggingInformation", shaderEnableDebug, - 3); + cmGeneratorExpression ge; + std::unique_ptr cge = + ge.Parse(shaderEnableDebug); + + for (size_t i = 0; i != this->Configurations.size(); ++i) { + const char* enableDebug = + cge->Evaluate(this->LocalGenerator, this->Configurations[i]); + if (strlen(enableDebug) > 0) { + Elem el(*this->BuildFileStream, 3); + el.StartElement("EnableDebuggingInformation"); + el.Attribute("Condition", "'$(Configuration)|$(Platform)'=='" + + this->Configurations[i] + "|" + this->Platform + "'"); + el.Content(cmSystemTools::IsOn(enableDebug) ? "true" : "false"); + } + } } if (!shaderDisableOptimizations.empty()) { - this->WriteElemEscapeXML("DisableOptimizations", - shaderDisableOptimizations, 3); + cmGeneratorExpression ge; + std::unique_ptr cge = + ge.Parse(shaderDisableOptimizations); + + for (size_t i = 0; i != this->Configurations.size(); ++i) { + const char* disableOptimizations = + cge->Evaluate(this->LocalGenerator, this->Configurations[i]); + if (strlen(disableOptimizations) > 0) { + Elem el(*this->BuildFileStream, 3); + el.StartElement("DisableOptimizations"); + el.Attribute("Condition", "'$(Configuration)|$(Platform)'=='" + + this->Configurations[i] + "|" + this->Platform + "'"); + el.Content(cmSystemTools::IsOn(disableOptimizations) ? "true" + : "false"); + } + } } if (!shaderObjectFileName.empty()) { this->WriteElemEscapeXML("ObjectFileOutput", shaderObjectFileName, 3); -- cgit v0.12