summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-05-17 08:12:02 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-05-18 08:00:48 (GMT)
commitb5d6f5dd5b894ea6dcd8f87e1925db5551f3ffc0 (patch)
tree59dd309a90bfd35c5117e6132ef6c7622fb7cdbf /Source
parentedeabd18e6db5a52b2191ea9d3b09ee8bd090af6 (diff)
downloadCMake-b5d6f5dd5b894ea6dcd8f87e1925db5551f3ffc0.zip
CMake-b5d6f5dd5b894ea6dcd8f87e1925db5551f3ffc0.tar.gz
CMake-b5d6f5dd5b894ea6dcd8f87e1925db5551f3ffc0.tar.bz2
Add EXPORT_NAME property.
This allows for example, the buildsystem to use names like 'boost_any' instead of the overly generic 'any', and still be able to generate IMPORTED targets called 'boost::any'.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExportBuildFileGenerator.cxx4
-rw-r--r--Source/cmExportFileGenerator.cxx12
-rw-r--r--Source/cmExportInstallFileGenerator.cxx7
-rw-r--r--Source/cmTarget.cxx43
-rw-r--r--Source/cmTarget.h1
5 files changed, 57 insertions, 10 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 7147f86..e1c26c6 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -30,7 +30,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
tei = this->Exports->begin();
tei != this->Exports->end(); ++tei)
{
- expectedTargets += sep + this->Namespace + (*tei)->GetName();
+ expectedTargets += sep + this->Namespace + (*tei)->GetExportName();
sep = " ";
cmTarget* te = *tei;
if(this->ExportedTargets.insert(te).second)
@@ -189,7 +189,7 @@ cmExportBuildFileGenerator::HandleMissingTarget(
// Assume the target will be exported by another command.
// Append it with the export namespace.
link_libs += this->Namespace;
- link_libs += dependee->GetName();
+ link_libs += dependee->GetExportName();
}
//----------------------------------------------------------------------------
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 27ec56b..a6ccbd5 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -376,7 +376,7 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target,
if (!properties.empty())
{
std::string targetName = this->Namespace;
- targetName += target->GetName();
+ targetName += target->GetExportName();
os << "set_target_properties(" << targetName << " PROPERTIES\n";
for(ImportPropertyMap::const_iterator pi = properties.begin();
pi != properties.end(); ++pi)
@@ -407,7 +407,7 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input,
}
if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end())
{
- input = this->Namespace + input;
+ input = this->Namespace + tgt->GetExportName();
}
else
{
@@ -772,7 +772,8 @@ cmExportFileGenerator
{
// Construct the imported target name.
std::string targetName = this->Namespace;
- targetName += target->GetName();
+
+ targetName += target->GetExportName();
// Create the imported target.
os << "# Create imported target " << targetName << "\n";
@@ -835,7 +836,8 @@ cmExportFileGenerator
{
// Construct the imported target name.
std::string targetName = this->Namespace;
- targetName += target->GetName();
+
+ targetName += target->GetExportName();
// Set the import properties.
os << "# Import target \"" << targetName << "\" for configuration \""
@@ -954,7 +956,7 @@ cmExportFileGenerator
{
// Construct the imported target name.
std::string targetName = this->Namespace;
- targetName += target->GetName();
+ targetName += target->GetExportName();
os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
"list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index ad12b5a..55081a7 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -47,7 +47,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei)
{
- expectedTargets += sep + this->Namespace + (*tei)->Target->GetName();
+ expectedTargets += sep + this->Namespace + (*tei)->Target->GetExportName();
sep = " ";
cmTargetExport const* te = *tei;
if(this->ExportedTargets.insert(te->Target).second)
@@ -395,13 +395,14 @@ cmExportInstallFileGenerator::HandleMissingTarget(
std::string& link_libs, std::vector<std::string>& missingTargets,
cmMakefile* mf, cmTarget* depender, cmTarget* dependee)
{
- std::string name = dependee->GetName();
+ const std::string name = dependee->GetName();
std::vector<std::string> namespaces = this->FindNamespaces(mf, name);
int targetOccurrences = (int)namespaces.size();
if (targetOccurrences == 1)
{
std::string missingTarget = namespaces[0];
- missingTarget += name;
+
+ missingTarget += dependee->GetExportName();
link_libs += missingTarget;
missingTargets.push_back(missingTarget);
}
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index ed8edcc..3f6488a 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -867,6 +867,13 @@ void cmTarget::DefineProperties(cmake *cm)
"OSX_ARCHITECTURES.");
cm->DefineProperty
+ ("EXPORT_NAME", cmProperty::TARGET,
+ "Exported name for target files.",
+ "This sets the name for the IMPORTED target generated when it this "
+ "target is is exported. "
+ "If not set, the logical target name is used by default.");
+
+ cm->DefineProperty
("OUTPUT_NAME", cmProperty::TARGET,
"Output name for target files.",
"This sets the base name for output files created for an executable or "
@@ -2719,6 +2726,14 @@ void cmTarget::SetProperty(const char* prop, const char* value)
new cmTargetInternals::IncludeDirectoriesEntry(cge));
return;
}
+ if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
+ {
+ cmOStringStream e;
+ e << "EXPORT_NAME property can't be set on imported targets (\""
+ << this->Name << "\")\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ return;
+ }
if (strcmp(prop, "LINK_LIBRARIES") == 0)
{
this->Internal->LinkInterfaceIncludeDirectoriesEntries.clear();
@@ -2753,6 +2768,14 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
new cmTargetInternals::IncludeDirectoriesEntry(ge.Parse(value)));
return;
}
+ if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
+ {
+ cmOStringStream e;
+ e << "EXPORT_NAME property can't be set on imported targets (\""
+ << this->Name << "\")\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ return;
+ }
if (strcmp(prop, "LINK_LIBRARIES") == 0)
{
if (cmGeneratorExpression::IsValidTargetName(value)
@@ -2770,6 +2793,26 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
}
//----------------------------------------------------------------------------
+const char* cmTarget::GetExportName()
+{
+ const char *exportName = this->GetProperty("EXPORT_NAME");
+
+ if (exportName && *exportName)
+ {
+ if (!cmGeneratorExpression::IsValidTargetName(exportName))
+ {
+ cmOStringStream e;
+ e << "EXPORT_NAME property \"" << exportName << "\" for \""
+ << this->GetName() << "\": is not valid.";
+ cmSystemTools::Error(e.str().c_str());
+ return "";
+ }
+ return exportName;
+ }
+ return this->GetName();
+}
+
+//----------------------------------------------------------------------------
void cmTarget::AppendBuildInterfaceIncludes()
{
if(this->GetType() != cmTarget::SHARED_LIBRARY &&
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 9d46796..42a31db 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -85,6 +85,7 @@ public:
///! Set/Get the name of the target
const char* GetName() const {return this->Name.c_str();}
+ const char* GetExportName();
///! Set the cmMakefile that owns this target
void SetMakefile(cmMakefile *mf);