Browse Source

Vs: factor out computation of <Link> tag for CSharp source files

Michael Stürmer 8 years ago
parent
commit
dcdab5cf23

+ 21 - 8
Source/cmVisualStudio10TargetGenerator.cxx

@@ -2056,14 +2056,10 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
     typedef std::map<std::string, std::string> CsPropMap;
     CsPropMap sourceFileTags;
     // set <Link> tag if necessary
-    if (!this->InSourceBuild) {
-      const std::string stripFromPath =
-        this->Makefile->GetCurrentSourceDirectory();
-      if (f.find(stripFromPath) != std::string::npos) {
-        std::string link = f.substr(stripFromPath.length() + 1);
-        this->ConvertToWindowsSlash(link);
-        sourceFileTags["Link"] = link;
-      }
+    std::string link;
+    this->GetCSharpSourceLink(source, link);
+    if (!link.empty()) {
+      sourceFileTags["Link"] = link;
     }
     this->GetCSharpSourceProperties(&sf, sourceFileTags);
     // write source file specific tags
@@ -4380,6 +4376,23 @@ void cmVisualStudio10TargetGenerator::WriteCSharpSourceProperties(
   }
 }
 
+void cmVisualStudio10TargetGenerator::GetCSharpSourceLink(
+  cmSourceFile const* sf, std::string& link)
+{
+  std::string f = sf->GetFullPath();
+  if (!this->InSourceBuild) {
+    const std::string stripFromPath =
+      this->Makefile->GetCurrentSourceDirectory();
+    if (f.find(stripFromPath) != std::string::npos) {
+      link = f.substr(stripFromPath.length() + 1);
+      if (const char* l = sf->GetProperty("VS_CSHARP_Link")) {
+        link = l;
+      }
+      this->ConvertToWindowsSlash(link);
+    }
+  }
+}
+
 std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath(
   const char* relativeFilePath) const
 {

+ 1 - 0
Source/cmVisualStudio10TargetGenerator.h

@@ -162,6 +162,7 @@ private:
                                  std::map<std::string, std::string>& tags);
   void WriteCSharpSourceProperties(
     const std::map<std::string, std::string>& tags);
+  void GetCSharpSourceLink(cmSourceFile const* sf, std::string& link);
 
 private:
   typedef cmVisualStudioGeneratorOptions Options;