diff options
author | Brad King <brad.king@kitware.com> | 2006-03-03 23:44:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-03-03 23:44:32 (GMT) |
commit | a2e136fd17b693765a4961220433bdf207930583 (patch) | |
tree | b785101e7a9fe7bed52a05e3d483216b500a4d70 /Source/cmInstallCommand.cxx | |
parent | 5792dc8da8a567ece9fd231e9844a5b1cd30ddc2 (diff) | |
download | CMake-a2e136fd17b693765a4961220433bdf207930583.zip CMake-a2e136fd17b693765a4961220433bdf207930583.tar.gz CMake-a2e136fd17b693765a4961220433bdf207930583.tar.bz2 |
ENH: Added PERMISSIONS and RENAME options to the INSTALL command's FILES and PROGRAMS mode, and corresponding support to FILE(INSTALL). Default permissions for shared libraries on non-Windows/non-OSX platforms no longer has the execute bit set.
Diffstat (limited to 'Source/cmInstallCommand.cxx')
-rw-r--r-- | Source/cmInstallCommand.cxx | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 6f86ee6..15a0f2b 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -299,8 +299,12 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) bool programs = (args[0] == "PROGRAMS"); bool doing_files = true; bool doing_destination = false; + bool doing_permissions = false; + bool doing_rename = false; std::vector<std::string> files; const char* destination = 0; + std::string rename; + std::string permissions; for(unsigned int i=1; i < args.size(); ++i) { if(args[i] == "DESTINATION") @@ -308,6 +312,24 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) // Switch to setting the destination property. doing_files = false; doing_destination = true; + doing_permissions = false; + doing_rename = false; + } + else if(args[i] == "PERMISSIONS") + { + // Switch to setting the permissions property. + doing_files = false; + doing_destination = false; + doing_permissions = true; + doing_rename = false; + } + else if(args[i] == "RENAME") + { + // Switch to setting the rename property. + doing_files = false; + doing_destination = false; + doing_permissions = false; + doing_rename = true; } else if(doing_files) { @@ -337,6 +359,23 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) destination = args[i].c_str(); doing_destination = false; } + else if(doing_permissions) + { + // Check the requested permission. + if(!this->CheckPermissions(args[i], permissions)) + { + cmOStringStream e; + e << args[0] << " given invalid permission \"" + << args[i] << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + else if(doing_rename) + { + rename = args[i]; + doing_rename = false; + } else { // Unknown argument. @@ -354,11 +393,20 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) } if(!destination) { + // A destination is required. cmOStringStream e; e << args[0] << " given no DESTINATION!"; this->SetError(e.str().c_str()); return false; } + if(!rename.empty() && files.size() > 1) + { + // The rename option works only with one file. + cmOStringStream e; + e << args[0] << " given RENAME option with more than one file."; + this->SetError(e.str().c_str()); + return false; + } // Compute destination path. std::string dest; @@ -366,7 +414,8 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) // Create the files install generator. m_Makefile->AddInstallGenerator( - new cmInstallFilesGenerator(files, dest.c_str(), programs)); + new cmInstallFilesGenerator(files, dest.c_str(), programs, + permissions.c_str(), rename.c_str())); return true; } @@ -398,3 +447,32 @@ void cmInstallCommand::ComputeDestination(const char* destination, dest = ""; } } + +//---------------------------------------------------------------------------- +bool cmInstallCommand::CheckPermissions(std::string const& arg, + std::string& permissions) +{ + // Table of valid permissions. + const char* table[] = + { + "OWNER_READ", "OWNER_WRITE", "OWNER_EXECUTE", + "GROUP_READ", "GROUP_WRITE", "GROUP_EXECUTE", + "WORLD_READ", "WORLD_WRITE", "WORLD_EXECUTE", + "SETUID", "SETGID", 0 + }; + + // Check the permission against the table. + for(const char** valid = table; *valid; ++valid) + { + if(arg == *valid) + { + // This is a valid permission. + permissions += " "; + permissions += arg; + return true; + } + } + + // This is not a valid permission. + return false; +} |