summaryrefslogtreecommitdiff
path: root/Source/cmOutputConverter.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-05-14 15:38:27 -0400
committerBrad King <brad.king@kitware.com>2021-05-17 10:04:01 -0400
commit8526756b61014f780348346ba5fdf0604a02d158 (patch)
tree875962cd6dd10ef90e65fc64cad8fdfef8dad5b5 /Source/cmOutputConverter.h
parent013ec595c8d6971c568cff4f8e457d90a6e8be88 (diff)
downloadcmake-8526756b61014f780348346ba5fdf0604a02d158.tar.gz
cmOutputConverter: Adopt relative path conversion helpers
Move them up from cmLocalGenerator and out of cmStateDirectory.
Diffstat (limited to 'Source/cmOutputConverter.h')
-rw-r--r--Source/cmOutputConverter.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h
index c67e74b9be..865df718b1 100644
--- a/Source/cmOutputConverter.h
+++ b/Source/cmOutputConverter.h
@@ -17,6 +17,21 @@ class cmOutputConverter
public:
cmOutputConverter(cmStateSnapshot const& snapshot);
+ /**
+ * Convert the given remote path to a relative path with respect to
+ * one of our common work directories. The path 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 MaybeRelativeToTopBinDir(std::string const& path) const;
+ std::string MaybeRelativeToCurBinDir(std::string const& path) const;
+
+ std::string const& GetRelativePathTopSource() const;
+ std::string const& GetRelativePathTopBinary() const;
+ void SetRelativePathTopSource(std::string const& top);
+ void SetRelativePathTopBinary(std::string const& top);
+
enum OutputFormat
{
SHELL,
@@ -115,4 +130,16 @@ private:
static std::string Shell_GetArgument(cm::string_view in, int flags);
bool LinkScriptShell;
+
+ // The top-most directories for relative path conversion. Both the
+ // source and destination location of a relative path conversion
+ // must be underneath one of these directories (both under source or
+ // both under binary) in order for the relative path to be evaluated
+ // safely by the build tools.
+ std::string RelativePathTopSource;
+ std::string RelativePathTopBinary;
+ void ComputeRelativePathTopSource();
+ void ComputeRelativePathTopBinary();
+ std::string MaybeRelativeTo(std::string const& local_path,
+ std::string const& remote_path) const;
};