From dfb025bf126080f6bb209f6f40ff909c4f5c5c97 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 10 Mar 2014 16:57:02 +0100 Subject: Move GetLocationForBuild to cmGeneratorTarget. --- Source/cmGeneratorTarget.cxx | 37 ++++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 5 +++++ Source/cmTarget.cxx | 40 +++++----------------------------------- Source/cmTarget.h | 5 ----- 4 files changed, 46 insertions(+), 41 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9fe7922..efb414e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -540,6 +540,41 @@ bool cmGeneratorTarget::IsImported() const } //---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetLocationForBuild() const +{ + static std::string location; + if(this->IsImported()) + { + location = this->Target->ImportedGetFullPath("", false); + return location.c_str(); + } + + // Now handle the deprecated build-time configuration location. + location = this->Target->GetDirectory(); + const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR"); + if(cfgid && strcmp(cfgid, ".") != 0) + { + location += "/"; + location += cfgid; + } + + if(this->Target->IsAppBundleOnApple()) + { + std::string macdir = this->Target->BuildMacContentDirectory("", "", + false); + if(!macdir.empty()) + { + location += "/"; + location += macdir; + } + } + location += "/"; + location += this->Target->GetFullName("", false); + return location.c_str(); +} + + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const { @@ -867,7 +902,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) { // This is really only for compatibility so we do not need to // worry about configuration names and output names. - std::string tLocation = t->Target->GetLocationForBuild(); + std::string tLocation = t->GetLocationForBuild(); tLocation = cmSystemTools::GetFilenamePath(tLocation); std::string depLocation = cmSystemTools::GetFilenamePath(dep); depLocation = cmSystemTools::CollapseFullPath(depLocation); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 060007f..72c5706 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -31,6 +31,11 @@ public: bool IsImported() const; const char *GetLocation(const std::string& config) const; + /** Get the location of the target in the build tree with a placeholder + referencing the configuration in the native build system. This + location is suitable for use as the LOCATION target property. */ + const char* GetLocationForBuild() const; + int GetType() const; std::string GetName() const; const char *GetProperty(const std::string& prop) const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9122daf..d880cc0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2748,39 +2748,6 @@ const char* cmTarget::ImportedGetLocation(const std::string& config) const } //---------------------------------------------------------------------------- -const char* cmTarget::GetLocationForBuild() const -{ - static std::string location; - if(this->IsImported()) - { - location = this->ImportedGetFullPath("", false); - return location.c_str(); - } - - // Now handle the deprecated build-time configuration location. - location = this->GetDirectory(); - const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR"); - if(cfgid && strcmp(cfgid, ".") != 0) - { - location += "/"; - location += cfgid; - } - - if(this->IsAppBundleOnApple()) - { - std::string macdir = this->BuildMacContentDirectory("", "", false); - if(!macdir.empty()) - { - location += "/"; - location += macdir; - } - } - location += "/"; - location += this->GetFullName("", false); - return location.c_str(); -} - -//---------------------------------------------------------------------------- void cmTarget::GetTargetVersion(int& major, int& minor) const { int patch; @@ -2922,8 +2889,11 @@ const char *cmTarget::GetProperty(const std::string& prop, // cannot take into account the per-configuration name of the // target because the configuration type may not be known at // CMake time. - this->Properties.SetProperty( - propLOCATION, this->GetLocationForBuild()); + cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator(); + gg->CreateGenerationObjects(); + cmGeneratorTarget* gt = gg->GetGeneratorTarget(this); + this->Properties.SetProperty(propLOCATION, + gt->GetLocationForBuild()); } } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4d419ee..eb0bf91 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -376,11 +376,6 @@ public: const char* ImportedGetLocation(const std::string& config) const; - /** Get the location of the target in the build tree with a placeholder - referencing the configuration in the native build system. This - location is suitable for use as the LOCATION target property. */ - const char* GetLocationForBuild() const; - /** Get the target major and minor version numbers interpreted from the VERSION property. Version 0 is returned if the property is not set or cannot be parsed. */ -- cgit v0.12