summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-02-12 16:53:02 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-02-12 16:53:02 (GMT)
commitfc7e15691a870f8f5e199e615279c7eb4dba8f6f (patch)
treef52513ad5012c4375b046bcc3f5848ef1dc9017f /Source
parent8c59928f3ac2a3a4f9b647f2c60c134d54d2237f (diff)
parentf30022eb07b913598326d2e3b10ff2e706fbe873 (diff)
downloadCMake-fc7e15691a870f8f5e199e615279c7eb4dba8f6f.zip
CMake-fc7e15691a870f8f5e199e615279c7eb4dba8f6f.tar.gz
CMake-fc7e15691a870f8f5e199e615279c7eb4dba8f6f.tar.bz2
Merge topic 'install-DESTINATION-genex'
f30022eb install: Allow generator expressions in TARGETS DESTINATION (#14317) 7607c3d1 cmInstallGenerator: Pass destination explicitly to AddInstallRule ebd556ca cmInstallGenerator: Fix check for absolute install destinations 290ca8e2 cmInstallGenerator: Refactor computation of absolute install dest f99991db cmInstallGenerator: Move GetDestination to subclasses that need it
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExportInstallFileGenerator.cxx10
-rw-r--r--Source/cmInstallDirectoryGenerator.cxx4
-rw-r--r--Source/cmInstallExportGenerator.cxx8
-rw-r--r--Source/cmInstallExportGenerator.h3
-rw-r--r--Source/cmInstallFilesGenerator.cxx1
-rw-r--r--Source/cmInstallGenerator.cxx14
-rw-r--r--Source/cmInstallGenerator.h9
-rw-r--r--Source/cmInstallTargetGenerator.cxx17
-rw-r--r--Source/cmInstallTargetGenerator.h2
9 files changed, 45 insertions, 23 deletions
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index a0d9013..ba1dde2 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -73,8 +73,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
// to reference if they are relative to the install prefix.
std::string installPrefix =
this->IEGen->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
- const char* installDest = this->IEGen->GetDestination();
- if(cmSystemTools::FileIsFullPath(installDest))
+ std::string const& expDest = this->IEGen->GetDestination();
+ if(cmSystemTools::FileIsFullPath(expDest))
{
// The export file is being installed to an absolute path so the
// package is not relocatable. Use the configured install prefix.
@@ -87,7 +87,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
{
// Add code to compute the installation prefix relative to the
// import file location.
- std::string absDest = installPrefix + "/" + installDest;
+ std::string absDest = installPrefix + "/" + expDest;
std::string absDestS = absDest + "/";
os << "# Compute the installation prefix relative to this file.\n"
<< "get_filename_component(_IMPORT_PREFIX"
@@ -109,7 +109,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
"unset(_realOrig)\n"
"unset(_realCurr)\n";
}
- std::string dest = installDest;
+ std::string dest = expDest;
while(!dest.empty())
{
os <<
@@ -398,7 +398,7 @@ cmExportInstallFileGenerator
cmTarget* target = itgen->GetTarget();
// Construct the installed location of the target.
- std::string dest = itgen->GetDestination();
+ std::string dest = itgen->GetDestination(config);
std::string value;
if(!cmSystemTools::FileIsFullPath(dest.c_str()))
{
diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx
index 8c13bab..7593380 100644
--- a/Source/cmInstallDirectoryGenerator.cxx
+++ b/Source/cmInstallDirectoryGenerator.cxx
@@ -44,7 +44,9 @@ cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os,
{
// Write code to install the directories.
const char* no_rename = 0;
- this->AddInstallRule(os, cmInstallType_DIRECTORY,
+ this->AddInstallRule(os,
+ this->Destination,
+ cmInstallType_DIRECTORY,
this->Directories,
this->Optional,
this->FilePermissions.c_str(),
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index 4480cc6..38c80df 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -185,7 +185,8 @@ cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
files.push_back(i->second);
std::string config_test = this->CreateConfigTest(i->first);
os << indent << "if(" << config_test << ")\n";
- this->AddInstallRule(os, cmInstallType_FILES, files, false,
+ this->AddInstallRule(os, this->Destination,
+ cmInstallType_FILES, files, false,
this->FilePermissions.c_str(), 0, 0, 0,
indent.Next());
os << indent << "endif()\n";
@@ -199,7 +200,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;
@@ -224,6 +225,7 @@ void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os,
// Install the main export file.
std::vector<std::string> files;
files.push_back(this->MainImportFile);
- this->AddInstallRule(os, cmInstallType_FILES, files, false,
+ this->AddInstallRule(os, this->Destination,
+ cmInstallType_FILES, files, false,
this->FilePermissions.c_str(), 0, 0, 0, indent);
}
diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h
index eb8c28b..3e078f2 100644
--- a/Source/cmInstallExportGenerator.h
+++ b/Source/cmInstallExportGenerator.h
@@ -41,6 +41,9 @@ public:
const std::string& GetNamespace() const { return this->Namespace; }
+ std::string const& GetDestination() const
+ { return this->Destination; }
+
protected:
virtual void GenerateScript(std::ostream& os);
virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent);
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index 91b102a..28c27c2 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -57,6 +57,7 @@ void cmInstallFilesGenerator::AddFilesInstallRule(
// Write code to install the files.
const char* no_dir_permissions = 0;
this->AddInstallRule(os,
+ this->Destination,
(this->Programs
? cmInstallType_PROGRAMS
: cmInstallType_FILES),
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx
index b261cbf..2e1c5f0 100644
--- a/Source/cmInstallGenerator.cxx
+++ b/Source/cmInstallGenerator.cxx
@@ -37,6 +37,7 @@ cmInstallGenerator
void cmInstallGenerator
::AddInstallRule(
std::ostream& os,
+ std::string const& dest,
cmInstallType type,
std::vector<std::string> const& files,
bool optional /* = false */,
@@ -60,7 +61,6 @@ void cmInstallGenerator
case cmInstallType_FILES: stype = "FILE"; break;
}
os << indent;
- std::string dest = this->GetInstallDestination();
if (cmSystemTools::FileIsFullPath(dest.c_str()))
{
os << "list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES\n";
@@ -94,7 +94,8 @@ void cmInstallGenerator
<< "${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n";
os << indent << "endif()\n";
}
- os << "file(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype;
+ std::string absDest = this->ConvertToAbsoluteDestination(dest);
+ os << "file(INSTALL DESTINATION \"" << absDest << "\" TYPE " << stype;
if(optional)
{
os << " OPTIONAL";
@@ -179,15 +180,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 38aac91..c4191e4 100644
--- a/Source/cmInstallGenerator.h
+++ b/Source/cmInstallGenerator.h
@@ -40,7 +40,9 @@ public:
virtual ~cmInstallGenerator();
void AddInstallRule(
- std::ostream& os, cmInstallType type,
+ std::ostream& os,
+ std::string const& dest,
+ cmInstallType type,
std::vector<std::string> const& files,
bool optional = false,
const char* permissions_file = 0,
@@ -50,12 +52,9 @@ public:
Indent const& indent = Indent()
);
- const char* GetDestination() const
- { return this->Destination.c_str(); }
-
/** 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 6d69f54..b035bad 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -12,6 +12,7 @@
#include "cmInstallTargetGenerator.h"
#include "cmComputeLinkInformation.h"
+#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
@@ -77,7 +78,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->GetDestination(config));
toDir += "/";
// Compute the list of files to install for this target.
@@ -322,8 +324,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
const char* no_dir_permissions = 0;
const char* no_rename = 0;
bool optional = this->Optional || this->ImportLibrary;
- this->AddInstallRule(os, type, filesFrom,
- optional,
+ this->AddInstallRule(os, this->GetDestination(config),
+ type, filesFrom, optional,
this->FilePermissions.c_str(), no_dir_permissions,
no_rename, literal_args.c_str(),
indent);
@@ -335,6 +337,15 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
//----------------------------------------------------------------------------
std::string
+cmInstallTargetGenerator::GetDestination(std::string const& config) const
+{
+ cmGeneratorExpression ge;
+ return ge.Parse(this->Destination)
+ ->Evaluate(this->Target->GetMakefile(), config);
+}
+
+//----------------------------------------------------------------------------
+std::string
cmInstallTargetGenerator::GetInstallFilename(const std::string& config) const
{
NameType nameType = this->ImportLibrary? NameImplib : NameNormal;
diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h
index 7e5cc71..075c8a4 100644
--- a/Source/cmInstallTargetGenerator.h
+++ b/Source/cmInstallTargetGenerator.h
@@ -60,6 +60,8 @@ public:
cmTarget* GetTarget() const { return this->Target; }
bool IsImportLibrary() const { return this->ImportLibrary; }
+ std::string GetDestination(std::string const& config) const;
+
protected:
virtual void GenerateScript(std::ostream& os);
virtual void GenerateScriptForConfig(std::ostream& os,