From 09b6cc66b09b9689ca01faee5e33ef101b46f972 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 8 Oct 2016 12:21:38 +0200 Subject: cmLinkLineComputer: Move LinkPath computation from cmLocalGenerator Add a ConvertToOutputForExisting method which can be made virtual later to satisfy different generator needs. Pass additional strings as parameters for now. They can be turned into class state later. --- Source/cmLinkLineComputer.cxx | 28 ++++++++++++++++++++++++++++ Source/cmLinkLineComputer.h | 5 +++++ Source/cmLocalGenerator.cxx | 13 ++----------- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index b2b56bf..a5e8b72 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -72,3 +72,31 @@ std::string cmLinkLineComputer::ConvertToOutputFormat(std::string const& input) return this->OutputConverter->ConvertToOutputFormat(input, shellFormat); } + +std::string cmLinkLineComputer::ConvertToOutputForExisting( + std::string const& input) +{ + cmOutputConverter::OutputFormat shellFormat = (this->ForResponse) + ? cmOutputConverter::RESPONSE + : ((this->UseWatcomQuote) ? cmOutputConverter::WATCOMQUOTE + : cmOutputConverter::SHELL); + + return this->OutputConverter->ConvertToOutputForExisting(input, shellFormat); +} + +std::string cmLinkLineComputer::ComputeLinkPath( + cmComputeLinkInformation& cli, std::string const& libPathFlag, + std::string const& libPathTerminator) +{ + std::string linkPath; + std::vector const& libDirs = cli.GetDirectories(); + for (std::vector::const_iterator libDir = libDirs.begin(); + libDir != libDirs.end(); ++libDir) { + std::string libpath = this->ConvertToOutputForExisting(*libDir); + linkPath += " " + libPathFlag; + linkPath += libpath; + linkPath += libPathTerminator; + linkPath += " "; + } + return linkPath; +} diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h index 2317385..d38213f 100644 --- a/Source/cmLinkLineComputer.h +++ b/Source/cmLinkLineComputer.h @@ -23,8 +23,13 @@ public: std::string ComputeLinkLibs(cmComputeLinkInformation& cli); + std::string ComputeLinkPath(cmComputeLinkInformation& cli, + std::string const& libPathFlag, + std::string const& libPathTerminator); + private: std::string ConvertToOutputFormat(std::string const& input); + std::string ConvertToOutputForExisting(std::string const& input); cmState::Directory StateDir; cmOutputConverter* OutputConverter; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 0d2fe86..ab3d3b6 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1441,17 +1441,8 @@ void cmLocalGenerator::OutputLinkLibraries( } } - // Append the library search path flags. - std::vector const& libDirs = cli.GetDirectories(); - for (std::vector::const_iterator libDir = libDirs.begin(); - libDir != libDirs.end(); ++libDir) { - std::string libpath = - this->ConvertToOutputForExisting(*libDir, shellFormat); - linkPath += " " + libPathFlag; - linkPath += libpath; - linkPath += libPathTerminator; - linkPath += " "; - } + linkPath = + linkLineComputer->ComputeLinkPath(cli, libPathFlag, libPathTerminator); std::string linkLibs = linkLineComputer->ComputeLinkLibs(cli); -- cgit v0.12