summaryrefslogtreecommitdiffstats
path: root/Source/cmInstallCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-01-28 13:38:36 (GMT)
committerBrad King <brad.king@kitware.com>2008-01-28 13:38:36 (GMT)
commit5594ad488576a77d9c6b8c3c1999a04fb4e6867d (patch)
treef22726476b6eaaf3832e48c185fe3c112601db17 /Source/cmInstallCommand.cxx
parenta7cb9d1120c0555f1da67dd585bd1b4fd16d389d (diff)
downloadCMake-5594ad488576a77d9c6b8c3c1999a04fb4e6867d.zip
CMake-5594ad488576a77d9c6b8c3c1999a04fb4e6867d.tar.gz
CMake-5594ad488576a77d9c6b8c3c1999a04fb4e6867d.tar.bz2
ENH: Updated exporting and importing of targets to support libraries and configurations.
- Created cmExportFileGenerator hierarchy to implement export file generation - Installed exports use per-config import files loaded by a central one. - Include soname of shared libraries in import information - Renamed PREFIX to NAMESPACE in INSTALL(EXPORT) and EXPORT() commands - Move addition of CMAKE_INSTALL_PREFIX to destinations to install generators - Import files compute the installation prefix relative to their location when loaded - Add mapping of importer configurations to importee configurations - Rename IMPORT targets to IMPORTED targets to distinguish from windows import libraries - Scope IMPORTED targets within directories to isolate them - Place all properties created by import files in the IMPORTED namespace - Document INSTALL(EXPORT) and EXPORT() commands. - Document IMPORTED signature of add_executable and add_library - Enable finding of imported targets in cmComputeLinkDepends
Diffstat (limited to 'Source/cmInstallCommand.cxx')
-rw-r--r--Source/cmInstallCommand.cxx96
1 files changed, 57 insertions, 39 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 915cd4b..6c742b9 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -300,7 +300,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
++targetIt)
{
// Lookup this target in the current directory.
- if(cmTarget* target=this->Makefile->FindTarget(targetIt->c_str(), false))
+ if(cmTarget* target=this->Makefile->FindTarget(targetIt->c_str()))
{
// Found the target. Check its type.
if(target->GetType() != cmTarget::EXECUTABLE &&
@@ -489,7 +489,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// library. Install it to the archive destination if it
// exists.
if(dll_platform && !archiveArgs.GetDestination().empty() &&
- target.GetPropertyAsBool("ENABLE_EXPORTS"))
+ target.IsExecutableWithExports())
{
// The import library uses the ARCHIVE properties.
archiveGenerator = CreateInstallTargetGenerator(target,
@@ -1069,13 +1069,9 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
return false;
}
- // Compute destination path.
- std::string dest;
- cmInstallCommandArguments::ComputeDestination(destination, dest);
-
// Create the directory install generator.
this->Makefile->AddInstallGenerator(
- new cmInstallDirectoryGenerator(dirs, dest.c_str(),
+ new cmInstallDirectoryGenerator(dirs, destination,
permissions_file.c_str(),
permissions_dir.c_str(),
configurations,
@@ -1095,12 +1091,12 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
{
// This is the EXPORT mode.
cmInstallCommandArguments ica;
- cmCAStringVector exports(&ica.Parser, "EXPORT");
- cmCAString prefix(&ica.Parser, "PREFIX", &ica.ArgumentGroup);
+ cmCAString exp(&ica.Parser, "EXPORT");
+ cmCAString name_space(&ica.Parser, "NAMESPACE", &ica.ArgumentGroup);
cmCAString filename(&ica.Parser, "FILE", &ica.ArgumentGroup);
- exports.Follows(0);
+ exp.Follows(0);
- ica.ArgumentGroup.Follows(&exports);
+ ica.ArgumentGroup.Follows(&exp);
std::vector<std::string> unknownArgs;
ica.Parse(&args, &unknownArgs);
@@ -1118,44 +1114,66 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
return false;
}
- std::string cmakeDir = this->Makefile->GetHomeOutputDirectory();
- cmakeDir += cmake::GetCMakeFilesDirectory();
- for(std::vector<std::string>::const_iterator
- exportIt = exports.GetVector().begin();
- exportIt != exports.GetVector().end();
- ++exportIt)
+ // Make sure there is a destination.
+ if(ica.GetDestination().empty())
{
- const std::vector<cmTargetExport*>* exportSet = this->
- Makefile->GetLocalGenerator()->GetGlobalGenerator()->
- GetExportSet(exportIt->c_str());
- if (exportSet == 0)
- {
- cmOStringStream e;
- e << "EXPORT given unknown export name \"" << exportIt->c_str() << "\".";
- this->SetError(e.str().c_str());
- return false;
- }
+ // A destination is required.
+ cmOStringStream e;
+ e << args[0] << " given no DESTINATION!";
+ this->SetError(e.str().c_str());
+ return false;
+ }
- // Create the export install generator.
- cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
- ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
- ica.GetConfigurations(),0 , filename.GetCString(),
- prefix.GetCString(), cmakeDir.c_str());
+ // Check the file name.
+ std::string fname = filename.GetString();
+ if(fname.find_first_of(":/\\") != fname.npos)
+ {
+ cmOStringStream e;
+ e << args[0] << " given invalid export file name \"" << fname << "\". "
+ << "The FILE argument may not contain a path. "
+ << "Specify the path in the DESTINATION argument.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
- if (exportGenerator->SetExportSet(exportIt->c_str(),exportSet))
- {
- this->Makefile->AddInstallGenerator(exportGenerator);
- }
- else
+ // Check the file extension.
+ if(!fname.empty() &&
+ cmSystemTools::GetFilenameLastExtension(fname) != ".cmake")
+ {
+ cmOStringStream e;
+ e << args[0] << " given invalid export file name \"" << fname << "\". "
+ << "The FILE argument must specify a name ending in \".cmake\".";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
+ // Construct the file name.
+ if(fname.empty())
+ {
+ fname = exp.GetString();
+ fname += ".cmake";
+
+ if(fname.find_first_of(":/\\") != fname.npos)
{
cmOStringStream e;
- e << "EXPORT failed, maybe a target is exported more than once.";
+ e << args[0] << " given export name \"" << exp.GetString() << "\". "
+ << "This name cannot be safely converted to a file name. "
+ << "Specify a different export name or use the FILE option to set "
+ << "a file name explicitly.";
this->SetError(e.str().c_str());
- delete exportGenerator;
return false;
}
}
+ // Create the export install generator.
+ cmInstallExportGenerator* exportGenerator =
+ new cmInstallExportGenerator(
+ exp.GetCString(), ica.GetDestination().c_str(),
+ ica.GetPermissions().c_str(), ica.GetConfigurations(),
+ ica.GetComponent().c_str(), fname.c_str(),
+ name_space.GetCString(), this->Makefile);
+ this->Makefile->AddInstallGenerator(exportGenerator);
+
return true;
}