cmGeneratorTarget: Move GetOutputName from cmTarget.

This commit is contained in:
Stephen Kelly 2015-08-04 19:19:50 +02:00
parent 4329a71c12
commit 34c437411d
4 changed files with 55 additions and 55 deletions

View File

@ -266,6 +266,54 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const
return this->Target->GetProperty(prop); return this->Target->GetProperty(prop);
} }
//----------------------------------------------------------------------------
std::string cmGeneratorTarget::GetOutputName(const std::string& config,
bool implib) const
{
std::vector<std::string> props;
std::string type = this->Target->GetOutputTargetType(implib);
std::string configUpper = cmSystemTools::UpperCase(config);
if(!type.empty() && !configUpper.empty())
{
// <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG>
props.push_back(type + "_OUTPUT_NAME_" + configUpper);
}
if(!type.empty())
{
// <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME
props.push_back(type + "_OUTPUT_NAME");
}
if(!configUpper.empty())
{
// OUTPUT_NAME_<CONFIG>
props.push_back("OUTPUT_NAME_" + configUpper);
// <CONFIG>_OUTPUT_NAME
props.push_back(configUpper + "_OUTPUT_NAME");
}
// OUTPUT_NAME
props.push_back("OUTPUT_NAME");
std::string outName;
for(std::vector<std::string>::const_iterator i = props.begin();
i != props.end(); ++i)
{
if (const char* outNameProp = this->Target->GetProperty(*i))
{
outName = outNameProp;
break;
}
}
if (outName.empty())
{
outName = this->GetName();
}
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(outName);
return cge->Evaluate(this->Makefile, config);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::vector<cmSourceFile*> const* std::vector<cmSourceFile*> const*
cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const
@ -922,7 +970,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config,
bool contentOnly) const bool contentOnly) const
{ {
std::string fpath; std::string fpath;
fpath += this->Target->GetOutputName(config, false); fpath += this->GetOutputName(config, false);
fpath += "."; fpath += ".";
const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION");
if (!ext) if (!ext)
@ -949,7 +997,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config,
bool rootDir) const bool rootDir) const
{ {
std::string fpath; std::string fpath;
fpath += this->Target->GetOutputName(config, false); fpath += this->GetOutputName(config, false);
fpath += ".framework"; fpath += ".framework";
if(!rootDir) if(!rootDir)
{ {
@ -2247,7 +2295,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
std::string fw_prefix; std::string fw_prefix;
if(this->Target->IsFrameworkOnApple()) if(this->Target->IsFrameworkOnApple())
{ {
fw_prefix = this->Target->GetOutputName(config, false); fw_prefix = this->GetOutputName(config, false);
fw_prefix += ".framework/"; fw_prefix += ".framework/";
targetPrefix = fw_prefix.c_str(); targetPrefix = fw_prefix.c_str();
targetSuffix = 0; targetSuffix = 0;
@ -2265,7 +2313,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
outPrefix = targetPrefix?targetPrefix:""; outPrefix = targetPrefix?targetPrefix:"";
// Append the target name or property-specified name. // Append the target name or property-specified name.
outBase += this->Target->GetOutputName(config, implib); outBase += this->GetOutputName(config, implib);
// Append the per-configuration postfix. // Append the per-configuration postfix.
outBase += configPostfix?configPostfix:""; outBase += configPostfix?configPostfix:"";

View File

@ -230,6 +230,9 @@ public:
/** Get the path for the MSVC /Fd option for this target. */ /** Get the path for the MSVC /Fd option for this target. */
std::string GetCompilePDBPath(const std::string& config="") const; std::string GetCompilePDBPath(const std::string& config="") const;
// Get the target base name.
std::string GetOutputName(const std::string& config, bool implib) const;
/** /**
* Flags for a given source file as used in this target. Typically assigned * Flags for a given source file as used in this target. Typically assigned
* via SET_TARGET_PROPERTIES when the property is a list of source files. * via SET_TARGET_PROPERTIES when the property is a list of source files.

View File

@ -3662,54 +3662,6 @@ bool cmTarget::UsesDefaultOutputDir(const std::string& config,
return this->ComputeOutputDir(config, implib, dir); return this->ComputeOutputDir(config, implib, dir);
} }
//----------------------------------------------------------------------------
std::string cmTarget::GetOutputName(const std::string& config,
bool implib) const
{
std::vector<std::string> props;
std::string type = this->GetOutputTargetType(implib);
std::string configUpper = cmSystemTools::UpperCase(config);
if(!type.empty() && !configUpper.empty())
{
// <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG>
props.push_back(type + "_OUTPUT_NAME_" + configUpper);
}
if(!type.empty())
{
// <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME
props.push_back(type + "_OUTPUT_NAME");
}
if(!configUpper.empty())
{
// OUTPUT_NAME_<CONFIG>
props.push_back("OUTPUT_NAME_" + configUpper);
// <CONFIG>_OUTPUT_NAME
props.push_back(configUpper + "_OUTPUT_NAME");
}
// OUTPUT_NAME
props.push_back("OUTPUT_NAME");
std::string outName;
for(std::vector<std::string>::const_iterator i = props.begin();
i != props.end(); ++i)
{
if (const char* outNameProp = this->GetProperty(*i))
{
outName = outNameProp;
break;
}
}
if (outName.empty())
{
outName = this->GetName();
}
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(outName);
return cge->Evaluate(this->Makefile, config);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmTarget::GetFrameworkVersion() const std::string cmTarget::GetFrameworkVersion() const
{ {

View File

@ -552,9 +552,6 @@ private:
// Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
const char* GetOutputTargetType(bool implib) const; const char* GetOutputTargetType(bool implib) const;
// Get the target base name.
std::string GetOutputName(const std::string& config, bool implib) const;
std::string GetFullNameImported(const std::string& config, std::string GetFullNameImported(const std::string& config,
bool implib) const; bool implib) const;