summaryrefslogtreecommitdiffstats
path: root/Source/cmExportInstallFileGenerator.cxx
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2012-09-28 19:47:37 (GMT)
committerBrad King <brad.king@kitware.com>2012-09-30 14:26:10 (GMT)
commit0cfd055acda3543d66690b5e92d8ee7c20e0654f (patch)
treef034d09d81d1c9a0c7f4203cb87d1d3db667046e /Source/cmExportInstallFileGenerator.cxx
parent190f2c8253910a9e6870948df58a87950e7b4185 (diff)
downloadCMake-0cfd055acda3543d66690b5e92d8ee7c20e0654f.zip
CMake-0cfd055acda3543d66690b5e92d8ee7c20e0654f.tar.gz
CMake-0cfd055acda3543d66690b5e92d8ee7c20e0654f.tar.bz2
exports: move the handling of missing targets into subclasses
Before, cmExportFileGenerator::ComplainAboutMissingTarget() was a virtual function which had to be implemented in the subclasses. It is not anymore. Instead, there is now a virtual function HandleMissingTargets(), which is implemented in the two subclasses. This makes e.g. dealing correctly with APPEND mode easier. Alex
Diffstat (limited to 'Source/cmExportInstallFileGenerator.cxx')
-rw-r--r--Source/cmExportInstallFileGenerator.cxx71
1 files changed, 70 insertions, 1 deletions
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index cd05e60..7841731 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -11,11 +11,14 @@
============================================================================*/
#include "cmExportInstallFileGenerator.h"
+#include "cmExportSet.h"
+#include "cmExportSetMap.h"
#include "cmGeneratedFileStream.h"
+#include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
#include "cmInstallExportGenerator.h"
#include "cmInstallTargetGenerator.h"
#include "cmTargetExport.h"
-#include "cmExportSet.h"
//----------------------------------------------------------------------------
cmExportInstallFileGenerator
@@ -311,6 +314,72 @@ cmExportInstallFileGenerator
//----------------------------------------------------------------------------
void
+cmExportInstallFileGenerator::HandleMissingTarget(
+ std::string& link_libs, std::vector<std::string>& missingTargets,
+ cmMakefile* mf, cmTarget* depender, cmTarget* dependee)
+{
+ 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;
+ link_libs += missingTarget;
+ missingTargets.push_back(missingTarget);
+ }
+ else
+ {
+ // We are not appending, so all exported targets should be
+ // known here. This is probably user-error.
+ this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
+ }
+}
+
+//----------------------------------------------------------------------------
+std::vector<std::string>
+cmExportInstallFileGenerator
+::FindNamespaces(cmMakefile* mf, const std::string& name)
+{
+ std::vector<std::string> namespaces;
+ cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator();
+ const cmExportSetMap& exportSets = gg->GetExportSets();
+
+ for(cmExportSetMap::const_iterator expIt = exportSets.begin();
+ expIt != exportSets.end();
+ ++expIt)
+ {
+ const cmExportSet* exportSet = expIt->second;
+ std::vector<cmTargetExport*> const* targets =
+ exportSet->GetTargetExports();
+
+ bool containsTarget = false;
+ for(unsigned int i=0; i<targets->size(); i++)
+ {
+ if (name == (*targets)[i]->Target->GetName())
+ {
+ containsTarget = true;
+ break;
+ }
+ }
+
+ if (containsTarget)
+ {
+ std::vector<cmInstallExportGenerator const*> const* installs =
+ exportSet->GetInstallations();
+ for(unsigned int i=0; i<installs->size(); i++)
+ {
+ namespaces.push_back((*installs)[i]->GetNamespace());
+ }
+ }
+ }
+
+ return namespaces;
+}
+
+
+//----------------------------------------------------------------------------
+void
cmExportInstallFileGenerator
::ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen)
{