diff options
-rw-r--r-- | Source/cmInstallCommand.cxx | 56 | ||||
-rw-r--r-- | Source/cmInstallCommand.h | 1 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.h | 5 | ||||
-rw-r--r-- | Tests/SimpleInstall/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/SimpleInstallS2/CMakeLists.txt | 5 |
6 files changed, 69 insertions, 12 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 15a0f2b..449aa44 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -98,11 +98,14 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // This is the TARGETS mode. bool doing_targets = true; bool doing_destination = false; + bool doing_permissions = false; bool library_settings = true; bool runtime_settings = true; std::vector<cmTarget*> targets; const char* library_destination = 0; const char* runtime_destination = 0; + std::string library_permissions; + std::string runtime_permissions; for(unsigned int i=1; i < args.size(); ++i) { if(args[i] == "DESTINATION") @@ -110,12 +113,21 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // Switch to setting the destination property. doing_targets = false; doing_destination = true; + doing_permissions = false; + } + else if(args[i] == "PERMISSIONS") + { + // Switch to setting the permissions property. + doing_targets = false; + doing_destination = false; + doing_permissions = true; } else if(args[i] == "LIBRARY") { // Switch to setting only library properties. doing_targets = false; doing_destination = false; + doing_permissions = false; library_settings = true; runtime_settings = false; } @@ -124,6 +136,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // Switch to setting only runtime properties. doing_targets = false; doing_destination = false; + doing_permissions = false; library_settings = false; runtime_settings = true; } @@ -171,6 +184,34 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } doing_destination = false; } + else if(doing_permissions) + { + // Set the permissions in the active set(s) of properties. + if(library_settings) + { + // Check the requested permission. + if(!this->CheckPermissions(args[i], library_permissions)) + { + cmOStringStream e; + e << args[0] << " given invalid permission \"" + << args[i] << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + if(runtime_settings) + { + // Check the requested permission. + if(!this->CheckPermissions(args[i], runtime_permissions)) + { + cmOStringStream e; + e << args[0] << " given invalid permission \"" + << args[i] << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + } else { // Unknown argument. @@ -218,13 +259,15 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) { // The import library uses the LIBRARY properties. m_Makefile->AddInstallGenerator( - new cmInstallTargetGenerator(target, library_dest.c_str(), true)); + new cmInstallTargetGenerator(target, library_dest.c_str(), true, + library_permissions.c_str())); } if(runtime_destination) { // The DLL uses the RUNTIME properties. m_Makefile->AddInstallGenerator( - new cmInstallTargetGenerator(target, runtime_dest.c_str(), false)); + new cmInstallTargetGenerator(target, runtime_dest.c_str(), false, + runtime_permissions.c_str())); } #else // This is a non-DLL platform. @@ -232,7 +275,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) { // The shared library uses the LIBRARY properties. m_Makefile->AddInstallGenerator( - new cmInstallTargetGenerator(target, library_dest.c_str())); + new cmInstallTargetGenerator(target, library_dest.c_str(), false, + library_permissions.c_str())); } #endif } @@ -244,7 +288,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) if(library_destination) { m_Makefile->AddInstallGenerator( - new cmInstallTargetGenerator(target, library_dest.c_str())); + new cmInstallTargetGenerator(target, library_dest.c_str(), false, + library_permissions.c_str())); } else { @@ -270,7 +315,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) if(runtime_destination) { m_Makefile->AddInstallGenerator( - new cmInstallTargetGenerator(target, runtime_dest.c_str())); + new cmInstallTargetGenerator(target, runtime_dest.c_str(), false, + runtime_permissions.c_str())); } else { diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index c692c22..d31fef5 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -90,6 +90,7 @@ public: "The TARGETS signature:\n" " INSTALL(TARGETS targets... [[LIBRARY|RUNTIME]\n" " [DESTINATION <dir>]\n" + " [PERMISSIONS permissions...]\n" " ] [...])\n" "The TARGETS form specifies rules for installing targets from a " "project. There are two kinds of target files that may be " diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 6be87ec..c84c4af 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -23,8 +23,10 @@ //---------------------------------------------------------------------------- cmInstallTargetGenerator -::cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib): - Target(&t), Destination(dest), ImportLibrary(implib) +::cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib, + const char* permissions): + Target(&t), Destination(dest), ImportLibrary(implib), + Permissions(permissions) { this->Target->SetHaveInstallRule(true); } @@ -158,7 +160,8 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os) // Write code to install the target file. this->AddInstallRule(os, destination.c_str(), type, fromFile.c_str(), - this->ImportLibrary, properties); + this->ImportLibrary, properties, + this->Permissions.c_str()); // Fix the install_name settings in installed binaries. if(type == cmTarget::SHARED_LIBRARY || diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 8ae834b..482e3f4 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -27,8 +27,8 @@ class cmTarget; class cmInstallTargetGenerator: public cmInstallGenerator { public: - cmInstallTargetGenerator(cmTarget& t, const char* dest, - bool implib = false); + cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib, + const char* permissions = ""); virtual ~cmInstallTargetGenerator(); protected: @@ -42,6 +42,7 @@ protected: cmTarget* Target; std::string Destination; bool ImportLibrary; + std::string Permissions; }; #endif diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index fc5c861..755d1a2 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -92,8 +92,11 @@ ELSE(STAGE2) ADD_DEPENDENCIES(test2 test3) ADD_DEPENDENCIES(test4 test2) - INSTALL(TARGETS SimpleInstall test1 test2 test3 test4 + INSTALL(TARGETS SimpleInstall test1 test2 test3 RUNTIME DESTINATION bin LIBRARY DESTINATION lib) + INSTALL(TARGETS test4 + RUNTIME DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE) INSTALL(FILES lib1.h DESTINATION include/foo) INSTALL(FILES lib2.h DESTINATION include/foo diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index fc5c861..755d1a2 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -92,8 +92,11 @@ ELSE(STAGE2) ADD_DEPENDENCIES(test2 test3) ADD_DEPENDENCIES(test4 test2) - INSTALL(TARGETS SimpleInstall test1 test2 test3 test4 + INSTALL(TARGETS SimpleInstall test1 test2 test3 RUNTIME DESTINATION bin LIBRARY DESTINATION lib) + INSTALL(TARGETS test4 + RUNTIME DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE) INSTALL(FILES lib1.h DESTINATION include/foo) INSTALL(FILES lib2.h DESTINATION include/foo |