From effd4d05694382598675913b957dda2e08aa7392 Mon Sep 17 00:00:00 2001 From: Sumit Bhardwaj Date: Sun, 19 Jan 2020 16:41:57 -0800 Subject: CSharp: Do not pass definitions with values The Microsoft C# tooling does not accept definitions with values. Filter them out. Fixes: #19817 --- Source/cmVisualStudio10TargetGenerator.cxx | 4 ++++ Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f707bb4..4478517 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -6,6 +6,7 @@ #include #include +#include #include "windows.h" @@ -2801,6 +2802,9 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( case csproj: this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName, "CSharp"); + cm::erase_if(targetDefines, [](std::string const& def) { + return def.find('=') != std::string::npos; + }); break; } clOptions.AddDefines(targetDefines); diff --git a/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake index 152bf9c..631abac 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake @@ -27,15 +27,15 @@ foreach(line IN LISTS lines) elseif(inDebug AND (line MATCHES "^ *.*MY_FOO_DEFINE.* *$") AND (line MATCHES "^ *.*DEFINE_ONLY_FOR_DEBUG.* *$") AND - (line MATCHES "^ *.*MY_BAR_ASSIGNMENT=bar.* *$") AND - (NOT (line MATCHES "^ *.*DEFINE_ONLY_FOR_RELEASE.* *$")) + (NOT (line MATCHES "^ *.*DEFINE_ONLY_FOR_RELEASE.* *$")) AND + (NOT (line MATCHES "^ *.*MY_BAR_ASSIGNMENT=bar.* *$")) ) set(debugOK TRUE) elseif(inRelease AND (line MATCHES "^ *.*MY_FOO_DEFINE.* *$") AND (line MATCHES "^ *.*DEFINE_ONLY_FOR_RELEASE.* *$") AND - (line MATCHES "^ *.*MY_BAR_ASSIGNMENT=bar.* *$") AND - (NOT (line MATCHES "^ *.*DEFINE_ONLY_FOR_DEBUG.* *$")) + (NOT (line MATCHES "^ *.*DEFINE_ONLY_FOR_DEBUG.* *$")) AND + (NOT (line MATCHES "^ *.*MY_BAR_ASSIGNMENT=bar.* *$")) ) set(releaseOK TRUE) endif() -- cgit v0.12