diff options
author | Brad King <brad.king@kitware.com> | 2021-05-12 19:51:47 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-05-13 16:47:25 (GMT) |
commit | 15fa3200715869d5acb94a282feb301d2e10a0eb (patch) | |
tree | 9c5d6c18b03b2917cc54d7fa2cfa5b9c89d8e4b0 /Source/cmLocalVisualStudio7Generator.cxx | |
parent | 1879f1bcbc4e2fbd9eaca4eff351ab928c4a3268 (diff) | |
download | CMake-15fa3200715869d5acb94a282feb301d2e10a0eb.zip CMake-15fa3200715869d5acb94a282feb301d2e10a0eb.tar.gz CMake-15fa3200715869d5acb94a282feb301d2e10a0eb.tar.bz2 |
cmLocalGenerator: Factor out relative path conversion helpers
Most calls to `MaybeConvertToRelativePath` use one of our common work
directories (e.g. top of the build tree) as the local path. Add helpers
for each of the common cases to simplify and clarify call sites.
Diffstat (limited to 'Source/cmLocalVisualStudio7Generator.cxx')
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index cead87b..c50cc5d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -784,8 +784,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( cmProp target_mod_dir = target->GetProperty("Fortran_MODULE_DIRECTORY"); std::string modDir; if (target_mod_dir) { - modDir = this->MaybeConvertToRelativePath( - this->GetCurrentBinaryDirectory(), *target_mod_dir); + modDir = this->MaybeRelativeToCurBinDir(*target_mod_dir); } else { modDir = "."; } @@ -1254,11 +1253,9 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries( std::ostream& fout, ItemVector const& libs) { cmLocalVisualStudio7Generator* lg = this->LocalGenerator; - std::string currentBinDir = lg->GetCurrentBinaryDirectory(); for (auto const& lib : libs) { if (lib.IsPath) { - std::string rel = - lg->MaybeConvertToRelativePath(currentBinDir, lib.Value.Value); + std::string rel = lg->MaybeRelativeToCurBinDir(lib.Value.Value); fout << lg->ConvertToXMLOutputPath(rel) << " "; } else if (!lib.Target || lib.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { @@ -1274,7 +1271,6 @@ void cmLocalVisualStudio7GeneratorInternals::OutputObjects( // VS < 8 does not support per-config source locations so we // list object library content on the link line instead. cmLocalVisualStudio7Generator* lg = this->LocalGenerator; - std::string currentBinDir = lg->GetCurrentBinaryDirectory(); std::vector<cmSourceFile const*> objs; gt->GetExternalObjects(objs, configName); @@ -1283,7 +1279,7 @@ void cmLocalVisualStudio7GeneratorInternals::OutputObjects( for (cmSourceFile const* obj : objs) { if (!obj->GetObjectLibrary().empty()) { std::string const& objFile = obj->GetFullPath(); - std::string rel = lg->MaybeConvertToRelativePath(currentBinDir, objFile); + std::string rel = lg->MaybeRelativeToCurBinDir(objFile); fout << sep << lg->ConvertToXMLOutputPath(rel); sep = " "; } @@ -1294,7 +1290,6 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories( std::ostream& fout, std::vector<std::string> const& dirs) { const char* comma = ""; - std::string currentBinDir = this->GetCurrentBinaryDirectory(); for (std::string dir : dirs) { // Remove any trailing slash and skip empty paths. if (dir.back() == '/') { @@ -1306,7 +1301,7 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories( // Switch to a relative path specification if it is shorter. if (cmSystemTools::FileIsFullPath(dir)) { - std::string rel = this->MaybeConvertToRelativePath(currentBinDir, dir); + std::string rel = this->MaybeRelativeToCurBinDir(dir); if (rel.size() < dir.size()) { dir = rel; } |