From 4cb6a53bf524258c34440fc573ab6a9a4de0f0b2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 14 May 2021 13:09:56 -0400 Subject: cmListFileCache: Simplify relative path conversion in backtraces Printing paths to CMake input files does not need to use the generator-wide relative path conversion rules because we are not actually generating a relative path for the build system that needs to be consistent with anything else. Instead, simply print a relative path if it does not need to start in `../`, and otherwise an absolute path. --- Source/cmListFileCache.cxx | 5 ++--- Source/cmTarget.cxx | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 2b98f20..4f7c959 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -15,7 +15,6 @@ #include "cmMessageType.h" #include "cmMessenger.h" #include "cmState.h" -#include "cmStateDirectory.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -550,7 +549,7 @@ void cmListFileBacktrace::PrintTitle(std::ostream& out) const cmListFileContext lfc = this->TopEntry->Context; cmStateSnapshot bottom = this->GetBottom(); if (!bottom.GetState()->GetIsInTryCompile()) { - lfc.FilePath = bottom.GetDirectory().ConvertToRelPathIfContained( + lfc.FilePath = cmSystemTools::RelativeIfUnder( bottom.GetState()->GetSourceDirectory(), lfc.FilePath); } out << (lfc.Line ? " at " : " in ") << lfc; @@ -581,7 +580,7 @@ void cmListFileBacktrace::PrintCallStack(std::ostream& out) const } cmListFileContext lfc = cur->Context; if (!bottom.GetState()->GetIsInTryCompile()) { - lfc.FilePath = bottom.GetDirectory().ConvertToRelPathIfContained( + lfc.FilePath = cmSystemTools::RelativeIfUnder( bottom.GetState()->GetSourceDirectory(), lfc.FilePath); } out << " " << lfc << "\n"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f84d246..29e361c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -929,12 +929,10 @@ 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"; - cmStateDirectory cmDir = - this->impl->Makefile->GetStateSnapshot().GetDirectory(); for (auto const& cmd : this->impl->TLLCommands) { if (cmd.first == sig) { cmListFileContext lfc = cmd.second; - lfc.FilePath = cmDir.ConvertToRelPathIfContained( + lfc.FilePath = cmSystemTools::RelativeIfUnder( this->impl->Makefile->GetState()->GetSourceDirectory(), lfc.FilePath); s << " * " << lfc << '\n'; } -- cgit v0.12