install: Allow generator expressions in FILES DESTINATION
This commit is contained in:
parent
c3b3284c93
commit
17aa6fd362
|
@ -192,6 +192,10 @@ The list of ``files...`` given to ``FILES`` or ``PROGRAMS`` may use
|
||||||
However, if any item begins in a generator expression it must evaluate
|
However, if any item begins in a generator expression it must evaluate
|
||||||
to a full path.
|
to a full path.
|
||||||
|
|
||||||
|
The install destination given to the files install ``DESTINATION`` may
|
||||||
|
use "generator expressions" with the syntax ``$<...>``. See the
|
||||||
|
:manual:`cmake-generator-expressions(7)` manual for available expressions.
|
||||||
|
|
||||||
Installing Directories
|
Installing Directories
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
install-files-dest-genex
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
* The :command:`install(FILES)` command ``DESTINATION`` option learned to
|
||||||
|
support :manual:`generator expressions <cmake-generator-expressions(7)>`.
|
|
@ -34,6 +34,12 @@ cmInstallFilesGenerator
|
||||||
Programs(programs),
|
Programs(programs),
|
||||||
Optional(optional)
|
Optional(optional)
|
||||||
{
|
{
|
||||||
|
// We need per-config actions if the destination has generator expressions.
|
||||||
|
if(cmGeneratorExpression::Find(Destination) != std::string::npos)
|
||||||
|
{
|
||||||
|
this->ActionsPerConfig = true;
|
||||||
|
}
|
||||||
|
|
||||||
// We need per-config actions if any files have generator expressions.
|
// We need per-config actions if any files have generator expressions.
|
||||||
for(std::vector<std::string>::const_iterator i = files.begin();
|
for(std::vector<std::string>::const_iterator i = files.begin();
|
||||||
!this->ActionsPerConfig && i != files.end(); ++i)
|
!this->ActionsPerConfig && i != files.end(); ++i)
|
||||||
|
@ -56,15 +62,26 @@ void cmInstallFilesGenerator::Compute(cmLocalGenerator* lg)
|
||||||
this->LocalGenerator = lg;
|
this->LocalGenerator = lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
std::string
|
||||||
|
cmInstallFilesGenerator::GetDestination(std::string const& config) const
|
||||||
|
{
|
||||||
|
cmGeneratorExpression ge;
|
||||||
|
return ge.Parse(this->Destination)
|
||||||
|
->Evaluate(this->LocalGenerator->GetMakefile(), config);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmInstallFilesGenerator::AddFilesInstallRule(
|
void cmInstallFilesGenerator::AddFilesInstallRule(
|
||||||
std::ostream& os, Indent const& indent,
|
std::ostream& os,
|
||||||
|
const std::string config,
|
||||||
|
Indent const& indent,
|
||||||
std::vector<std::string> const& files)
|
std::vector<std::string> const& files)
|
||||||
{
|
{
|
||||||
// Write code to install the files.
|
// Write code to install the files.
|
||||||
const char* no_dir_permissions = 0;
|
const char* no_dir_permissions = 0;
|
||||||
this->AddInstallRule(os,
|
this->AddInstallRule(os,
|
||||||
this->Destination,
|
this->GetDestination(config),
|
||||||
(this->Programs
|
(this->Programs
|
||||||
? cmInstallType_PROGRAMS
|
? cmInstallType_PROGRAMS
|
||||||
: cmInstallType_FILES),
|
: cmInstallType_FILES),
|
||||||
|
@ -84,7 +101,7 @@ void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->AddFilesInstallRule(os, indent, this->Files);
|
this->AddFilesInstallRule(os, "", indent, this->Files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,5 +119,5 @@ void cmInstallFilesGenerator::GenerateScriptForConfig(std::ostream& os,
|
||||||
cmSystemTools::ExpandListArgument(cge->Evaluate(
|
cmSystemTools::ExpandListArgument(cge->Evaluate(
|
||||||
this->LocalGenerator->GetMakefile(), config), files);
|
this->LocalGenerator->GetMakefile(), config), files);
|
||||||
}
|
}
|
||||||
this->AddFilesInstallRule(os, indent, files);
|
this->AddFilesInstallRule(os, config, indent, files);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,12 +32,16 @@ public:
|
||||||
|
|
||||||
void Compute(cmLocalGenerator* lg);
|
void Compute(cmLocalGenerator* lg);
|
||||||
|
|
||||||
|
std::string GetDestination(std::string const& config) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
|
virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
|
||||||
virtual void GenerateScriptForConfig(std::ostream& os,
|
virtual void GenerateScriptForConfig(std::ostream& os,
|
||||||
const std::string& config,
|
const std::string& config,
|
||||||
Indent const& indent);
|
Indent const& indent);
|
||||||
void AddFilesInstallRule(std::ostream& os, Indent const& indent,
|
void AddFilesInstallRule(std::ostream& os,
|
||||||
|
const std::string config,
|
||||||
|
Indent const& indent,
|
||||||
std::vector<std::string> const& files);
|
std::vector<std::string> const& files);
|
||||||
|
|
||||||
cmLocalGenerator* LocalGenerator;
|
cmLocalGenerator* LocalGenerator;
|
||||||
|
|
Loading…
Reference in New Issue