diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a26a90f61..4e4970dcc 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -67,7 +67,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, this->Configured = false; this->EmitUniversalBinaryFlags = true; this->RelativePathsConfigured = false; - this->PathConversionsSetup = false; this->BackwardsCompatibility = 0; this->BackwardsCompatibilityFinal = false; } @@ -196,22 +195,6 @@ void cmLocalGenerator::ReadInputFile() this->Makefile->ProcessBuildsystemFile(currentStart.c_str()); } -void cmLocalGenerator::SetupPathConversions() -{ - // Setup the current output directory components for use by - // Convert - std::string outdir; - - outdir = cmSystemTools::CollapseFullPath( - this->StateSnapshot.GetCurrentSourceDirectory()); - cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents); - - outdir = cmSystemTools::CollapseFullPath - (this->StateSnapshot.GetCurrentBinaryDirectory()); - cmSystemTools::SplitPath(outdir, - this->StartOutputDirectoryComponents); -} - void cmLocalGenerator::ConfigureFinalPass() { this->Makefile->ConfigureFinalPass(); @@ -2698,13 +2681,6 @@ std::string cmLocalGenerator::Convert(const std::string& source, OutputFormat output, bool optional) { - // Make sure the relative path conversion components are set. - if(!this->PathConversionsSetup) - { - this->SetupPathConversions(); - this->PathConversionsSetup = true; - } - // Convert the path to a relative path. std::string result = source; @@ -2719,20 +2695,18 @@ std::string cmLocalGenerator::Convert(const std::string& source, break; case START: //result = cmSystemTools::CollapseFullPath(result.c_str()); - result = this->ConvertToRelativePath(this->StartDirectoryComponents, - result); + result = this->ConvertToRelativePath( + this->StateSnapshot.GetCurrentSourceDirectoryComponents(), result); break; case HOME_OUTPUT: //result = cmSystemTools::CollapseFullPath(result.c_str()); - result = - this->ConvertToRelativePath( - this->GetState()->GetBinaryDirectoryComponents(), result); + result = this->ConvertToRelativePath( + this->GetState()->GetBinaryDirectoryComponents(), result); break; case START_OUTPUT: //result = cmSystemTools::CollapseFullPath(result.c_str()); - result = - this->ConvertToRelativePath(this->StartOutputDirectoryComponents, - result); + result = this->ConvertToRelativePath( + this->StateSnapshot.GetCurrentBinaryDirectoryComponents(), result); break; case FULL: result = cmSystemTools::CollapseFullPath(result); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index f08c97308..e4d4444c8 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -443,7 +443,6 @@ protected: void ConfigureRelativePaths(); std::string FindRelativePathTopSource(); std::string FindRelativePathTopBinary(); - void SetupPathConversions(); virtual std::string ConvertToLinkReference(std::string const& lib, OutputFormat format = SHELL); @@ -458,8 +457,6 @@ protected: cmMakefile *Makefile; cmState::Snapshot StateSnapshot; cmGlobalGenerator *GlobalGenerator; - std::vector StartDirectoryComponents; - std::vector StartOutputDirectoryComponents; cmLocalGenerator* Parent; std::vector Children; std::map UniqueObjectNamesMap; @@ -484,7 +481,6 @@ protected: std::string RelativePathTopSource; std::string RelativePathTopBinary; bool RelativePathsConfigured; - bool PathConversionsSetup; cmIML_INT_uint64_t BackwardsCompatibility; bool BackwardsCompatibilityFinal; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index aa690dc56..27a36bce2 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -197,6 +197,8 @@ void cmState::Initialize() this->Locations.clear(); this->OutputLocations.clear(); this->ParentPositions.clear(); + this->CurrentSourceDirectoryComponents.clear(); + this->CurrentBinaryDirectoryComponents.clear(); this->CreateSnapshot(Snapshot()); this->DefineProperty @@ -500,6 +502,10 @@ cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot) this->ParentPositions.push_back(originSnapshot.Position); this->Locations.resize(this->Locations.size() + 1); this->OutputLocations.resize(this->OutputLocations.size() + 1); + this->CurrentSourceDirectoryComponents.resize( + this->CurrentSourceDirectoryComponents.size() + 1); + this->CurrentBinaryDirectoryComponents.resize( + this->CurrentBinaryDirectoryComponents.size() + 1); return cmState::Snapshot(this, pos); } @@ -523,6 +529,10 @@ void cmState::Snapshot::SetCurrentSourceDirectory(std::string const& dir) this->State->Locations[this->Position]); this->State->Locations[this->Position] = cmSystemTools::CollapseFullPath(this->State->Locations[this->Position]); + + cmSystemTools::SplitPath( + this->State->Locations[this->Position], + this->State->CurrentSourceDirectoryComponents[this->Position]); } const char* cmState::Snapshot::GetCurrentBinaryDirectory() const @@ -539,6 +549,22 @@ void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir) this->State->OutputLocations[this->Position] = cmSystemTools::CollapseFullPath( this->State->OutputLocations[this->Position]); + + cmSystemTools::SplitPath( + this->State->OutputLocations[this->Position], + this->State->CurrentBinaryDirectoryComponents[this->Position]); +} + +std::vector const& +cmState::Snapshot::GetCurrentSourceDirectoryComponents() +{ + return this->State->CurrentSourceDirectoryComponents[this->Position]; +} + +std::vector const& +cmState::Snapshot::GetCurrentBinaryDirectoryComponents() +{ + return this->State->CurrentBinaryDirectoryComponents[this->Position]; } bool cmState::Snapshot::IsValid() const diff --git a/Source/cmState.h b/Source/cmState.h index 956b4f487..faf0739a1 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -36,6 +36,9 @@ public: const char* GetCurrentBinaryDirectory() const; void SetCurrentBinaryDirectory(std::string const& dir); + std::vector const& GetCurrentSourceDirectoryComponents(); + std::vector const& GetCurrentBinaryDirectoryComponents(); + bool IsValid() const; Snapshot GetParent() const; @@ -136,6 +139,9 @@ private: std::vector OutputLocations; std::vector ParentPositions; + std::vector > CurrentSourceDirectoryComponents; + std::vector > CurrentBinaryDirectoryComponents; + std::vector SourceDirectoryComponents; std::vector BinaryDirectoryComponents; std::string SourceDirectory;