From cd43433de56ab31269a076fb2b2ace8babaa107d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 12 Mar 2014 21:09:20 +0100 Subject: cmGlobalGenerator: Extract a ComputeTargetObjectDirectory interface. Make it public for future external calls. --- Source/cmGlobalGenerator.cxx | 6 ++++++ Source/cmGlobalGenerator.h | 2 ++ Source/cmGlobalNinjaGenerator.cxx | 27 ++++++++++++++++----------- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 27 +++++++++++++++++---------- Source/cmGlobalUnixMakefileGenerator3.h | 1 + Source/cmGlobalVisualStudioGenerator.cxx | 7 ++++++- Source/cmGlobalVisualStudioGenerator.h | 1 + Source/cmGlobalXCodeGenerator.cxx | 5 +++++ Source/cmGlobalXCodeGenerator.h | 1 + 10 files changed, 56 insertions(+), 23 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b95ff81..c9ae799 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1449,6 +1449,7 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects() continue; } cmGeneratorTarget* gt = ti->second; + this->ComputeTargetObjectDirectory(gt); gt->LookupObjectLibraries(); this->ComputeTargetObjects(gt); } @@ -1520,6 +1521,11 @@ void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget*) const // Implemented in generator subclasses that need this. } +//---------------------------------------------------------------------------- +void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const +{ +} + void cmGlobalGenerator::CheckLocalGenerators() { std::map notFoundMap; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 91e71a8..ed07b10 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -323,6 +323,8 @@ public: GetExportedTargetsFile(const std::string &filename) const; void AddCMP0042WarnTarget(const std::string& target); + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; + protected: typedef std::vector GeneratorVector; // for a project collect all its targets by following depend diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0a05f5a..686414d 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -634,16 +634,6 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const // TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl. void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const { - cmTarget* target = gt->Target; - - // Compute full path to object file directory for this target. - std::string dir_max; - dir_max += gt->Makefile->GetCurrentOutputDirectory(); - dir_max += "/"; - dir_max += gt->LocalGenerator->GetTargetDirectory(*target); - dir_max += "/"; - gt->ObjectDirectory = dir_max; - std::vector objectSources; gt->GetObjectSources(objectSources); // Compute the name of each object file. @@ -653,12 +643,27 @@ void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const { cmSourceFile* sf = *si; std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, dir_max); + ->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); gt->AddObject(sf, objectName); } } //---------------------------------------------------------------------------- +void cmGlobalNinjaGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const +{ + cmTarget* target = gt->Target; + + // Compute full path to object file directory for this target. + std::string dir_max; + dir_max += gt->Makefile->GetCurrentOutputDirectory(); + dir_max += "/"; + dir_max += gt->LocalGenerator->GetTargetDirectory(*target); + dir_max += "/"; + gt->ObjectDirectory = dir_max; +} + +//---------------------------------------------------------------------------- // Private methods void cmGlobalNinjaGenerator::OpenBuildFileStream() diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 7725cf3..e3a22e5 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -299,7 +299,7 @@ public: void AddTargetAlias(const std::string& alias, cmTarget* target); - + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: /// Overloaded methods. diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 0e03e89..f9ec0a9 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -108,15 +108,6 @@ void cmGlobalUnixMakefileGenerator3 ::ComputeTargetObjects(cmGeneratorTarget* gt) const { - cmTarget* target = gt->Target; - // Compute full path to object file directory for this target. - std::string dir_max; - dir_max += gt->Makefile->GetCurrentOutputDirectory(); - dir_max += "/"; - dir_max += gt->LocalGenerator->GetTargetDirectory(*target); - dir_max += "/"; - gt->ObjectDirectory = dir_max; - std::vector objectSources; gt->GetObjectSources(objectSources); // Compute the name of each object file. @@ -126,11 +117,27 @@ cmGlobalUnixMakefileGenerator3 { cmSourceFile* sf = *si; std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, dir_max); + ->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); gt->AddObject(sf, objectName); } } +//---------------------------------------------------------------------------- +void +cmGlobalUnixMakefileGenerator3 +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const +{ + cmTarget* target = gt->Target; + + // Compute full path to object file directory for this target. + std::string dir_max; + dir_max += gt->Makefile->GetCurrentOutputDirectory(); + dir_max += "/"; + dir_max += gt->LocalGenerator->GetTargetDirectory(*target); + dir_max += "/"; + gt->ObjectDirectory = dir_max; +} + void cmGlobalUnixMakefileGenerator3::Configure() { // Initialize CMAKE_EDIT_COMMAND cache entry. diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 8115176..42453f2 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -128,6 +128,7 @@ public: /** Does the make tool tolerate .NOTPARALLEL? */ virtual bool AllowNotParallel() const { return true; } + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: void WriteMainMakefile2(); void WriteMainCMakefile(); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 69c893c..f3cba5a 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -159,10 +159,15 @@ cmGlobalVisualStudioGenerator } gt->AddObject(sf, objectName); } +} +//---------------------------------------------------------------------------- +void cmGlobalVisualStudioGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const +{ std::string dir = gt->Makefile->GetCurrentOutputDirectory(); dir += "/"; - std::string tgtDir = lg->GetTargetDirectory(*gt->Target); + std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(*gt->Target); if(!tgtDir.empty()) { dir += tgtDir; diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 7e8dcf8..f957056 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -88,6 +88,7 @@ public: virtual std::string ExpandCFGIntDir(const std::string& str, const std::string& config) const; + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: // Does this VS version link targets to each other if there are // dependencies in the SLN file? This was done for VS versions diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 36196a2..6c12040 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3964,7 +3964,12 @@ cmGlobalXCodeGenerator gt->AddObject(sf, objectName); } +} +//---------------------------------------------------------------------------- +void cmGlobalXCodeGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const +{ const char* configName = this->GetCMakeCFGIntDir(); std::string dir = this->GetObjectsNormalDirectory( "$(PROJECT_NAME)", configName, gt->Target); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index be81cdc..f9dd58f 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -204,6 +204,7 @@ private: std::vector const& defines, bool dflag = false); + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: virtual const char* GetInstallTargetName() const { return "install"; } virtual const char* GetPackageTargetName() const { return "package"; } -- cgit v0.12