diff options
author | Brad King <brad.king@kitware.com> | 2006-02-19 23:47:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-02-19 23:47:13 (GMT) |
commit | 518080136d2b643b2b27ae1ef69cee28306c2f81 (patch) | |
tree | 3e57cf1c6f7943dcff3bb879e0da13bc01f97412 /Source/cmInstallCommand.cxx | |
parent | 4140f4a6faa63042cdb5378061cf8d30040a7dd1 (diff) | |
download | CMake-518080136d2b643b2b27ae1ef69cee28306c2f81.zip CMake-518080136d2b643b2b27ae1ef69cee28306c2f81.tar.gz CMake-518080136d2b643b2b27ae1ef69cee28306c2f81.tar.bz2 |
ENH: Implemented FILES and PROGRAMS forms of the INSTALL command as replacements for the INSTALL_FILES and INSTALL_PROGRAMS commands. This addresses the request for absolute path install destinations in bug#2691.
Diffstat (limited to 'Source/cmInstallCommand.cxx')
-rw-r--r-- | Source/cmInstallCommand.cxx | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 0750173..6f86ee6 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -16,6 +16,7 @@ =========================================================================*/ #include "cmInstallCommand.h" +#include "cmInstallFilesGenerator.h" #include "cmInstallScriptGenerator.h" #include "cmInstallTargetGenerator.h" @@ -38,6 +39,14 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args) { return this->HandleTargetsMode(args); } + else if(args[0] == "FILES") + { + return this->HandleFilesMode(args); + } + else if(args[0] == "PROGRAMS") + { + return this->HandleFilesMode(args); + } // Unknown mode. cmStdString e = "called with unknown mode "; @@ -284,6 +293,85 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } //---------------------------------------------------------------------------- +bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) +{ + // This is the FILES mode. + bool programs = (args[0] == "PROGRAMS"); + bool doing_files = true; + bool doing_destination = false; + std::vector<std::string> files; + const char* destination = 0; + for(unsigned int i=1; i < args.size(); ++i) + { + if(args[i] == "DESTINATION") + { + // Switch to setting the destination property. + doing_files = false; + doing_destination = true; + } + else if(doing_files) + { + // Convert this file to a full path. + std::string file = args[i]; + if(!cmSystemTools::FileIsFullPath(file.c_str())) + { + file = m_Makefile->GetCurrentDirectory(); + file += "/"; + file += args[i]; + } + + // Make sure the file is not a directory. + if(cmSystemTools::FileIsDirectory(file.c_str())) + { + cmOStringStream e; + e << args[0] << " given directory \"" << args[i] << "\" to install."; + this->SetError(e.str().c_str()); + return false; + } + + // Store the file for installation. + files.push_back(file); + } + else if(doing_destination) + { + destination = args[i].c_str(); + doing_destination = 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(files.empty()) + { + return true; + } + if(!destination) + { + 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 files install generator. + m_Makefile->AddInstallGenerator( + new cmInstallFilesGenerator(files, dest.c_str(), programs)); + + return true; +} + +//---------------------------------------------------------------------------- void cmInstallCommand::ComputeDestination(const char* destination, std::string& dest) { |