Browse Source

cm{,Generator}Target: Add global generator accessors

Provide 'static polymorphism' between the types in this aspect so that
they can be used indiscriminately in a C++ template.
Stephen Kelly 9 years ago
parent
commit
a0a720e6a7
4 changed files with 15 additions and 0 deletions
  1. 5 0
      Source/cmGeneratorTarget.cxx
  2. 2 0
      Source/cmGeneratorTarget.h
  3. 5 0
      Source/cmTarget.cxx
  4. 3 0
      Source/cmTarget.h

+ 5 - 0
Source/cmGeneratorTarget.cxx

@@ -320,6 +320,11 @@ cmGeneratorTarget::~cmGeneratorTarget()
   cmDeleteAll(this->LinkInformation);
 }
 
+cmGlobalGenerator* cmGeneratorTarget::GetGlobalGenerator() const
+{
+  return this->GetLocalGenerator()->GetGlobalGenerator();
+}
+
 cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const
 {
   return this->LocalGenerator;

+ 2 - 0
Source/cmGeneratorTarget.h

@@ -32,6 +32,8 @@ public:
 
   cmLocalGenerator* GetLocalGenerator() const;
 
+  cmGlobalGenerator* GetGlobalGenerator() const;
+
   bool IsImported() const;
   bool IsImportedGloballyVisible() const;
   const char* GetLocation(const std::string& config) const;

+ 5 - 0
Source/cmTarget.cxx

@@ -272,6 +272,11 @@ cmTarget::cmTarget(std::string const& name, cmState::TargetType type,
   }
 }
 
+cmGlobalGenerator* cmTarget::GetGlobalGenerator() const
+{
+  return this->GetMakefile()->GetGlobalGenerator();
+}
+
 void cmTarget::AddUtility(const std::string& u, cmMakefile* makefile)
 {
   if (this->Utilities.insert(u).second && makefile) {

+ 3 - 0
Source/cmTarget.h

@@ -30,6 +30,7 @@
 
 class cmMakefile;
 class cmSourceFile;
+class cmGlobalGenerator;
 class cmTargetInternals;
 
 class cmTargetInternalPointer
@@ -76,6 +77,8 @@ public:
    */
   cmState::TargetType GetType() const { return this->TargetTypeValue; }
 
+  cmGlobalGenerator* GetGlobalGenerator() const;
+
   ///! Set/Get the name of the target
   const std::string& GetName() const { return this->Name; }