summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/CMakeLists.txt2
-rw-r--r--Source/cmFileCommand.cxx350
-rw-r--r--Source/cmInstallCommand.cxx179
-rw-r--r--Source/cmInstallCommand.h1
-rw-r--r--Source/cmInstallDirectoryGenerator.cxx59
-rw-r--r--Source/cmInstallDirectoryGenerator.h46
-rw-r--r--Source/cmInstallFilesGenerator.cxx7
-rw-r--r--Source/cmInstallFilesGenerator.h4
-rw-r--r--Source/cmInstallGenerator.cxx11
-rw-r--r--Source/cmInstallGenerator.h3
-rw-r--r--Source/cmInstallTargetGenerator.cxx7
-rw-r--r--Source/cmInstallTargetGenerator.h4
12 files changed, 571 insertions, 102 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 0535fa983f..876047f57a 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -122,6 +122,8 @@ SET(SRCS
cmInstallScriptGenerator.cxx
cmInstallTargetGenerator.h
cmInstallTargetGenerator.cxx
+ cmInstallDirectoryGenerator.h
+ cmInstallDirectoryGenerator.cxx
cmListFileCache.cxx
cmListFileCache.h
cmListFileLexer.c
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 80c69e6fc0..9f2573ed37 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -316,6 +316,121 @@ bool cmFileCommand::HandleMakeDirectoryCommand(
}
//----------------------------------------------------------------------------
+struct cmFileInstaller
+{
+ bool InstallFile(const char* fromFile, const char* toFile, bool always);
+ bool InstallDirectory(const char* source,
+ const char* destination,
+ bool always,
+ std::string& smanifest_files,
+ int destDirLength);
+ cmFileInstaller(cmFileCommand* fc, cmMakefile* mf):
+ FileCommand(fc), Makefile(mf) {}
+ cmFileCommand* FileCommand;
+ cmMakefile* Makefile;
+ mode_t FilePermissions;
+ mode_t DirPermissions;
+};
+
+//----------------------------------------------------------------------------
+bool cmFileInstaller::InstallFile(const char* fromFile, const char* toFile,
+ bool always)
+{
+ // Inform the user about this file installation.
+ std::string message = "Installing ";
+ message += toFile;
+ this->Makefile->DisplayStatus(message.c_str(), -1);
+
+ // Copy the file.
+ if(!cmSystemTools::CopyAFile(fromFile, toFile, always))
+ {
+ cmOStringStream e;
+ e << "INSTALL cannot copy file \"" << fromFile
+ << "\" to \"" << toFile << "\".";
+ this->FileCommand->SetError(e.str().c_str());
+ return false;
+ }
+
+ // Set permissions of the destination file.
+ if(!cmSystemTools::SetPermissions(toFile, this->FilePermissions))
+ {
+ cmOStringStream e;
+ e << "Problem setting permissions on file \"" << toFile << "\"";
+ this->FileCommand->SetError(e.str().c_str());
+ return false;
+ }
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmFileInstaller::InstallDirectory(const char* source,
+ const char* destination,
+ bool always,
+ std::string& smanifest_files,
+ int destDirLength)
+{
+ cmsys::Directory dir;
+ dir.Load(source);
+ if(!cmSystemTools::MakeDirectory(destination))
+ {
+ return false;
+ }
+ // TODO: Make sure destination directory has write permissions
+ // before installing files. User requested permissions may be
+ // restored later.
+ unsigned long numFiles = static_cast<unsigned long>(dir.GetNumberOfFiles());
+ for(unsigned long fileNum = 0; fileNum < numFiles; ++fileNum)
+ {
+ if(!(strcmp(dir.GetFile(fileNum), ".") == 0 ||
+ strcmp(dir.GetFile(fileNum), "..") == 0))
+ {
+ kwsys_stl::string fromPath = source;
+ fromPath += "/";
+ fromPath += dir.GetFile(fileNum);
+ if(cmSystemTools::FileIsDirectory(fromPath.c_str()))
+ {
+ kwsys_stl::string toDir = destination;
+ toDir += "/";
+ toDir += dir.GetFile(fileNum);
+ if(!this->InstallDirectory(fromPath.c_str(), toDir.c_str(), always,
+ smanifest_files, destDirLength))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ // Install this file.
+ std::string toFile = destination;
+ toFile += "/";
+ toFile += dir.GetFile(fileNum);
+ if(this->InstallFile(fromPath.c_str(), toFile.c_str(), always))
+ {
+ smanifest_files += ";";
+ smanifest_files += toFile.substr(destDirLength);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+ }
+
+ // Set the requested permissions on the destination directory.
+ if(!cmSystemTools::SetPermissions(destination, this->DirPermissions))
+ {
+ cmOStringStream e;
+ e << "Problem setting permissions on directory \"" << destination << "\"";
+ this->FileCommand->SetError(e.str().c_str());
+ return false;
+ }
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
bool cmFileCommand::HandleInstallCommand(
std::vector<std::string> const& args)
{
@@ -369,11 +484,14 @@ bool cmFileCommand::HandleInstallCommand(
bool in_files = false;
bool in_properties = false;
- bool in_permissions = false;
+ bool in_permissions_file = false;
+ bool in_permissions_dir = false;
bool in_components = false;
bool in_configurations = false;
- bool use_given_permissions = false;
- mode_t permissions = 0;
+ bool use_given_permissions_file = false;
+ bool use_given_permissions_dir = false;
+ mode_t permissions_file = 0;
+ mode_t permissions_dir = 0;
bool optional = false;
for ( ; i != args.size(); ++i )
{
@@ -384,7 +502,8 @@ bool cmFileCommand::HandleInstallCommand(
destination = args[i];
in_files = false;
in_properties = false;
- in_permissions = false;
+ in_permissions_file = false;
+ in_permissions_dir = false;
in_components = false;
in_configurations = false;
}
@@ -399,7 +518,8 @@ bool cmFileCommand::HandleInstallCommand(
}
in_properties = false;
in_files = false;
- in_permissions = false;
+ in_permissions_file = false;
+ in_permissions_dir = false;
in_components = false;
in_configurations = false;
}
@@ -409,7 +529,8 @@ bool cmFileCommand::HandleInstallCommand(
rename = args[i];
in_properties = false;
in_files = false;
- in_permissions = false;
+ in_permissions_file = false;
+ in_permissions_dir = false;
in_components = false;
in_configurations = false;
}
@@ -417,16 +538,28 @@ bool cmFileCommand::HandleInstallCommand(
{
in_properties = true;
in_files = false;
- in_permissions = false;
+ in_permissions_file = false;
+ in_permissions_dir = false;
in_components = false;
in_configurations = false;
}
- else if ( *cstr == "PERMISSIONS" )
+ else if ( *cstr == "PERMISSIONS" )
{
- use_given_permissions = true;
+ use_given_permissions_file = true;
in_properties = false;
in_files = false;
- in_permissions = true;
+ in_permissions_file = true;
+ in_permissions_dir = false;
+ in_components = false;
+ in_configurations = false;
+ }
+ else if ( *cstr == "DIR_PERMISSIONS" )
+ {
+ use_given_permissions_dir = true;
+ in_properties = false;
+ in_files = false;
+ in_permissions_file = false;
+ in_permissions_dir = true;
in_components = false;
in_configurations = false;
}
@@ -434,7 +567,8 @@ bool cmFileCommand::HandleInstallCommand(
{
in_properties = false;
in_files = false;
- in_permissions = false;
+ in_permissions_file = false;
+ in_permissions_dir = false;
in_components = true;
in_configurations = false;
}
@@ -442,7 +576,8 @@ bool cmFileCommand::HandleInstallCommand(
{
in_properties = false;
in_files = false;
- in_permissions = false;
+ in_permissions_file = false;
+ in_permissions_dir = false;
in_components = false;
in_configurations = true;
}
@@ -450,7 +585,8 @@ bool cmFileCommand::HandleInstallCommand(
{
in_files = true;
in_properties = false;
- in_permissions = false;
+ in_permissions_file = false;
+ in_permissions_dir = false;
in_components = false;
in_configurations = false;
}
@@ -471,49 +607,93 @@ bool cmFileCommand::HandleInstallCommand(
{
configurations.insert(cmSystemTools::UpperCase(*cstr));
}
- else if(in_permissions && args[i] == "OWNER_READ")
+ else if(in_permissions_file && args[i] == "OWNER_READ")
+ {
+ permissions_file |= mode_owner_read;
+ }
+ else if(in_permissions_file && args[i] == "OWNER_WRITE")
+ {
+ permissions_file |= mode_owner_write;
+ }
+ else if(in_permissions_file && args[i] == "OWNER_EXECUTE")
+ {
+ permissions_file |= mode_owner_execute;
+ }
+ else if(in_permissions_file && args[i] == "GROUP_READ")
+ {
+ permissions_file |= mode_group_read;
+ }
+ else if(in_permissions_file && args[i] == "GROUP_WRITE")
+ {
+ permissions_file |= mode_group_write;
+ }
+ else if(in_permissions_file && args[i] == "GROUP_EXECUTE")
+ {
+ permissions_file |= mode_group_execute;
+ }
+ else if(in_permissions_file && args[i] == "WORLD_READ")
+ {
+ permissions_file |= mode_world_read;
+ }
+ else if(in_permissions_file && args[i] == "WORLD_WRITE")
+ {
+ permissions_file |= mode_world_write;
+ }
+ else if(in_permissions_file && args[i] == "WORLD_EXECUTE")
+ {
+ permissions_file |= mode_world_execute;
+ }
+ else if(in_permissions_file && args[i] == "SETUID")
+ {
+ permissions_file |= mode_setuid;
+ }
+ else if(in_permissions_file && args[i] == "SETGID")
{
- permissions |= mode_owner_read;
+ permissions_file |= mode_setgid;
}
- else if(in_permissions && args[i] == "OWNER_WRITE")
+ else if(in_permissions_dir && args[i] == "OWNER_READ")
{
- permissions |= mode_owner_write;
+ permissions_dir |= mode_owner_read;
}
- else if(in_permissions && args[i] == "OWNER_EXECUTE")
+ else if(in_permissions_dir && args[i] == "OWNER_WRITE")
{
- permissions |= mode_owner_execute;
+ permissions_dir |= mode_owner_write;
}
- else if(in_permissions && args[i] == "GROUP_READ")
+ else if(in_permissions_dir && args[i] == "OWNER_EXECUTE")
{
- permissions |= mode_group_read;
+ permissions_dir |= mode_owner_execute;
}
- else if(in_permissions && args[i] == "GROUP_WRITE")
+ else if(in_permissions_dir && args[i] == "GROUP_READ")
{
- permissions |= mode_group_write;
+ permissions_dir |= mode_group_read;
}
- else if(in_permissions && args[i] == "GROUP_EXECUTE")
+ else if(in_permissions_dir && args[i] == "GROUP_WRITE")
{
- permissions |= mode_group_execute;
+ permissions_dir |= mode_group_write;
}
- else if(in_permissions && args[i] == "WORLD_READ")
+ else if(in_permissions_dir && args[i] == "GROUP_EXECUTE")
{
- permissions |= mode_world_read;
+ permissions_dir |= mode_group_execute;
}
- else if(in_permissions && args[i] == "WORLD_WRITE")
+ else if(in_permissions_dir && args[i] == "WORLD_READ")
{
- permissions |= mode_world_write;
+ permissions_dir |= mode_world_read;
}
- else if(in_permissions && args[i] == "WORLD_EXECUTE")
+ else if(in_permissions_dir && args[i] == "WORLD_WRITE")
{
- permissions |= mode_world_execute;
+ permissions_dir |= mode_world_write;
}
- else if(in_permissions && args[i] == "SETUID")
+ else if(in_permissions_dir && args[i] == "WORLD_EXECUTE")
{
- permissions |= mode_setuid;
+ permissions_dir |= mode_world_execute;
}
- else if(in_permissions && args[i] == "SETGID")
+ else if(in_permissions_dir && args[i] == "SETUID")
{
- permissions |= mode_setgid;
+ permissions_dir |= mode_setuid;
+ }
+ else if(in_permissions_dir && args[i] == "SETGID")
+ {
+ permissions_dir |= mode_setgid;
}
else
{
@@ -683,9 +863,9 @@ bool cmFileCommand::HandleInstallCommand(
}
}
- // If permissions were not specified set default permissions for
- // this target type.
- if(!use_given_permissions)
+ // If file permissions were not specified set default permissions
+ // for this target type.
+ if(!use_given_permissions_file)
{
switch(itype)
{
@@ -693,36 +873,55 @@ bool cmFileCommand::HandleInstallCommand(
case cmTarget::MODULE_LIBRARY:
#if defined(__linux__)
// Use read/write permissions.
- permissions = 0;
- permissions |= mode_owner_read;
- permissions |= mode_owner_write;
- permissions |= mode_group_read;
- permissions |= mode_world_read;
+ permissions_file = 0;
+ permissions_file |= mode_owner_read;
+ permissions_file |= mode_owner_write;
+ permissions_file |= mode_group_read;
+ permissions_file |= mode_world_read;
break;
#endif
case cmTarget::EXECUTABLE:
case cmTarget::INSTALL_PROGRAMS:
// Use read/write/executable permissions.
- permissions = 0;
- permissions |= mode_owner_read;
- permissions |= mode_owner_write;
- permissions |= mode_owner_execute;
- permissions |= mode_group_read;
- permissions |= mode_group_execute;
- permissions |= mode_world_read;
- permissions |= mode_world_execute;
+ permissions_file = 0;
+ permissions_file |= mode_owner_read;
+ permissions_file |= mode_owner_write;
+ permissions_file |= mode_owner_execute;
+ permissions_file |= mode_group_read;
+ permissions_file |= mode_group_execute;
+ permissions_file |= mode_world_read;
+ permissions_file |= mode_world_execute;
break;
default:
// Use read/write permissions.
- permissions = 0;
- permissions |= mode_owner_read;
- permissions |= mode_owner_write;
- permissions |= mode_group_read;
- permissions |= mode_world_read;
+ permissions_file = 0;
+ permissions_file |= mode_owner_read;
+ permissions_file |= mode_owner_write;
+ permissions_file |= mode_group_read;
+ permissions_file |= mode_world_read;
break;
}
}
+ // If directory permissions were not specified set default permissions.
+ if(!use_given_permissions_dir)
+ {
+ // Use read/write/executable permissions.
+ permissions_dir = 0;
+ permissions_dir |= mode_owner_read;
+ permissions_dir |= mode_owner_write;
+ permissions_dir |= mode_owner_execute;
+ permissions_dir |= mode_group_read;
+ permissions_dir |= mode_group_execute;
+ permissions_dir |= mode_world_read;
+ permissions_dir |= mode_world_execute;
+ }
+
+ // Construct a file installer object.
+ cmFileInstaller installer(this, this->Makefile);
+ installer.FilePermissions = permissions_file;
+ installer.DirPermissions = permissions_dir;
+
// Get the current manifest.
const char* manifest_files =
this->Makefile->GetDefinition("CMAKE_INSTALL_MANIFEST_FILES");
@@ -870,35 +1069,20 @@ bool cmFileCommand::HandleInstallCommand(
if(itype == cmTarget::INSTALL_DIRECTORY &&
cmSystemTools::FileIsDirectory(fromFile.c_str()))
{
- // We will install this file. Display the information.
- message = "Installing ";
- message += toFile.c_str();
- this->Makefile->DisplayStatus(message.c_str(), -1);
- if(!cmSystemTools::CopyADirectory(fromFile.c_str(), toFile.c_str(),
- copy_always))
+ // Try installing this directory.
+ if(!installer.InstallDirectory(fromFile.c_str(), toFile.c_str(),
+ copy_always, smanifest_files,
+ destDirLength))
{
- cmOStringStream e;
- e << "INSTALL cannot copy directory \"" << fromFile
- << "\" to \"" << toFile + "\".";
- this->SetError(e.str().c_str());
return false;
}
}
else if(cmSystemTools::FileExists(fromFile.c_str()))
{
- // We will install this file. Display the information.
- message = "Installing ";
- message += toFile.c_str();
- this->Makefile->DisplayStatus(message.c_str(), -1);
-
- // Copy the file.
- if(!cmSystemTools::CopyAFile(fromFile.c_str(), toFile.c_str(),
- copy_always))
+ // Install this file.
+ if(!installer.InstallFile(fromFile.c_str(), toFile.c_str(),
+ copy_always))
{
- cmOStringStream e;
- e << "INSTALL cannot copy file \"" << fromFile
- << "\" to \"" << toFile + "\".";
- this->SetError(e.str().c_str());
return false;
}
@@ -920,16 +1104,6 @@ bool cmFileCommand::HandleInstallCommand(
}
#endif
- // Set permissions of the destination file.
- if(!cmSystemTools::SetPermissions(toFile.c_str(), permissions))
- {
- cmOStringStream e;
- e << "Problem setting permissions on file \""
- << toFile.c_str() << "\"";
- this->SetError(e.str().c_str());
- return false;
- }
-
// Add the file to the manifest.
smanifest_files += ";";
smanifest_files += toFile.substr(destDirLength);
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 057f3e0d50..833beae522 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -16,6 +16,7 @@
=========================================================================*/
#include "cmInstallCommand.h"
+#include "cmInstallDirectoryGenerator.h"
#include "cmInstallFilesGenerator.h"
#include "cmInstallScriptGenerator.h"
#include "cmInstallTargetGenerator.h"
@@ -51,6 +52,10 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args)
{
return this->HandleFilesMode(args);
}
+ else if(args[0] == "DIRECTORY")
+ {
+ return this->HandleDirectoryMode(args);
+ }
// Unknown mode.
cmStdString e = "called with unknown mode ";
@@ -676,6 +681,180 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
}
//----------------------------------------------------------------------------
+bool
+cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
+{
+ bool doing_dirs = true;
+ bool doing_destination = false;
+ bool doing_permissions_file = false;
+ bool doing_permissions_dir = false;
+ bool doing_configurations = false;
+ bool doing_component = false;
+ std::vector<std::string> dirs;
+ const char* destination = 0;
+ std::string permissions_file;
+ std::string permissions_dir;
+ std::vector<std::string> configurations;
+ std::string component;
+ for(unsigned int i=1; i < args.size(); ++i)
+ {
+ if(args[i] == "DESTINATION")
+ {
+ // Switch to setting the destination property.
+ doing_dirs = false;
+ doing_destination = true;
+ doing_permissions_file = false;
+ doing_permissions_dir = false;
+ doing_configurations = false;
+ doing_component = false;
+ }
+ else if(args[i] == "FILE_PERMISSIONS")
+ {
+ // Switch to setting the file permissions property.
+ doing_dirs = false;
+ doing_destination = false;
+ doing_permissions_file = true;
+ doing_permissions_dir = false;
+ doing_configurations = false;
+ doing_component = false;
+ }
+ else if(args[i] == "DIRECTORY_PERMISSIONS")
+ {
+ // Switch to setting the directory permissions property.
+ doing_dirs = false;
+ doing_destination = false;
+ doing_permissions_file = false;
+ doing_permissions_dir = true;
+ doing_configurations = false;
+ doing_component = false;
+ }
+ else if(args[i] == "CONFIGURATIONS")
+ {
+ // Switch to setting the configurations property.
+ doing_dirs = false;
+ doing_destination = false;
+ doing_permissions_file = false;
+ doing_permissions_dir = false;
+ doing_configurations = true;
+ doing_component = false;
+ }
+ else if(args[i] == "COMPONENT")
+ {
+ // Switch to setting the component property.
+ doing_dirs = false;
+ doing_destination = false;
+ doing_permissions_file = false;
+ doing_permissions_dir = false;
+ doing_configurations = false;
+ doing_component = true;
+ }
+ else if(doing_dirs)
+ {
+ // Convert this directory to a full path.
+ std::string dir = args[i];
+ if(!cmSystemTools::FileIsFullPath(dir.c_str()))
+ {
+ dir = this->Makefile->GetCurrentDirectory();
+ dir += "/";
+ dir += args[i];
+ }
+
+ // Make sure the name is a directory.
+ if(!cmSystemTools::FileIsDirectory(dir.c_str()))
+ {
+ cmOStringStream e;
+ e << args[0] << " given non-directory \""
+ << args[i] << "\" to install.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
+ // Store the directory for installation.
+ dirs.push_back(dir);
+ }
+ else if(doing_configurations)
+ {
+ configurations.push_back(args[i]);
+ }
+ else if(doing_destination)
+ {
+ destination = args[i].c_str();
+ doing_destination = false;
+ }
+ else if(doing_component)
+ {
+ component = args[i];
+ doing_component = false;
+ }
+ else if(doing_permissions_file)
+ {
+ // Check the requested permission.
+ if(!this->CheckPermissions(args[i], permissions_file))
+ {
+ cmOStringStream e;
+ e << args[0] << " given invalid file permission \""
+ << args[i] << "\".";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ }
+ else if(doing_permissions_dir)
+ {
+ // Check the requested permission.
+ if(!this->CheckPermissions(args[i], permissions_dir))
+ {
+ cmOStringStream e;
+ e << args[0] << " given invalid directory permission \""
+ << args[i] << "\".";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ }
+ else
+ {
+ // Unknown argument.
+ cmOStringStream e;
+ e << args[0] << " given unknown argument \"" << args[i] << "\".";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ }
+
+ // Check if there is something to do.
+ if(dirs.empty())
+ {
+ return true;
+ }
+ if(!destination)
+ {
+ // A destination is required.
+ cmOStringStream e;
+ e << args[0] << " given no DESTINATION!";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
+ // Compute destination path.
+ std::string dest;
+ this->ComputeDestination(destination, dest);
+
+ // Create the directory install generator.
+ this->Makefile->AddInstallGenerator(
+ new cmInstallDirectoryGenerator(dirs, dest.c_str(),
+ permissions_file.c_str(),
+ permissions_dir.c_str(),
+ configurations,
+ component.c_str()));
+
+ // Tell the global generator about any installation component names
+ // specified.
+ this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
+ ->AddInstallComponent(component.c_str());
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
void cmInstallCommand::ComputeDestination(const char* destination,
std::string& dest)
{
diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h
index 508fc093a7..7bf77df152 100644
--- a/Source/cmInstallCommand.h
+++ b/Source/cmInstallCommand.h
@@ -191,6 +191,7 @@ private:
bool HandleScriptMode(std::vector<std::string> const& args);
bool HandleTargetsMode(std::vector<std::string> const& args);
bool HandleFilesMode(std::vector<std::string> const& args);
+ bool HandleDirectoryMode(std::vector<std::string> const& args);
void ComputeDestination(const char* destination, std::string& dest);
bool CheckPermissions(std::string const& arg, std::string& permissions);
};
diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx
new file mode 100644
index 0000000000..9ff09a6f82
--- /dev/null
+++ b/Source/cmInstallDirectoryGenerator.cxx
@@ -0,0 +1,59 @@
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#include "cmInstallDirectoryGenerator.h"
+
+#include "cmTarget.h"
+
+//----------------------------------------------------------------------------
+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):
+ Directories(dirs), Destination(dest),
+ FilePermissions(file_permissions), DirPermissions(dir_permissions),
+ Configurations(configurations), Component(component)
+{
+}
+
+//----------------------------------------------------------------------------
+cmInstallDirectoryGenerator
+::~cmInstallDirectoryGenerator()
+{
+}
+
+//----------------------------------------------------------------------------
+void cmInstallDirectoryGenerator::GenerateScript(std::ostream& os)
+{
+ // Write code to install the directories.
+ for(std::vector<std::string>::const_iterator di = this->Directories.begin();
+ di != this->Directories.end(); ++di)
+ {
+ bool not_optional = false;
+ const char* no_properties = 0;
+ const char* no_rename = 0;
+ this->AddInstallRule(os, this->Destination.c_str(),
+ cmTarget::INSTALL_DIRECTORY, di->c_str(),
+ not_optional, no_properties,
+ this->FilePermissions.c_str(),
+ this->DirPermissions.c_str(),
+ this->Configurations, this->Component.c_str(),
+ no_rename);
+ }
+}
diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h
new file mode 100644
index 0000000000..6b36434db3
--- /dev/null
+++ b/Source/cmInstallDirectoryGenerator.h
@@ -0,0 +1,46 @@
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef cmInstallDirectoryGenerator_h
+#define cmInstallDirectoryGenerator_h
+
+#include "cmInstallGenerator.h"
+
+/** \class cmInstallDirectoryGenerator
+ * \brief Generate directory installation rules.
+ */
+class cmInstallDirectoryGenerator: public cmInstallGenerator
+{
+public:
+ 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);
+ virtual ~cmInstallDirectoryGenerator();
+
+protected:
+ virtual void GenerateScript(std::ostream& os);
+ std::vector<std::string> Directories;
+ std::string Destination;
+ std::string FilePermissions;
+ std::string DirPermissions;
+ std::vector<std::string> Configurations;
+ std::string Component;
+};
+
+#endif
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index 7990b2ac68..fd857a5075 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -22,12 +22,12 @@
cmInstallFilesGenerator
::cmInstallFilesGenerator(std::vector<std::string> const& files,
const char* dest, bool programs,
- const char* permissions,
+ const char* file_permissions,
std::vector<std::string> const& configurations,
const char* component,
const char* rename):
Files(files), Destination(dest), Programs(programs),
- Permissions(permissions), Configurations(configurations),
+ FilePermissions(file_permissions), Configurations(configurations),
Component(component), Rename(rename)
{
}
@@ -47,12 +47,13 @@ void cmInstallFilesGenerator::GenerateScript(std::ostream& os)
{
bool not_optional = false;
const char* no_properties = 0;
+ const char* no_dir_permissions = 0;
this->AddInstallRule(os, this->Destination.c_str(),
(this->Programs
? cmTarget::INSTALL_PROGRAMS
: cmTarget::INSTALL_FILES), fi->c_str(),
not_optional, no_properties,
- this->Permissions.c_str(),
+ this->FilePermissions.c_str(), no_dir_permissions,
this->Configurations,
this->Component.c_str(),
this->Rename.c_str());
diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h
index 4589b1e37e..400d29a79a 100644
--- a/Source/cmInstallFilesGenerator.h
+++ b/Source/cmInstallFilesGenerator.h
@@ -27,7 +27,7 @@ class cmInstallFilesGenerator: public cmInstallGenerator
public:
cmInstallFilesGenerator(std::vector<std::string> const& files,
const char* dest, bool programs,
- const char* permissions,
+ const char* file_permissions,
std::vector<std::string> const& configurations,
const char* component,
const char* rename);
@@ -38,7 +38,7 @@ protected:
std::vector<std::string> Files;
std::string Destination;
bool Programs;
- std::string Permissions;
+ std::string FilePermissions;
std::vector<std::string> Configurations;
std::string Component;
std::string Rename;
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx
index afbc68acec..034410bb94 100644
--- a/Source/cmInstallGenerator.cxx
+++ b/Source/cmInstallGenerator.cxx
@@ -55,7 +55,8 @@ void cmInstallGenerator
const char* file,
bool optional /* = false */,
const char* properties /* = 0 */,
- const char* permissions /* = 0 */,
+ const char* permissions_file /* = 0 */,
+ const char* permissions_dir /* = 0 */,
std::vector<std::string> const& configurations,
const char* component /* = 0 */,
const char* rename /* = 0 */
@@ -83,9 +84,13 @@ void cmInstallGenerator
{
os << " PROPERTIES" << properties;
}
- if(permissions && *permissions)
+ if(permissions_file && *permissions_file)
{
- os << " PERMISSIONS" << permissions;
+ os << " PERMISSIONS" << permissions_file;
+ }
+ if(permissions_dir && *permissions_dir)
+ {
+ os << " DIR_PERMISSIONS" << permissions_dir;
}
if(rename && *rename)
{
diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h
index 53c8c432df..df165c0c6f 100644
--- a/Source/cmInstallGenerator.h
+++ b/Source/cmInstallGenerator.h
@@ -38,7 +38,8 @@ public:
std::ostream& os, const char* dest, int type,
const char* file, bool optional = false,
const char* properties = 0,
- const char* permissions = 0,
+ const char* permissions_file = 0,
+ const char* permissions_dir = 0,
std::vector<std::string> const& configurations
= std::vector<std::string>(),
const char* component = 0,
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index aba196063e..a15ce3c617 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -25,11 +25,11 @@
//----------------------------------------------------------------------------
cmInstallTargetGenerator
::cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib,
- const char* permissions,
+ const char* file_permissions,
std::vector<std::string> const& configurations,
const char* component):
Target(&t), Destination(dest), ImportLibrary(implib),
- Permissions(permissions), Configurations(configurations),
+ FilePermissions(file_permissions), Configurations(configurations),
Component(component)
{
this->Target->SetHaveInstallRule(true);
@@ -158,9 +158,10 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os)
}
// Write code to install the target file.
+ const char* no_dir_permissions = 0;
this->AddInstallRule(os, destination.c_str(), type, fromFile.c_str(),
this->ImportLibrary, properties,
- this->Permissions.c_str(),
+ this->FilePermissions.c_str(), no_dir_permissions,
this->Configurations,
this->Component.c_str());
diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h
index 693a908f13..63eea304dd 100644
--- a/Source/cmInstallTargetGenerator.h
+++ b/Source/cmInstallTargetGenerator.h
@@ -29,7 +29,7 @@ class cmInstallTargetGenerator: public cmInstallGenerator
public:
cmInstallTargetGenerator(
cmTarget& t, const char* dest, bool implib,
- const char* permissions = "",
+ const char* file_permissions = "",
std::vector<std::string> const& configurations
= std::vector<std::string>(),
const char* component = ""
@@ -47,7 +47,7 @@ protected:
cmTarget* Target;
std::string Destination;
bool ImportLibrary;
- std::string Permissions;
+ std::string FilePermissions;
std::vector<std::string> Configurations;
std::string Component;
};