Move GetLocationForBuild to cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2014-03-10 16:57:02 +01:00
parent 9f2dca805c
commit dfb025bf12
4 changed files with 46 additions and 41 deletions

View File

@ -539,6 +539,41 @@ bool cmGeneratorTarget::IsImported() const
return this->Target->IsImported();
}
//----------------------------------------------------------------------------
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);

View File

@ -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;

View File

@ -2747,39 +2747,6 @@ const char* cmTarget::ImportedGetLocation(const std::string& config) const
return location.c_str();
}
//----------------------------------------------------------------------------
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
{
@ -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());
}
}

View File

@ -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. */