Browse Source

cmGeneratorTarget: Add methods for generate-time source addition.

Stephen Kelly 10 years ago
parent
commit
c38e30f68c

+ 11 - 1
Source/cmGeneratorTarget.cxx

@@ -402,6 +402,16 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config,
   return i->second;
 }
 
+void cmGeneratorTarget::AddSource(const std::string& src)
+{
+  this->Target->AddSource(src);
+}
+
+void cmGeneratorTarget::AddTracedSources(std::vector<std::string> const& srcs)
+{
+  this->Target->AddTracedSources(srcs);
+}
+
 //----------------------------------------------------------------------------
 std::vector<cmSourceFile*> const*
 cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const
@@ -1755,7 +1765,7 @@ void cmTargetTraceDependencies::Trace()
     }
   this->CurrentEntry = 0;
 
-  this->Target->AddTracedSources(this->NewSources);
+  this->GeneratorTarget->AddTracedSources(this->NewSources);
 }
 
 //----------------------------------------------------------------------------

+ 3 - 0
Source/cmGeneratorTarget.h

@@ -296,6 +296,9 @@ public:
   // Get the target base name.
   std::string GetOutputName(const std::string& config, bool implib) const;
 
+  void AddSource(const std::string& src);
+  void AddTracedSources(std::vector<std::string> const& srcs);
+
   /**
    * Flags for a given source file as used in this target. Typically assigned
    * via SET_TARGET_PROPERTIES when the property is a list of source files.

+ 1 - 1
Source/cmGlobalVisualStudio8Generator.cxx

@@ -336,7 +336,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
        no_main_dependency, commandLines, "Checking Build System",
        no_working_directory, true))
     {
-    tgt->AddSource(file->GetFullPath());
+    gt->AddSource(file->GetFullPath());
     }
   else
     {

+ 8 - 5
Source/cmGlobalXCodeGenerator.cxx

@@ -463,7 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
   std::string listfile = mf->GetCurrentSourceDirectory();
   listfile += "/";
   listfile += "CMakeLists.txt";
-  allbuild->AddSource(listfile.c_str());
+  allBuildGt->AddSource(listfile.c_str());
 
   // Add XCODE depend helper
   std::string dir = mf->GetCurrentBinaryDirectory();
@@ -553,11 +553,13 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
         allbuild->AddUtility(target.GetName());
         }
 
+      cmGeneratorTarget* targetGT = this->GetGeneratorTarget(&target);
+
       // Refer to the build configuration file for easy editing.
       listfile = lg->GetMakefile()->GetCurrentSourceDirectory();
       listfile += "/";
       listfile += "CMakeLists.txt";
-      target.AddSource(listfile.c_str());
+      targetGT->AddSource(listfile.c_str());
       }
     }
 }
@@ -1401,7 +1403,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget)
   if(cmSourceFile* sf = mf->GetOrCreateSource(fname.c_str()))
     {
     sf->SetProperty("LANGUAGE", llang.c_str());
-    cmtarget.AddSource(fname);
+    gtgt->AddSource(fname);
     }
 }
 
@@ -3069,17 +3071,18 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
         continue;
         }
 
+      cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
+
       // add the soon to be generated Info.plist file as a source for a
       // MACOSX_BUNDLE file
       if(cmtarget.GetPropertyAsBool("MACOSX_BUNDLE"))
         {
         std::string plist = this->ComputeInfoPListLocation(cmtarget);
         mf->GetOrCreateSource(plist, true);
-        cmtarget.AddSource(plist);
+        gtgt->AddSource(plist);
         }
 
       std::vector<cmSourceFile*> classes;
-      cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
       if (!gtgt->GetConfigCommonSourceFiles(classes))
         {
         return false;

+ 4 - 2
Source/cmLocalVisualStudio6Generator.cxx

@@ -243,7 +243,8 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
                                            no_working_directory, true);
   if(this->Makefile->GetSource(makefileIn.c_str()))
     {
-    tgt.AddSource(makefileIn);
+    cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&tgt);
+    gt->AddSource(makefileIn);
     }
   else
     {
@@ -595,7 +596,8 @@ cmLocalVisualStudio6Generator
        origCommand.GetCommandLines(), comment,
        origCommand.GetWorkingDirectory().c_str()))
     {
-    target.AddSource(outsf->GetFullPath());
+    cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target);
+    gt->AddSource(outsf->GetFullPath());
     }
 
   // Replace the dependencies with the output of this rule so that the

+ 6 - 2
Source/cmLocalVisualStudio7Generator.cxx

@@ -112,7 +112,9 @@ void cmLocalVisualStudio7Generator::AddCMakeListsRules()
           }
         if(l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
           {
-          l->second.AddSource(sf->GetFullPath());
+          cmGeneratorTarget* gt =
+              this->GlobalGenerator->GetGeneratorTarget(&l->second);
+          gt->AddSource(sf->GetFullPath());
           }
         }
       }
@@ -148,7 +150,9 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
            force.c_str(), no_depends, no_main_dependency,
            force_commands, " ", 0, true))
         {
-        tgt.AddSource(file->GetFullPath());
+        cmGeneratorTarget* gt =
+            this->GlobalGenerator->GetGeneratorTarget(&tgt);
+        gt->AddSource(file->GetFullPath());
         }
       }
     }

+ 2 - 2
Source/cmQtAutoGeneratorInitializer.cxx

@@ -101,7 +101,7 @@ static void SetupSourceFiles(cmGeneratorTarget const* target,
       fileIt != newRccFiles.end();
       ++fileIt)
     {
-    const_cast<cmTarget*>(target->Target)->AddSource(*fileIt);
+    const_cast<cmGeneratorTarget*>(target)->AddSource(*fileIt);
     }
 }
 
@@ -709,7 +709,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenSources(
     makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
                             mocCppFile.c_str(), false);
 
-    target->Target->AddSource(mocCppFile);
+    target->AddSource(mocCppFile);
     }
 }