2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2006-08-17 22:48:54 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2006-08-17 22:48:54 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2006-08-17 22:48:54 +04:00
|
|
|
#include "cmInstallDirectoryGenerator.h"
|
|
|
|
|
2015-09-24 00:15:29 +03:00
|
|
|
#include "cmGeneratorExpression.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
2006-08-17 22:48:54 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmInstallDirectoryGenerator::cmInstallDirectoryGenerator(
|
|
|
|
std::vector<std::string> const& dirs, const char* dest,
|
|
|
|
const char* file_permissions, const char* dir_permissions,
|
|
|
|
std::vector<std::string> const& configurations, const char* component,
|
|
|
|
MessageLevel message, bool exclude_from_all, const char* literal_args,
|
|
|
|
bool optional)
|
|
|
|
: cmInstallGenerator(dest, configurations, component, message,
|
|
|
|
exclude_from_all)
|
2016-06-27 23:44:16 +03:00
|
|
|
, LocalGenerator(CM_NULLPTR)
|
2016-05-16 17:34:04 +03:00
|
|
|
, Directories(dirs)
|
|
|
|
, FilePermissions(file_permissions)
|
|
|
|
, DirPermissions(dir_permissions)
|
|
|
|
, LiteralArguments(literal_args)
|
|
|
|
, Optional(optional)
|
2006-08-17 22:48:54 +04:00
|
|
|
{
|
2015-09-24 00:15:29 +03:00
|
|
|
// We need per-config actions if destination have generator expressions.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmGeneratorExpression::Find(Destination) != std::string::npos) {
|
2015-09-24 00:15:29 +03:00
|
|
|
this->ActionsPerConfig = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-01-12 23:01:07 +03:00
|
|
|
|
|
|
|
// We need per-config actions if any directories have generator expressions.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = dirs.begin();
|
|
|
|
!this->ActionsPerConfig && i != dirs.end(); ++i) {
|
|
|
|
if (cmGeneratorExpression::Find(*i) != std::string::npos) {
|
2016-01-12 23:01:07 +03:00
|
|
|
this->ActionsPerConfig = true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-08-17 22:48:54 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmInstallDirectoryGenerator::~cmInstallDirectoryGenerator()
|
2006-08-17 22:48:54 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:15:29 +03:00
|
|
|
void cmInstallDirectoryGenerator::Compute(cmLocalGenerator* lg)
|
|
|
|
{
|
|
|
|
LocalGenerator = lg;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os,
|
|
|
|
Indent const& indent)
|
2015-09-24 00:15:29 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ActionsPerConfig) {
|
2015-09-24 00:15:29 +03:00
|
|
|
this->cmInstallGenerator::GenerateScriptActions(os, indent);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2016-01-12 23:01:07 +03:00
|
|
|
this->AddDirectoryInstallRule(os, "", indent, this->Directories);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-24 00:15:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmInstallDirectoryGenerator::GenerateScriptForConfig(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::ostream& os, const std::string& config, Indent const& indent)
|
2015-09-24 00:15:29 +03:00
|
|
|
{
|
2016-01-12 23:01:07 +03:00
|
|
|
std::vector<std::string> dirs;
|
|
|
|
cmGeneratorExpression ge;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = this->Directories.begin();
|
|
|
|
i != this->Directories.end(); ++i) {
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*i);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(
|
|
|
|
cge->Evaluate(this->LocalGenerator, config), dirs);
|
|
|
|
}
|
2016-01-12 23:01:07 +03:00
|
|
|
this->AddDirectoryInstallRule(os, config, indent, dirs);
|
2015-09-24 00:15:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmInstallDirectoryGenerator::AddDirectoryInstallRule(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::ostream& os, const std::string& config, Indent const& indent,
|
2016-01-12 23:01:07 +03:00
|
|
|
std::vector<std::string> const& dirs)
|
2006-08-17 22:48:54 +04:00
|
|
|
{
|
|
|
|
// Write code to install the directories.
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* no_rename = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddInstallRule(os, this->GetDestination(config),
|
|
|
|
cmInstallType_DIRECTORY, dirs, this->Optional,
|
2007-06-29 00:11:18 +04:00
|
|
|
this->FilePermissions.c_str(),
|
2016-05-16 17:34:04 +03:00
|
|
|
this->DirPermissions.c_str(), no_rename,
|
|
|
|
this->LiteralArguments.c_str(), indent);
|
2006-08-17 22:48:54 +04:00
|
|
|
}
|
2015-09-24 00:15:29 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmInstallDirectoryGenerator::GetDestination(
|
|
|
|
std::string const& config) const
|
2015-09-24 00:15:29 +03:00
|
|
|
{
|
|
|
|
cmGeneratorExpression ge;
|
2016-05-16 17:34:04 +03:00
|
|
|
return ge.Parse(this->Destination)->Evaluate(this->LocalGenerator, config);
|
2015-09-24 00:15:29 +03:00
|
|
|
}
|