Ver Fonte

cmOutputConverter: move ConvertToRelativePath to cmStateDirectory.

Bruno Manganelli há 7 anos atrás
pai
commit
b6a957c969

+ 1 - 1
Source/cmCommonTargetGenerator.cxx

@@ -198,7 +198,7 @@ std::string cmCommonTargetGenerator::GetManifests()
   manifests.reserve(manifest_srcs.size());
   for (cmSourceFile const* manifest_src : manifest_srcs) {
     manifests.push_back(this->LocalCommonGenerator->ConvertToOutputFormat(
-      this->LocalCommonGenerator->ConvertToRelativePath(
+      this->LocalCommonGenerator->MaybeConvertToRelativePath(
         this->LocalCommonGenerator->GetWorkingDirectory(),
         manifest_src->GetFullPath()),
       cmOutputConverter::SHELL));

+ 4 - 2
Source/cmDependsC.cxx

@@ -100,7 +100,8 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
   // Compute a path to the object file to write to the internal depend file.
   // Any existing content of the internal depend file has already been
   // loaded in ValidDeps with this path as a key.
-  std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj);
+  std::string obj_i =
+    this->LocalGenerator->MaybeConvertToRelativePath(binDir, obj);
 
   if (this->ValidDeps != nullptr) {
     std::map<std::string, DependencyVector>::const_iterator tmpIt =
@@ -234,7 +235,8 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
   for (std::string const& dep : dependencies) {
     makeDepends << obj_m << ": "
                 << cmSystemTools::ConvertToOutputPath(
-                     this->LocalGenerator->ConvertToRelativePath(binDir, dep))
+                     this->LocalGenerator->MaybeConvertToRelativePath(binDir,
+                                                                      dep))
                 << std::endl;
     internalDepends << " " << dep << std::endl;
   }

+ 1 - 1
Source/cmExtraEclipseCDT4Generator.cxx

@@ -899,7 +899,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
   for (cmLocalGenerator* lgen : this->GlobalGenerator->GetLocalGenerators()) {
     const std::vector<cmGeneratorTarget*>& targets =
       lgen->GetGeneratorTargets();
-    std::string subdir = lgen->ConvertToRelativePath(
+    std::string subdir = lgen->MaybeConvertToRelativePath(
       this->HomeOutputDirectory, lgen->GetCurrentBinaryDirectory());
     if (subdir == ".") {
       subdir.clear();

+ 3 - 2
Source/cmGhsMultiTargetGenerator.cxx

@@ -150,7 +150,8 @@ void cmGhsMultiTargetGenerator::WriteTargetSpecifics(std::ostream& fout,
   if (this->TagType != GhsMultiGpj::SUBPROJECT) {
     // set target binary file destination
     outpath = this->GeneratorTarget->GetDirectory(config);
-    outpath = this->LocalGenerator->ConvertToRelativePath(rootpath, outpath);
+    outpath =
+      this->LocalGenerator->MaybeConvertToRelativePath(rootpath, outpath);
     fout << "    :binDirRelative=\"" << outpath << "\"" << std::endl;
     fout << "    -o \"" << this->TargetNameReal << "\"" << std::endl;
   }
@@ -550,7 +551,7 @@ void cmGhsMultiTargetGenerator::WriteReferences(std::ostream& fout)
     std::string tpath = t->LocalGenerator->GetCurrentBinaryDirectory();
     std::string rootpath = this->LocalGenerator->GetCurrentBinaryDirectory();
     std::string outpath =
-      this->LocalGenerator->ConvertToRelativePath(rootpath, tpath) + "/" +
+      this->LocalGenerator->MaybeConvertToRelativePath(rootpath, tpath) + "/" +
       tname + "REF" + cmGlobalGhsMultiGenerator::FILE_EXTENSION;
 
     fout << outpath;

+ 3 - 3
Source/cmGlobalGenerator.cxx

@@ -33,7 +33,6 @@
 #include "cmMSVC60LinkLineComputer.h"
 #include "cmMakefile.h"
 #include "cmMessageType.h"
-#include "cmOutputConverter.h"
 #include "cmPolicies.h"
 #include "cmSourceFile.h"
 #include "cmState.h"
@@ -2804,8 +2803,9 @@ void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
   }
 
   // Shorten the output name (in expected use case).
-  cmOutputConverter converter(this->GetMakefiles()[0]->GetStateSnapshot());
-  std::string fname = converter.ConvertToRelativePath(
+  cmStateDirectory cmDir =
+    this->GetMakefiles()[0]->GetStateSnapshot().GetDirectory();
+  std::string fname = cmDir.ConvertToRelPathIfNotContained(
     this->GetMakefiles()[0]->GetState()->GetBinaryDirectory(), outputs[0]);
 
   // Associate the hash with this output.

+ 1 - 1
Source/cmGlobalGhsMultiGenerator.cxx

@@ -297,7 +297,7 @@ void cmGlobalGhsMultiGenerator::WriteSubProjects(
     if (projName && projType) {
       cmLocalGenerator* lg = target->GetLocalGenerator();
       std::string dir = lg->GetCurrentBinaryDirectory();
-      dir = root->ConvertToRelativePath(rootBinaryDir, dir.c_str());
+      dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir.c_str());
       if (dir == ".") {
         dir.clear();
       } else {

+ 1 - 1
Source/cmGlobalNinjaGenerator.cxx

@@ -861,7 +861,7 @@ std::string const& cmGlobalNinjaGenerator::ConvertToNinjaPath(
   cmLocalNinjaGenerator* ng =
     static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
   std::string const& bin_dir = ng->GetState()->GetBinaryDirectory();
-  std::string convPath = ng->ConvertToRelativePath(bin_dir, path);
+  std::string convPath = ng->MaybeConvertToRelativePath(bin_dir, path);
   convPath = this->NinjaOutputPath(convPath);
 #ifdef _WIN32
   std::replace(convPath.begin(), convPath.end(), '/', '\\');

+ 13 - 8
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -325,7 +325,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
     << "set(CMAKE_MAKEFILE_DEPENDS\n"
     << "  \"CMakeCache.txt\"\n";
   for (std::string const& f : lfiles) {
-    cmakefileStream << "  \"" << lg->ConvertToRelativePath(currentBinDir, f)
+    cmakefileStream << "  \""
+                    << lg->MaybeConvertToRelativePath(currentBinDir, f)
                     << "\"\n";
   }
   cmakefileStream << "  )\n\n";
@@ -339,9 +340,11 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
   cmakefileStream << "# The corresponding makefile is:\n"
                   << "set(CMAKE_MAKEFILE_OUTPUTS\n"
                   << "  \""
-                  << lg->ConvertToRelativePath(currentBinDir, makefileName)
+                  << lg->MaybeConvertToRelativePath(currentBinDir,
+                                                    makefileName)
                   << "\"\n"
-                  << "  \"" << lg->ConvertToRelativePath(currentBinDir, check)
+                  << "  \""
+                  << lg->MaybeConvertToRelativePath(currentBinDir, check)
                   << "\"\n";
   cmakefileStream << "  )\n\n";
 
@@ -354,7 +357,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
     const std::vector<std::string>& outfiles =
       lg->GetMakefile()->GetOutputFiles();
     for (std::string const& outfile : outfiles) {
-      cmakefileStream << "  \"" << lg->ConvertToRelativePath(binDir, outfile)
+      cmakefileStream << "  \""
+                      << lg->MaybeConvertToRelativePath(binDir, outfile)
                       << "\"\n";
     }
 
@@ -365,7 +369,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
       tmpStr = lg->GetCurrentBinaryDirectory();
       tmpStr += cmake::GetCMakeFilesDirectory();
       tmpStr += "/CMakeDirectoryInformation.cmake";
-      cmakefileStream << "  \"" << lg->ConvertToRelativePath(binDir, tmpStr)
+      cmakefileStream << "  \""
+                      << lg->MaybeConvertToRelativePath(binDir, tmpStr)
                       << "\"\n";
     }
     cmakefileStream << "  )\n\n";
@@ -474,7 +479,7 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2(
 
   // Begin the directory-level rules section.
   std::string dir =
-    cmSystemTools::ConvertToOutputPath(lg->ConvertToRelativePath(
+    cmSystemTools::ConvertToOutputPath(lg->MaybeConvertToRelativePath(
       lg->GetBinaryDirectory(), lg->GetCurrentBinaryDirectory()));
   lg->WriteDivider(ruleFileStream);
   ruleFileStream << "# Directory level rules for directory " << dir << "\n\n";
@@ -526,9 +531,9 @@ void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
     if (fast) {
       tname += "/fast";
     }
-    cmOutputConverter conv(mf->GetStateSnapshot());
     tname =
-      conv.ConvertToRelativePath(mf->GetState()->GetBinaryDirectory(), tname);
+      mf->GetStateSnapshot().GetDirectory().ConvertToRelPathIfNotContained(
+        mf->GetState()->GetBinaryDirectory(), tname);
     cmSystemTools::ConvertToOutputSlashes(tname);
     makeCommand.push_back(std::move(tname));
   }

+ 1 - 1
Source/cmGlobalVisualStudio7Generator.cxx

@@ -367,7 +367,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
       if (vcprojName) {
         cmLocalGenerator* lg = target->GetLocalGenerator();
         std::string dir = lg->GetCurrentBinaryDirectory();
-        dir = root->ConvertToRelativePath(rootBinaryDir, dir.c_str());
+        dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir.c_str());
         if (dir == ".") {
           dir.clear(); // msbuild cannot handle ".\" prefix
         }

+ 1 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -3570,7 +3570,7 @@ std::string cmGlobalXCodeGenerator::RelativeToSource(const char* p)
 
 std::string cmGlobalXCodeGenerator::RelativeToBinary(const char* p)
 {
-  return this->CurrentLocalGenerator->ConvertToRelativePath(
+  return this->CurrentLocalGenerator->MaybeConvertToRelativePath(
     cmSystemTools::JoinPath(this->ProjectOutputDirectoryComponents), p);
 }
 

+ 3 - 5
Source/cmListFileCache.cxx

@@ -5,8 +5,8 @@
 #include "cmListFileLexer.h"
 #include "cmMessageType.h"
 #include "cmMessenger.h"
-#include "cmOutputConverter.h"
 #include "cmState.h"
+#include "cmStateDirectory.h"
 #include "cmSystemTools.h"
 
 #include <assert.h>
@@ -390,9 +390,8 @@ void cmListFileBacktrace::PrintTitle(std::ostream& out) const
   }
   cmListFileContext lfc = this->TopEntry->Context;
   cmStateSnapshot bottom = this->GetBottom();
-  cmOutputConverter converter(bottom);
   if (!bottom.GetState()->GetIsInTryCompile()) {
-    lfc.FilePath = converter.ConvertToRelativePath(
+    lfc.FilePath = bottom.GetDirectory().ConvertToRelPathIfNotContained(
       bottom.GetState()->GetSourceDirectory(), lfc.FilePath);
   }
   out << (lfc.Line ? " at " : " in ") << lfc;
@@ -409,7 +408,6 @@ void cmListFileBacktrace::PrintCallStack(std::ostream& out) const
 
   bool first = true;
   cmStateSnapshot bottom = this->GetBottom();
-  cmOutputConverter converter(bottom);
   for (Entry const* cur = this->TopEntry->Parent.get(); !cur->IsBottom();
        cur = cur->Parent.get()) {
     if (cur->Context.Name.empty()) {
@@ -423,7 +421,7 @@ void cmListFileBacktrace::PrintCallStack(std::ostream& out) const
     }
     cmListFileContext lfc = cur->Context;
     if (!bottom.GetState()->GetIsInTryCompile()) {
-      lfc.FilePath = converter.ConvertToRelativePath(
+      lfc.FilePath = bottom.GetDirectory().ConvertToRelPathIfNotContained(
         bottom.GetState()->GetSourceDirectory(), lfc.FilePath);
     }
     out << "  " << lfc << "\n";

+ 1 - 1
Source/cmLocalCommonGenerator.cxx

@@ -47,7 +47,7 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags(
     target->GetFortranModuleDirectory(this->WorkingDirectory);
   if (!mod_dir.empty()) {
     mod_dir = this->ConvertToOutputFormat(
-      this->ConvertToRelativePath(this->WorkingDirectory, mod_dir),
+      this->MaybeConvertToRelativePath(this->WorkingDirectory, mod_dir),
       cmOutputConverter::SHELL);
   } else {
     mod_dir =

+ 13 - 6
Source/cmLocalGenerator.cxx

@@ -316,7 +316,7 @@ void cmLocalGenerator::GenerateTestFiles()
   for (cmStateSnapshot const& i : children) {
     // TODO: Use add_subdirectory instead?
     std::string outP = i.GetDirectory().GetCurrentBinary();
-    outP = this->ConvertToRelativePath(parentBinDir, outP);
+    outP = this->MaybeConvertToRelativePath(parentBinDir, outP);
     outP = cmOutputConverter::EscapeForCMake(outP);
     fout << "subdirs(" << outP << ")" << std::endl;
   }
@@ -2294,7 +2294,7 @@ std::string cmLocalGenerator::ConstructComment(
     std::string currentBinaryDir = this->GetCurrentBinaryDirectory();
     for (std::string const& o : ccg.GetOutputs()) {
       comment += sep;
-      comment += this->ConvertToRelativePath(currentBinaryDir, o);
+      comment += this->MaybeConvertToRelativePath(currentBinaryDir, o);
       sep = ", ";
     }
     return comment;
@@ -2551,15 +2551,15 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
   std::string const& fullPath = source.GetFullPath();
 
   // Try referencing the source relative to the source tree.
-  std::string relFromSource =
-    this->ConvertToRelativePath(this->GetCurrentSourceDirectory(), fullPath);
+  std::string relFromSource = this->MaybeConvertToRelativePath(
+    this->GetCurrentSourceDirectory(), fullPath);
   assert(!relFromSource.empty());
   bool relSource = !cmSystemTools::FileIsFullPath(relFromSource);
   bool subSource = relSource && relFromSource[0] != '.';
 
   // Try referencing the source relative to the binary tree.
-  std::string relFromBinary =
-    this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), fullPath);
+  std::string relFromBinary = this->MaybeConvertToRelativePath(
+    this->GetCurrentBinaryDirectory(), fullPath);
   assert(!relFromBinary.empty());
   bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary);
   bool subBinary = relBinary && relFromBinary[0] != '.';
@@ -2658,6 +2658,13 @@ std::string const& cmLocalGenerator::GetCurrentSourceDirectory() const
   return this->StateSnapshot.GetDirectory().GetCurrentSource();
 }
 
+std::string cmLocalGenerator::MaybeConvertToRelativePath(
+  std::string const& local_path, std::string const& remote_path) const
+{
+  return this->StateSnapshot.GetDirectory().ConvertToRelPathIfNotContained(
+    local_path, remote_path);
+}
+
 std::string cmLocalGenerator::GetTargetDirectory(
   const cmGeneratorTarget* /*unused*/) const
 {

+ 10 - 0
Source/cmLocalGenerator.h

@@ -301,6 +301,16 @@ public:
   std::string const& GetCurrentBinaryDirectory() const;
   std::string const& GetCurrentSourceDirectory() const;
 
+  /**
+   * Convert the given remote path to a relative path with respect to
+   * the given local path.  Both paths must use forward slashes and not
+   * already be escaped or quoted.
+   * The conversion is skipped if the paths are not both in the source
+   * or both in the binary tree.
+   */
+  std::string MaybeConvertToRelativePath(std::string const& local_path,
+                                         std::string const& remote_path) const;
+
   /**
    * Generate a macOS application bundle Info.plist file.
    */

+ 5 - 4
Source/cmLocalNinjaGenerator.cxx

@@ -54,7 +54,7 @@ void cmLocalNinjaGenerator::Generate()
 {
   // Compute the path to use when referencing the current output
   // directory from the top output directory.
-  this->HomeRelativeOutputPath = this->ConvertToRelativePath(
+  this->HomeRelativeOutputPath = this->MaybeConvertToRelativePath(
     this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory());
   if (this->HomeRelativeOutputPath == ".") {
     this->HomeRelativeOutputPath.clear();
@@ -141,7 +141,8 @@ std::string cmLocalNinjaGenerator::ConvertToIncludeReference(
                                        format);
   }
   return this->ConvertToOutputFormat(
-    this->ConvertToRelativePath(this->GetBinaryDirectory(), path), format);
+    this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), path),
+    format);
 }
 
 // Private methods.
@@ -584,8 +585,8 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
   if (!outputs.empty()) {
     output = outputs[0];
     if (ccg.GetWorkingDirectory().empty()) {
-      output =
-        this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), output);
+      output = this->MaybeConvertToRelativePath(
+        this->GetCurrentBinaryDirectory(), output);
     }
     output = this->ConvertToOutputFormat(output, cmOutputConverter::SHELL);
   }

+ 0 - 9
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -2088,12 +2088,3 @@ void cmLocalUnixMakefileGenerator3::CreateCDCommand(
                    [&prefix](std::string const& s) { return prefix + s; });
   }
 }
-
-std::string cmLocalUnixMakefileGenerator3::MaybeConvertToRelativePath(
-  std::string const& base, std::string const& path)
-{
-  if (!this->GetStateSnapshot().GetDirectory().ContainsBoth(base, path)) {
-    return path;
-  }
-  return cmSystemTools::ForceToRelativePath(base, path);
-}

+ 0 - 3
Source/cmLocalUnixMakefileGenerator3.h

@@ -183,9 +183,6 @@ public:
   // Eclipse generator.
   void GetIndividualFileTargets(std::vector<std::string>& targets);
 
-  std::string MaybeConvertToRelativePath(std::string const& base,
-                                         std::string const& path);
-
 protected:
   void WriteLocalMakefile();
 

+ 5 - 5
Source/cmLocalVisualStudio7Generator.cxx

@@ -803,8 +803,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
       target->GetProperty("Fortran_MODULE_DIRECTORY");
     std::string modDir;
     if (target_mod_dir) {
-      modDir = this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(),
-                                           target_mod_dir);
+      modDir = this->MaybeConvertToRelativePath(
+        this->GetCurrentBinaryDirectory(), target_mod_dir);
     } else {
       modDir = ".";
     }
@@ -1306,7 +1306,7 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries(
   for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
     if (l->IsPath) {
       std::string rel =
-        lg->ConvertToRelativePath(currentBinDir, l->Value.c_str());
+        lg->MaybeConvertToRelativePath(currentBinDir, l->Value.c_str());
       fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " ";
     } else if (!l->Target ||
                l->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
@@ -1332,7 +1332,7 @@ void cmLocalVisualStudio7GeneratorInternals::OutputObjects(
        i != objs.end(); ++i) {
     if (!(*i)->GetObjectLibrary().empty()) {
       std::string const& objFile = (*i)->GetFullPath();
-      std::string rel = lg->ConvertToRelativePath(currentBinDir, objFile);
+      std::string rel = lg->MaybeConvertToRelativePath(currentBinDir, objFile);
       fout << sep << lg->ConvertToXMLOutputPath(rel.c_str());
       sep = " ";
     }
@@ -1358,7 +1358,7 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(
     // Switch to a relative path specification if it is shorter.
     if (cmSystemTools::FileIsFullPath(dir.c_str())) {
       std::string rel =
-        this->ConvertToRelativePath(currentBinDir, dir.c_str());
+        this->MaybeConvertToRelativePath(currentBinDir, dir.c_str());
       if (rel.size() < dir.size()) {
         dir = rel;
       }

+ 4 - 3
Source/cmLocalVisualStudioGenerator.cxx

@@ -210,9 +210,10 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
     }
 
     if (workingDirectory.empty()) {
-      script += this->ConvertToOutputFormat(
-        this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), cmd),
-        cmOutputConverter::SHELL);
+      script +=
+        this->ConvertToOutputFormat(this->MaybeConvertToRelativePath(
+                                      this->GetCurrentBinaryDirectory(), cmd),
+                                    cmOutputConverter::SHELL);
     } else {
       script += this->ConvertToOutputFormat(cmd.c_str(), SHELL);
     }

+ 0 - 12
Source/cmOutputConverter.cxx

@@ -10,7 +10,6 @@
 #include <vector>
 
 #include "cmState.h"
-#include "cmStateDirectory.h"
 #include "cmSystemTools.h"
 
 cmOutputConverter::cmOutputConverter(cmStateSnapshot const& snapshot)
@@ -72,17 +71,6 @@ std::string cmOutputConverter::ConvertDirectorySeparatorsForShell(
   return result;
 }
 
-std::string cmOutputConverter::ConvertToRelativePath(
-  std::string const& local_path, std::string const& remote_path) const
-{
-  if (!this->StateSnapshot.GetDirectory().ContainsBoth(local_path,
-                                                       remote_path)) {
-    return remote_path;
-  }
-
-  return cmSystemTools::ForceToRelativePath(local_path, remote_path);
-}
-
 static bool cmOutputConverterIsShellOperator(const std::string& str)
 {
   static std::set<std::string> shellOperators;

+ 0 - 10
Source/cmOutputConverter.h

@@ -91,16 +91,6 @@ public:
   };
   static FortranFormat GetFortranFormat(const char* value);
 
-  /**
-   * Convert the given remote path to a relative path with respect to
-   * the given local path.  Both paths must use forward slashes and not
-   * already be escaped or quoted.
-   * The conversion is skipped if the paths are not both in the source
-   * or both in the binary tree.
-   */
-  std::string ConvertToRelativePath(std::string const& local_path,
-                                    std::string const& remote_path) const;
-
 private:
   cmState* GetState() const;
 

+ 9 - 0
Source/cmStateDirectory.cxx

@@ -155,6 +155,15 @@ bool cmStateDirectory::ContainsBoth(std::string const& local_path,
   return bothInBinary || bothInSource;
 }
 
+std::string cmStateDirectory::ConvertToRelPathIfNotContained(
+  std::string const& local_path, std::string const& remote_path) const
+{
+  if (!this->ContainsBoth(local_path, remote_path)) {
+    return remote_path;
+  }
+  return cmSystemTools::ForceToRelativePath(local_path, remote_path);
+}
+
 cmStateDirectory::cmStateDirectory(
   cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator iter,
   const cmStateSnapshot& snapshot)

+ 3 - 0
Source/cmStateDirectory.h

@@ -35,6 +35,9 @@ public:
   bool ContainsBoth(std::string const& local_path,
                     std::string const& remote_path) const;
 
+  std::string ConvertToRelPathIfNotContained(
+    std::string const& local_path, std::string const& remote_path) const;
+
   cmStringRange GetIncludeDirectoriesEntries() const;
   cmBacktraceRange GetIncludeDirectoriesEntryBacktraces() const;
   void AppendIncludeDirectoriesEntry(std::string const& vec,

+ 3 - 3
Source/cmTarget.cxx

@@ -19,7 +19,6 @@
 #include "cmMakefile.h"
 #include "cmMessageType.h"
 #include "cmMessenger.h"
-#include "cmOutputConverter.h"
 #include "cmProperty.h"
 #include "cmSourceFile.h"
 #include "cmSourceFileLocation.h"
@@ -747,11 +746,12 @@ void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const
   const char* sigString =
     (sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain");
   s << "The uses of the " << sigString << " signature are here:\n";
-  cmOutputConverter converter(this->GetMakefile()->GetStateSnapshot());
+  cmStateDirectory cmDir =
+    this->GetMakefile()->GetStateSnapshot().GetDirectory();
   for (auto const& cmd : this->TLLCommands) {
     if (cmd.first == sig) {
       cmListFileContext lfc = cmd.second;
-      lfc.FilePath = converter.ConvertToRelativePath(
+      lfc.FilePath = cmDir.ConvertToRelPathIfNotContained(
         this->Makefile->GetState()->GetSourceDirectory(), lfc.FilePath);
       s << " * " << lfc << std::endl;
     }

+ 4 - 4
Source/cmVisualStudio10TargetGenerator.cxx

@@ -3584,8 +3584,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions(
     this->LocalGenerator->GetCurrentBinaryDirectory();
   for (cmComputeLinkInformation::Item const& l : libs) {
     if (l.IsPath && cmVS10IsTargetsFile(l.Value)) {
-      std::string path =
-        this->LocalGenerator->ConvertToRelativePath(currentBinDir, l.Value);
+      std::string path = this->LocalGenerator->MaybeConvertToRelativePath(
+        currentBinDir, l.Value);
       ConvertToWindowsSlash(path);
       this->AddTargetsFileAndConfigPair(path, config);
     }
@@ -3668,8 +3668,8 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
     }
 
     if (l.IsPath) {
-      std::string path =
-        this->LocalGenerator->ConvertToRelativePath(currentBinDir, l.Value);
+      std::string path = this->LocalGenerator->MaybeConvertToRelativePath(
+        currentBinDir, l.Value);
       ConvertToWindowsSlash(path);
       if (cmVS10IsTargetsFile(l.Value)) {
         vsTargetVec.push_back(path);