From 290ca8e2d0328d27f51ff5248c35e32e44fdd1eb Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 11 Feb 2015 11:48:02 -0500 Subject: [PATCH] cmInstallGenerator: Refactor computation of absolute install dest Replace the GetInstallDestination method, which looked up the Destination ivar, with a new ConvertToAbsoluteDestination method that takes the nominal destination as an argument. Update call sites accordingly. This will allow some clients to transform the install destination before calling the method. --- Source/cmInstallExportGenerator.cxx | 2 +- Source/cmInstallGenerator.cxx | 11 ++++++----- Source/cmInstallGenerator.h | 2 +- Source/cmInstallTargetGenerator.cxx | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 4480cc643..77af6c29c 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -199,7 +199,7 @@ void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os, { // Remove old per-configuration export files if the main changes. std::string installedDir = "$ENV{DESTDIR}"; - installedDir += this->GetInstallDestination(); + installedDir += this->ConvertToAbsoluteDestination(this->Destination); installedDir += "/"; std::string installedFile = installedDir; installedFile += this->FileName; diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index b261cbfd0..1d6467475 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -60,7 +60,7 @@ void cmInstallGenerator case cmInstallType_FILES: stype = "FILE"; break; } os << indent; - std::string dest = this->GetInstallDestination(); + std::string dest = this->ConvertToAbsoluteDestination(this->Destination); if (cmSystemTools::FileIsFullPath(dest.c_str())) { os << "list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES\n"; @@ -179,15 +179,16 @@ bool cmInstallGenerator::InstallsForConfig(const std::string& config) } //---------------------------------------------------------------------------- -std::string cmInstallGenerator::GetInstallDestination() const +std::string +cmInstallGenerator::ConvertToAbsoluteDestination(std::string const& dest) const { std::string result; - if(!this->Destination.empty() && - !cmSystemTools::FileIsFullPath(this->Destination.c_str())) + if(!dest.empty() && + !cmSystemTools::FileIsFullPath(dest.c_str())) { result = "${CMAKE_INSTALL_PREFIX}/"; } - result += this->Destination; + result += dest; return result; } diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index eeeca158b..1e87bda3b 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -52,7 +52,7 @@ public: /** Get the install destination as it should appear in the installation script. */ - std::string GetInstallDestination() const; + std::string ConvertToAbsoluteDestination(std::string const& dest) const; /** Test if this generator installs something for a given configuration. */ bool InstallsForConfig(const std::string& config); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 6d69f545c..a22b123fa 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -77,7 +77,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary); fromDirConfig += "/"; } - std::string toDir = this->GetInstallDestination(); + std::string toDir = + this->ConvertToAbsoluteDestination(this->Destination); toDir += "/"; // Compute the list of files to install for this target.