summaryrefslogtreecommitdiffstats
path: root/Source/cmInstallCommand.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-06-19 17:10:21 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-06-19 17:10:21 (GMT)
commitc0d000d234525c709b8f6226d1c78c3cc0b632b3 (patch)
treefce16d3de49d612d0c545e2b385eed04b736a945 /Source/cmInstallCommand.cxx
parent617602e9e9e0ff57a3ef35e62e17d4a764edf920 (diff)
downloadCMake-c0d000d234525c709b8f6226d1c78c3cc0b632b3.zip
CMake-c0d000d234525c709b8f6226d1c78c3cc0b632b3.tar.gz
CMake-c0d000d234525c709b8f6226d1c78c3cc0b632b3.tar.bz2
ENH: add INSTALL(EXPORT ...) mode and INSTALL( TARGETS ... EXPORT <set> ) ,
tests still have to be added Alex
Diffstat (limited to 'Source/cmInstallCommand.cxx')
-rw-r--r--Source/cmInstallCommand.cxx186
1 files changed, 186 insertions, 0 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 62d3579..53a4173 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -20,6 +20,7 @@
#include "cmInstallFilesGenerator.h"
#include "cmInstallScriptGenerator.h"
#include "cmInstallTargetGenerator.h"
+#include "cmInstallExportGenerator.h"
#include <cmsys/Glob.hxx>
@@ -62,6 +63,10 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args)
{
return this->HandleDirectoryMode(args);
}
+ else if(args[0] == "EXPORT")
+ {
+ return this->HandleExportMode(args);
+ }
// Unknown mode.
cmStdString e = "called with unknown mode ";
@@ -135,6 +140,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
bool doing_permissions = false;
bool doing_component = false;
bool doing_configurations = false;
+ bool doing_export = false;
bool archive_settings = true;
bool library_settings = true;
bool runtime_settings = true;
@@ -148,6 +154,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
std::string archive_component;
std::string library_component;
std::string runtime_component;
+ std::string exportName;
std::vector<std::string> archive_configurations;
std::vector<std::string> library_configurations;
std::vector<std::string> runtime_configurations;
@@ -164,6 +171,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
doing_permissions = false;
doing_component = false;
doing_configurations = false;
+ doing_export = false;
}
else if(args[i] == "PERMISSIONS")
{
@@ -173,6 +181,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
doing_permissions = true;
doing_component = false;
doing_configurations = false;
+ doing_export = false;
}
else if(args[i] == "COMPONENT")
{
@@ -182,6 +191,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
doing_permissions = false;
doing_component = true;
doing_configurations = false;
+ doing_export = false;
}
else if(args[i] == "CONFIGURATIONS")
{
@@ -191,6 +201,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
doing_permissions = false;
doing_component = false;
doing_configurations = true;
+ doing_export = false;
}
else if(args[i] == "ARCHIVE")
{
@@ -200,6 +211,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
doing_permissions = false;
doing_component = false;
doing_configurations = false;
+ doing_export = false;
archive_settings = true;
library_settings = false;
runtime_settings = false;
@@ -212,6 +224,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
doing_permissions = false;
doing_component = false;
doing_configurations = false;
+ doing_export = false;
archive_settings = false;
library_settings = true;
runtime_settings = false;
@@ -224,10 +237,21 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
doing_permissions = false;
doing_component = false;
doing_configurations = false;
+ doing_export = false;
archive_settings = false;
library_settings = false;
runtime_settings = true;
}
+ else if(args[i] == "EXPORT")
+ {
+ // Switch to setting only runtime properties.
+ doing_targets = false;
+ doing_destination = false;
+ doing_permissions = false;
+ doing_component = false;
+ doing_configurations = false;
+ doing_export = true;
+ }
else if(args[i] == "OPTIONAL")
{
// Set the optional property.
@@ -370,6 +394,11 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
runtime_configurations.push_back(args[i]);
}
}
+ else if(doing_export)
+ {
+ exportName = args[i];
+ doing_export = false;
+ }
else
{
// Unknown argument.
@@ -566,6 +595,15 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
this->Makefile->AddInstallGenerator(runtimeGenerator);
this->Makefile->AddInstallGenerator(libraryGenerator);
+ if (!exportName.empty())
+ {
+ this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
+ ->AddTargetToExports(exportName.c_str(),
+ &target,
+ archiveGenerator,
+ runtimeGenerator,
+ libraryGenerator);
+ }
}
// Tell the global generator about any installation component names
@@ -1126,6 +1164,154 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
}
//----------------------------------------------------------------------------
+bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
+{
+ // This is the EXPORT mode.
+ bool doing_exports = true;
+ bool doing_destination = false;
+ bool doing_permissions = false;
+ bool doing_configurations = false;
+ bool doing_filename = false;
+ bool doing_prefix = false;
+ std::vector<std::string> exports;
+ const char* destination = 0;
+ std::string filename;
+ std::string permissions;
+ std::string prefix;
+ std::vector<std::string> configurations;
+ for(unsigned int i=1; i < args.size(); ++i)
+ {
+ if(args[i] == "DESTINATION")
+ {
+ // Switch to setting the destination property.
+ doing_exports = false;
+ doing_destination = true;
+ doing_permissions = false;
+ doing_configurations = false;
+ doing_filename = false;
+ doing_prefix = false;
+ }
+ else if(args[i] == "PERMISSIONS")
+ {
+ // Switch to setting the permissions property.
+ doing_exports = false;
+ doing_destination = false;
+ doing_permissions = true;
+ doing_configurations = false;
+ doing_filename = false;
+ doing_prefix = false;
+ }
+ else if(args[i] == "CONFIGURATIONS")
+ {
+ // Switch to setting the configurations property.
+ doing_exports = false;
+ doing_destination = false;
+ doing_permissions = false;
+ doing_configurations = true;
+ doing_filename = false;
+ doing_prefix = false;
+ }
+ else if(args[i] == "FILENAME")
+ {
+ // Switch to setting the rename property.
+ doing_exports = false;
+ doing_destination = false;
+ doing_permissions = false;
+ doing_configurations = false;
+ doing_filename = true;
+ doing_prefix = false;
+ }
+ else if(args[i] == "PREFIX")
+ {
+ // Switch to setting the rename property.
+ doing_exports = false;
+ doing_destination = false;
+ doing_permissions = false;
+ doing_configurations = false;
+ doing_filename = false;
+ doing_prefix = true;
+ }
+ else if(doing_exports)
+ {
+ // Store the file for installation.
+ exports.push_back(args[i]);
+ }
+ else if(doing_configurations)
+ {
+ configurations.push_back(args[i]);
+ }
+ else if(doing_destination)
+ {
+ 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_filename)
+ {
+ filename = args[i];
+ doing_filename = false;
+ }
+ else if(doing_prefix)
+ {
+ prefix = args[i];
+ doing_prefix = false;
+ }
+ else
+ {
+ // Unknown argument.
+ cmOStringStream e;
+ e << args[0] << " given unknown argument \"" << args[i] << "\".";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ }
+
+ std::string cmakeDir = this->Makefile->GetHomeOutputDirectory();
+ cmakeDir += cmake::GetCMakeFilesDirectory();
+ for(std::vector<std::string>::const_iterator exportIt = exports.begin();
+ exportIt != exports.end();
+ ++exportIt)
+ {
+
+ const std::vector<cmTargetExport*>* exportSet = this->
+ Makefile->GetLocalGenerator()->GetGlobalGenerator()->
+ GetExportSet(exportIt->c_str());
+ if (exportSet == 0)
+ {
+ return false;
+ }
+
+ // Create the export install generator.
+ cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
+ destination, permissions.c_str(), configurations,
+ filename.c_str(), prefix.c_str(), cmakeDir.c_str());
+
+ if (exportGenerator->SetExportSet(exportIt->c_str(),exportSet))
+ {
+ this->Makefile->AddInstallGenerator(exportGenerator);
+ }
+ else
+ {
+ delete exportGenerator;
+ return false;
+ }
+ }
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
void cmInstallCommand::ComputeDestination(const char* destination,
std::string& dest) const
{