summaryrefslogtreecommitdiffstats
path: root/Source/cmExportBuildFileGenerator.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-12-23 16:07:26 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-12-24 12:02:49 (GMT)
commitcbe7e8fae48b3663e784bb37d5f66bf8b3eb0546 (patch)
tree910046c109660f4533f0ec6ceec1de485e3032d2 /Source/cmExportBuildFileGenerator.cxx
parente73d1ad003c50730a8141db757462574c0c2dddc (diff)
downloadCMake-cbe7e8fae48b3663e784bb37d5f66bf8b3eb0546.zip
CMake-cbe7e8fae48b3663e784bb37d5f66bf8b3eb0546.tar.gz
CMake-cbe7e8fae48b3663e784bb37d5f66bf8b3eb0546.tar.bz2
export: Implement EXPORT subcommand (#9822)
Teach the export command to handle export sets defined by invocations of install(TARGETS ... EXPORT foo). This makes maintenance of targets exported to both the build tree and install tree trivial.
Diffstat (limited to 'Source/cmExportBuildFileGenerator.cxx')
-rw-r--r--Source/cmExportBuildFileGenerator.cxx36
1 files changed, 32 insertions, 4 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index c10f86f..b669cd1 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -13,11 +13,14 @@
#include "cmLocalGenerator.h"
#include "cmGlobalGenerator.h"
+#include "cmExportSet.h"
+#include "cmTargetExport.h"
//----------------------------------------------------------------------------
cmExportBuildFileGenerator::cmExportBuildFileGenerator()
{
this->Makefile = 0;
+ this->ExportSet = 0;
}
//----------------------------------------------------------------------------
@@ -26,9 +29,11 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
{
std::string expectedTargets;
std::string sep;
+ std::vector<std::string> targets;
+ this->GetTargets(targets);
for(std::vector<std::string>::const_iterator
- tei = this->Targets.begin();
- tei != this->Targets.end(); ++tei)
+ tei = targets.begin();
+ tei != targets.end(); ++tei)
{
cmTarget *te = this->Makefile->FindTargetToUse(tei->c_str());
expectedTargets += sep + this->Namespace + te->GetExportName();
@@ -153,6 +158,12 @@ cmExportBuildFileGenerator
}
//----------------------------------------------------------------------------
+void cmExportBuildFileGenerator::SetExportSet(cmExportSet *exportSet)
+{
+ this->ExportSet = exportSet;
+}
+
+//----------------------------------------------------------------------------
void
cmExportBuildFileGenerator
::SetImportLocationProperty(const char* config, std::string const& suffix,
@@ -232,6 +243,23 @@ cmExportBuildFileGenerator::HandleMissingTarget(
}
//----------------------------------------------------------------------------
+void cmExportBuildFileGenerator
+::GetTargets(std::vector<std::string> &targets) const
+{
+ if (this->ExportSet)
+ {
+ for(std::vector<cmTargetExport*>::const_iterator
+ tei = this->ExportSet->GetTargetExports()->begin();
+ tei != this->ExportSet->GetTargetExports()->end(); ++tei)
+ {
+ targets.push_back((*tei)->Target->GetName());
+ }
+ return;
+ }
+ targets = this->Targets;
+}
+
+//----------------------------------------------------------------------------
std::vector<std::string>
cmExportBuildFileGenerator
::FindNamespaces(cmMakefile* mf, const std::string& name)
@@ -246,8 +274,8 @@ cmExportBuildFileGenerator
expIt = exportSets.begin(); expIt != exportSets.end(); ++expIt)
{
const cmExportBuildFileGenerator* exportSet = expIt->second;
- std::vector<std::string> const& targets = exportSet->GetTargets();
-
+ std::vector<std::string> targets;
+ exportSet->GetTargets(targets);
if (std::find(targets.begin(), targets.end(), name) != targets.end())
{
namespaces.push_back(exportSet->GetNamespace());