Browse Source

cmLocalGenerator: Add current source directory accessor.

Stephen Kelly 10 years ago
parent
commit
a367416cec

+ 2 - 2
Source/cmExtraEclipseCDT4Generator.cxx

@@ -497,7 +497,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
 
     std::string sourceLinkedResourceName = "[Source directory]";
     std::string linkSourceDirectory = this->GetEclipsePath(
-                                             mf->GetCurrentSourceDirectory());
+                                             lg->GetCurrentSourceDirectory());
     // .project dir can't be subdir of a linked resource dir
     if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory,
                                          linkSourceDirectory))
@@ -638,7 +638,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
        ++it)
     {
     std::string linkSourceDirectory = this->GetEclipsePath(
-                   it->second[0]->GetMakefile()->GetCurrentSourceDirectory());
+                   it->second[0]->GetCurrentSourceDirectory());
     // a linked resource must not point to a parent directory of .project or
     // .project itself
     if ((baseDir != linkSourceDirectory) &&

+ 1 - 1
Source/cmGlobalGenerator.cxx

@@ -2105,7 +2105,7 @@ cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const
   for(std::vector<cmLocalGenerator*>::const_iterator it =
       this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it)
     {
-    std::string sd = (*it)->GetMakefile()->GetCurrentSourceDirectory();
+    std::string sd = (*it)->GetCurrentSourceDirectory();
     if (sd == start_dir)
       {
       return *it;

+ 6 - 5
Source/cmGlobalXCodeGenerator.cxx

@@ -412,8 +412,9 @@ void cmGlobalXCodeGenerator::SetGenerationRoot(cmLocalGenerator* root)
 {
   this->CurrentProject = root->GetProjectName();
   this->SetCurrentLocalGenerator(root);
-  cmSystemTools::SplitPath(this->CurrentMakefile->GetCurrentSourceDirectory(),
-                           this->ProjectSourceDirectoryComponents);
+  cmSystemTools::SplitPath(
+        this->CurrentLocalGenerator->GetCurrentSourceDirectory(),
+        this->ProjectSourceDirectoryComponents);
   cmSystemTools::SplitPath(
         this->CurrentLocalGenerator->GetCurrentBinaryDirectory(),
         this->ProjectOutputDirectoryComponents);
@@ -461,7 +462,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
   mf->AddGeneratorTarget(allbuild, allBuildGt);
 
   // Refer to the main build configuration file for easy editing.
-  std::string listfile = mf->GetCurrentSourceDirectory();
+  std::string listfile = root->GetCurrentSourceDirectory();
   listfile += "/";
   listfile += "CMakeLists.txt";
   allBuildGt->AddSource(listfile.c_str());
@@ -557,7 +558,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
       cmGeneratorTarget* targetGT = this->GetGeneratorTarget(&target);
 
       // Refer to the build configuration file for easy editing.
-      listfile = lg->GetMakefile()->GetCurrentSourceDirectory();
+      listfile = lg->GetCurrentSourceDirectory();
       listfile += "/";
       listfile += "CMakeLists.txt";
       targetGT->AddSource(listfile.c_str());
@@ -3372,7 +3373,7 @@ bool cmGlobalXCodeGenerator
   // Point Xcode at the top of the source tree.
   {
   std::string pdir =
-    this->RelativeToBinary(root->GetMakefile()->GetCurrentSourceDirectory());
+    this->RelativeToBinary(root->GetCurrentSourceDirectory());
   this->RootObject->AddAttribute("projectDirPath",
                                  this->CreateString(pdir.c_str()));
   this->RootObject->AddAttribute("projectRoot", this->CreateString(""));

+ 5 - 0
Source/cmLocalGenerator.cxx

@@ -2883,6 +2883,11 @@ const char* cmLocalGenerator::GetCurrentBinaryDirectory() const
   return this->StateSnapshot.GetDirectory().GetCurrentBinary();
 }
 
+const char* cmLocalGenerator::GetCurrentSourceDirectory() const
+{
+  return this->StateSnapshot.GetDirectory().GetCurrentSource();
+}
+
 //----------------------------------------------------------------------------
 std::string
 cmLocalGenerator::GetTargetDirectory(cmTarget const&) const

+ 1 - 0
Source/cmLocalGenerator.h

@@ -259,6 +259,7 @@ public:
   const char* GetBinaryDirectory() const;
 
   const char* GetCurrentBinaryDirectory() const;
+  const char* GetCurrentSourceDirectory() const;
 
   /**
    * Generate a Mac OS X application bundle Info.plist file.

+ 1 - 1
Source/cmLocalVisualStudio6Generator.cxx

@@ -215,7 +215,7 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
   dspname += ".dsp.cmake";
   cmCustomCommandLine commandLine;
   commandLine.push_back(cmSystemTools::GetCMakeCommand());
-  std::string makefileIn = this->Makefile->GetCurrentSourceDirectory();
+  std::string makefileIn = this->GetCurrentSourceDirectory();
   makefileIn += "/";
   makefileIn += "CMakeLists.txt";
   if(!cmSystemTools::FileExists(makefileIn.c_str()))

+ 1 - 1
Source/cmLocalVisualStudio7Generator.cxx

@@ -282,7 +282,7 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
   stampName += "generate.stamp";
   cmCustomCommandLine commandLine;
   commandLine.push_back(cmSystemTools::GetCMakeCommand());
-  std::string makefileIn = this->Makefile->GetCurrentSourceDirectory();
+  std::string makefileIn = this->GetCurrentSourceDirectory();
   makefileIn += "/";
   makefileIn += "CMakeLists.txt";
   makefileIn = cmSystemTools::CollapseFullPath(makefileIn.c_str());

+ 1 - 1
Source/cmMakefileTargetGenerator.cxx

@@ -1114,7 +1114,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
          << this->Convert(this->LocalGenerator->GetSourceDirectory(),
                           cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
          << " "
-         << this->Convert(this->Makefile->GetCurrentSourceDirectory(),
+         << this->Convert(this->LocalGenerator->GetCurrentSourceDirectory(),
                           cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
          << " "
          << this->Convert(this->LocalGenerator->GetBinaryDirectory(),

+ 1 - 2
Source/cmNinjaTargetGenerator.cxx

@@ -45,8 +45,7 @@ cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
         // We only want to process global targets that live in the home
         // (i.e. top-level) directory.  CMake creates copies of these targets
         // in every directory, which we don't need.
-        cmMakefile *mf = target->Target->GetMakefile();
-        if (strcmp(mf->GetCurrentSourceDirectory(),
+        if (strcmp(target->GetLocalGenerator()->GetCurrentSourceDirectory(),
                    target->GetLocalGenerator()->GetSourceDirectory()) == 0)
           return new cmNinjaUtilityTargetGenerator(target);
         // else fallthrough

+ 1 - 1
Source/cmVisualStudio10TargetGenerator.cxx

@@ -2243,7 +2243,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
 {
   // Look through the sources for AndroidManifest.xml and use
   // its location as the root source directory.
-  std::string rootDir = this->Makefile->GetCurrentSourceDirectory();
+  std::string rootDir = this->LocalGenerator->GetCurrentSourceDirectory();
   {
   std::vector<cmSourceFile const*> extraSources;
   this->GeneratorTarget->GetExtraSources(extraSources, "");