瀏覽代碼

CSharp: Do not pass definitions with values

The Microsoft C# tooling does not accept definitions with values.
Filter them out.

Fixes: #19817
Sumit Bhardwaj 5 年之前
父節點
當前提交
effd4d0569
共有 2 個文件被更改,包括 8 次插入4 次删除
  1. 4 0
      Source/cmVisualStudio10TargetGenerator.cxx
  2. 4 4
      Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake

+ 4 - 0
Source/cmVisualStudio10TargetGenerator.cxx

@@ -6,6 +6,7 @@
 #include <set>
 #include <set>
 
 
 #include <cm/memory>
 #include <cm/memory>
+#include <cm/vector>
 
 
 #include "windows.h"
 #include "windows.h"
 
 
@@ -2801,6 +2802,9 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
     case csproj:
     case csproj:
       this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName,
       this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName,
                                                    "CSharp");
                                                    "CSharp");
+      cm::erase_if(targetDefines, [](std::string const& def) {
+        return def.find('=') != std::string::npos;
+      });
       break;
       break;
   }
   }
   clOptions.AddDefines(targetDefines);
   clOptions.AddDefines(targetDefines);

+ 4 - 4
Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake

@@ -27,15 +27,15 @@ foreach(line IN LISTS lines)
   elseif(inDebug AND
   elseif(inDebug AND
      (line MATCHES "^ *<DefineConstants>.*MY_FOO_DEFINE.*</DefineConstants> *$") AND
      (line MATCHES "^ *<DefineConstants>.*MY_FOO_DEFINE.*</DefineConstants> *$") AND
      (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_DEBUG.*</DefineConstants> *$") AND
      (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_DEBUG.*</DefineConstants> *$") AND
-     (line MATCHES "^ *<DefineConstants>.*MY_BAR_ASSIGNMENT=bar.*</DefineConstants> *$") AND
-     (NOT (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_RELEASE.*</DefineConstants> *$"))
+     (NOT (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_RELEASE.*</DefineConstants> *$")) AND
+     (NOT (line MATCHES "^ *<DefineConstants>.*MY_BAR_ASSIGNMENT=bar.*</DefineConstants> *$"))
     )
     )
     set(debugOK TRUE)
     set(debugOK TRUE)
   elseif(inRelease AND
   elseif(inRelease AND
      (line MATCHES "^ *<DefineConstants>.*MY_FOO_DEFINE.*</DefineConstants> *$") AND
      (line MATCHES "^ *<DefineConstants>.*MY_FOO_DEFINE.*</DefineConstants> *$") AND
      (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_RELEASE.*</DefineConstants> *$") AND
      (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_RELEASE.*</DefineConstants> *$") AND
-     (line MATCHES "^ *<DefineConstants>.*MY_BAR_ASSIGNMENT=bar.*</DefineConstants> *$") AND
-     (NOT (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_DEBUG.*</DefineConstants> *$"))
+     (NOT (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_DEBUG.*</DefineConstants> *$")) AND
+     (NOT (line MATCHES "^ *<DefineConstants>.*MY_BAR_ASSIGNMENT=bar.*</DefineConstants> *$"))
     )
     )
     set(releaseOK TRUE)
     set(releaseOK TRUE)
   endif()
   endif()