summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-02-24 14:16:36 (GMT)
committerBrad King <brad.king@kitware.com>2014-02-24 14:16:36 (GMT)
commitb686154b6191e87541a355e1de863f3d92330467 (patch)
treedc90e1c49052cce776a4051e5c6e4c12fb35fd07 /Source
parent549b4d02d42206c9f311dd4aca441adb85954552 (diff)
parent6e89c8a5f1d5aa9bffa95be2b1add8d2c4e55026 (diff)
downloadCMake-b686154b6191e87541a355e1de863f3d92330467.zip
CMake-b686154b6191e87541a355e1de863f3d92330467.tar.gz
CMake-b686154b6191e87541a355e1de863f3d92330467.tar.bz2
Merge branch 'install-FILES-genex' into release
Diffstat (limited to 'Source')
-rw-r--r--Source/cmInstallCommand.cxx21
-rw-r--r--Source/cmInstallFilesCommand.cxx5
-rw-r--r--Source/cmInstallFilesGenerator.cxx55
-rw-r--r--Source/cmInstallFilesGenerator.h12
-rw-r--r--Source/cmInstallProgramsCommand.cxx5
5 files changed, 81 insertions, 17 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 6f2dd65..0878aae 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -32,10 +32,12 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target,
}
static cmInstallFilesGenerator* CreateInstallFilesGenerator(
+ cmMakefile* mf,
const std::vector<std::string>& absFiles,
const cmInstallCommandArguments& args, bool programs)
{
- return new cmInstallFilesGenerator(absFiles, args.GetDestination().c_str(),
+ return new cmInstallFilesGenerator(mf,
+ absFiles, args.GetDestination().c_str(),
programs, args.GetPermissions().c_str(),
args.GetConfigurations(), args.GetComponent().c_str(),
args.GetRename().c_str(), args.GetOptional());
@@ -668,7 +670,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
if (!privateHeaderArgs.GetDestination().empty())
{
privateHeaderGenerator =
- CreateInstallFilesGenerator(absFiles, privateHeaderArgs, false);
+ CreateInstallFilesGenerator(this->Makefile, absFiles,
+ privateHeaderArgs, false);
}
else
{
@@ -694,7 +697,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
if (!publicHeaderArgs.GetDestination().empty())
{
publicHeaderGenerator =
- CreateInstallFilesGenerator(absFiles, publicHeaderArgs, false);
+ CreateInstallFilesGenerator(this->Makefile, absFiles,
+ publicHeaderArgs, false);
}
else
{
@@ -719,8 +723,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// Create the files install generator.
if (!resourceArgs.GetDestination().empty())
{
- resourceGenerator = CreateInstallFilesGenerator(absFiles,
- resourceArgs, false);
+ resourceGenerator = CreateInstallFilesGenerator(
+ this->Makefile, absFiles, resourceArgs, false);
}
else
{
@@ -888,7 +892,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
// Create the files install generator.
this->Makefile->AddInstallGenerator(
- CreateInstallFilesGenerator(absFiles, ica, programs));
+ CreateInstallFilesGenerator(this->Makefile, absFiles, ica, programs));
//Tell the global generator about any installation component names specified.
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
@@ -1351,7 +1355,8 @@ bool cmInstallCommand::MakeFilesFullPath(const char* modeName,
++fileIt)
{
std::string file = (*fileIt);
- if(!cmSystemTools::FileIsFullPath(file.c_str()))
+ std::string::size_type gpos = cmGeneratorExpression::Find(file);
+ if(gpos != 0 && !cmSystemTools::FileIsFullPath(file.c_str()))
{
file = this->Makefile->GetCurrentDirectory();
file += "/";
@@ -1359,7 +1364,7 @@ bool cmInstallCommand::MakeFilesFullPath(const char* modeName,
}
// Make sure the file is not a directory.
- if(cmSystemTools::FileIsDirectory(file.c_str()))
+ if(gpos == file.npos && cmSystemTools::FileIsDirectory(file.c_str()))
{
cmOStringStream e;
e << modeName << " given directory \"" << (*fileIt) << "\" to install.";
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index cc62c4b..488d486 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -133,7 +133,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const
"CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
std::vector<std::string> no_configurations;
this->Makefile->AddInstallGenerator(
- new cmInstallFilesGenerator(this->Files,
+ new cmInstallFilesGenerator(this->Makefile, this->Files,
destination.c_str(), false,
no_permissions, no_configurations,
no_component.c_str(), no_rename));
@@ -148,7 +148,8 @@ void cmInstallFilesCommand::CreateInstallGenerator() const
*/
std::string cmInstallFilesCommand::FindInstallSource(const char* name) const
{
- if(cmSystemTools::FileIsFullPath(name))
+ if(cmSystemTools::FileIsFullPath(name) ||
+ cmGeneratorExpression::Find(name) == 0)
{
// This is a full path.
return name;
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index ec02bc7..ec15044 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -11,9 +11,13 @@
============================================================================*/
#include "cmInstallFilesGenerator.h"
+#include "cmGeneratorExpression.h"
+#include "cmSystemTools.h"
+
//----------------------------------------------------------------------------
cmInstallFilesGenerator
-::cmInstallFilesGenerator(std::vector<std::string> const& files,
+::cmInstallFilesGenerator(cmMakefile* mf,
+ std::vector<std::string> const& files,
const char* dest, bool programs,
const char* file_permissions,
std::vector<std::string> const& configurations,
@@ -21,10 +25,20 @@ cmInstallFilesGenerator
const char* rename,
bool optional):
cmInstallGenerator(dest, configurations, component),
+ Makefile(mf),
Files(files), Programs(programs),
FilePermissions(file_permissions),
Rename(rename), Optional(optional)
{
+ // We need per-config actions if any files have generator expressions.
+ for(std::vector<std::string>::const_iterator i = files.begin();
+ !this->ActionsPerConfig && i != files.end(); ++i)
+ {
+ if(cmGeneratorExpression::Find(*i) != std::string::npos)
+ {
+ this->ActionsPerConfig = true;
+ }
+ }
}
//----------------------------------------------------------------------------
@@ -34,8 +48,9 @@ cmInstallFilesGenerator
}
//----------------------------------------------------------------------------
-void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
- Indent const& indent)
+void cmInstallFilesGenerator::AddFilesInstallRule(
+ std::ostream& os, Indent const& indent,
+ std::vector<std::string> const& files)
{
// Write code to install the files.
const char* no_dir_permissions = 0;
@@ -43,8 +58,40 @@ void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
(this->Programs
? cmInstallType_PROGRAMS
: cmInstallType_FILES),
- this->Files,
+ files,
this->Optional,
this->FilePermissions.c_str(), no_dir_permissions,
this->Rename.c_str(), 0, indent);
}
+
+//----------------------------------------------------------------------------
+void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
+ Indent const& indent)
+{
+ if(this->ActionsPerConfig)
+ {
+ this->cmInstallGenerator::GenerateScriptActions(os, indent);
+ }
+ else
+ {
+ this->AddFilesInstallRule(os, indent, this->Files);
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmInstallFilesGenerator::GenerateScriptForConfig(std::ostream& os,
+ const char* config,
+ Indent const& indent)
+{
+ std::vector<std::string> files;
+ cmListFileBacktrace lfbt;
+ cmGeneratorExpression ge(lfbt);
+ for(std::vector<std::string>::const_iterator i = this->Files.begin();
+ i != this->Files.end(); ++i)
+ {
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*i);
+ cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile, config),
+ files);
+ }
+ this->AddFilesInstallRule(os, indent, files);
+}
diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h
index 871335c..9dea296 100644
--- a/Source/cmInstallFilesGenerator.h
+++ b/Source/cmInstallFilesGenerator.h
@@ -14,13 +14,16 @@
#include "cmInstallGenerator.h"
+class cmMakefile;
+
/** \class cmInstallFilesGenerator
* \brief Generate file installation rules.
*/
class cmInstallFilesGenerator: public cmInstallGenerator
{
public:
- cmInstallFilesGenerator(std::vector<std::string> const& files,
+ cmInstallFilesGenerator(cmMakefile* mf,
+ std::vector<std::string> const& files,
const char* dest, bool programs,
const char* file_permissions,
std::vector<std::string> const& configurations,
@@ -31,6 +34,13 @@ public:
protected:
virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
+ virtual void GenerateScriptForConfig(std::ostream& os,
+ const char* config,
+ Indent const& indent);
+ void AddFilesInstallRule(std::ostream& os, Indent const& indent,
+ std::vector<std::string> const& files);
+
+ cmMakefile* Makefile;
std::vector<std::string> Files;
bool Programs;
std::string FilePermissions;
diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx
index 3a0a322..54d903a 100644
--- a/Source/cmInstallProgramsCommand.cxx
+++ b/Source/cmInstallProgramsCommand.cxx
@@ -94,7 +94,7 @@ void cmInstallProgramsCommand::FinalPass()
"CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
std::vector<std::string> no_configurations;
this->Makefile->AddInstallGenerator(
- new cmInstallFilesGenerator(this->Files,
+ new cmInstallFilesGenerator(this->Makefile, this->Files,
destination.c_str(), true,
no_permissions, no_configurations,
no_component.c_str(), no_rename));
@@ -109,7 +109,8 @@ void cmInstallProgramsCommand::FinalPass()
std::string cmInstallProgramsCommand
::FindInstallSource(const char* name) const
{
- if(cmSystemTools::FileIsFullPath(name))
+ if(cmSystemTools::FileIsFullPath(name) ||
+ cmGeneratorExpression::Find(name) == 0)
{
// This is a full path.
return name;