cmGeneratorTarget: Move GetFullName from cmTarget.

Bring GetFullNameInternal with it.
This commit is contained in:
Stephen Kelly 2015-08-04 19:19:48 +02:00
parent 7a460852fa
commit d6bb319b09
8 changed files with 201 additions and 195 deletions

View File

@ -576,7 +576,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const
}
}
location += "/";
location += this->Target->GetFullName("", false);
location += this->GetFullName("", false);
return location.c_str();
}
@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const
std::string prefix;
std::string base;
std::string suffix;
this->Target->GetFullNameInternal(config, false, prefix, base, suffix);
this->GetFullNameInternal(config, false, prefix, base, suffix);
// Check for a per-configuration output directory target property.
std::string configUpper = cmSystemTools::UpperCase(config);
@ -896,13 +896,27 @@ std::string
cmGeneratorTarget::GetAppBundleDirectory(const std::string& config,
bool contentOnly) const
{
std::string fpath = this->Target->GetFullName(config, false);
std::string fpath = this->GetFullName(config, false);
fpath += ".app/Contents";
if(!contentOnly)
fpath += "/MacOS";
return fpath;
}
//----------------------------------------------------------------------------
std::string
cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const
{
if(this->Target->IsImported())
{
return this->Target->GetFullNameImported(config, implib);
}
else
{
return this->GetFullNameInternal(config, implib);
}
}
//----------------------------------------------------------------------------
std::string
cmGeneratorTarget::GetInstallNameDirForBuildTree(
@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix,
const std::string& config,
bool implib) const
{
this->Target->GetFullNameInternal(config, implib, prefix, base, suffix);
this->GetFullNameInternal(config, implib, prefix, base, suffix);
}
//----------------------------------------------------------------------------
@ -1655,7 +1669,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config,
// Add the full name of the target.
if(implib)
{
fpath += this->Target->GetFullName(config, true);
fpath += this->GetFullName(config, true);
}
else if(realname)
{
@ -1663,7 +1677,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config,
}
else
{
fpath += this->Target->GetFullName(config, false);
fpath += this->GetFullName(config, false);
}
return fpath;
}
@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name,
std::string prefix;
std::string base;
std::string suffix;
this->Target->GetFullNameInternal(config, false, prefix, base, suffix);
this->GetFullNameInternal(config, false, prefix, base, suffix);
// The library name.
name = prefix+base+suffix;
@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name,
if(this->GetType() == cmTarget::SHARED_LIBRARY ||
this->GetType() == cmTarget::MODULE_LIBRARY)
{
impName = this->Target->GetFullNameInternal(config, true);
impName = this->GetFullNameInternal(config, true);
}
else
{
@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name,
std::string prefix;
std::string base;
std::string suffix;
this->Target->GetFullNameInternal(config, false, prefix, base, suffix);
this->GetFullNameInternal(config, false, prefix, base, suffix);
// The executable name.
name = prefix+base+suffix;
@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name,
#endif
// The import library name.
impName = this->Target->GetFullNameInternal(config, true);
impName = this->GetFullNameInternal(config, true);
// The program database file name.
pdbName = this->GetPDBName(config);
}
//----------------------------------------------------------------------------
std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config,
bool implib) const
{
std::string prefix;
std::string base;
std::string suffix;
this->GetFullNameInternal(config, implib, prefix, base, suffix);
return prefix+base+suffix;
}
//----------------------------------------------------------------------------
void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
bool implib,
std::string& outPrefix,
std::string& outBase,
std::string& outSuffix) const
{
// Use just the target name for non-main target types.
if(this->GetType() != cmTarget::STATIC_LIBRARY &&
this->GetType() != cmTarget::SHARED_LIBRARY &&
this->GetType() != cmTarget::MODULE_LIBRARY &&
this->GetType() != cmTarget::EXECUTABLE)
{
outPrefix = "";
outBase = this->GetName();
outSuffix = "";
return;
}
// Return an empty name for the import library if this platform
// does not support import libraries.
if(implib &&
!this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
{
outPrefix = "";
outBase = "";
outSuffix = "";
return;
}
// The implib option is only allowed for shared libraries, module
// libraries, and executables.
if(this->GetType() != cmTarget::SHARED_LIBRARY &&
this->GetType() != cmTarget::MODULE_LIBRARY &&
this->GetType() != cmTarget::EXECUTABLE)
{
implib = false;
}
// Compute the full name for main target types.
const char* targetPrefix = (implib
? this->GetProperty("IMPORT_PREFIX")
: this->GetProperty("PREFIX"));
const char* targetSuffix = (implib
? this->GetProperty("IMPORT_SUFFIX")
: this->GetProperty("SUFFIX"));
const char* configPostfix = 0;
if(!config.empty())
{
std::string configProp = cmSystemTools::UpperCase(config);
configProp += "_POSTFIX";
configPostfix = this->GetProperty(configProp);
// Mac application bundles and frameworks have no postfix.
if(configPostfix &&
(this->Target->IsAppBundleOnApple()
|| this->Target->IsFrameworkOnApple()))
{
configPostfix = 0;
}
}
const char* prefixVar = this->Target->GetPrefixVariableInternal(implib);
const char* suffixVar = this->Target->GetSuffixVariableInternal(implib);
// Check for language-specific default prefix and suffix.
std::string ll = this->Target->GetLinkerLanguage(config);
if(!ll.empty())
{
if(!targetSuffix && suffixVar && *suffixVar)
{
std::string langSuff = suffixVar + std::string("_") + ll;
targetSuffix = this->Makefile->GetDefinition(langSuff);
}
if(!targetPrefix && prefixVar && *prefixVar)
{
std::string langPrefix = prefixVar + std::string("_") + ll;
targetPrefix = this->Makefile->GetDefinition(langPrefix);
}
}
// if there is no prefix on the target use the cmake definition
if(!targetPrefix && prefixVar)
{
targetPrefix = this->Makefile->GetSafeDefinition(prefixVar);
}
// if there is no suffix on the target use the cmake definition
if(!targetSuffix && suffixVar)
{
targetSuffix = this->Makefile->GetSafeDefinition(suffixVar);
}
// frameworks have directory prefix but no suffix
std::string fw_prefix;
if(this->Target->IsFrameworkOnApple())
{
fw_prefix = this->Target->GetOutputName(config, false);
fw_prefix += ".framework/";
targetPrefix = fw_prefix.c_str();
targetSuffix = 0;
}
if(this->Target->IsCFBundleOnApple())
{
fw_prefix = this->Target->GetCFBundleDirectory(config, false);
fw_prefix += "/";
targetPrefix = fw_prefix.c_str();
targetSuffix = 0;
}
// Begin the final name with the prefix.
outPrefix = targetPrefix?targetPrefix:"";
// Append the target name or property-specified name.
outBase += this->Target->GetOutputName(config, implib);
// Append the per-configuration postfix.
outBase += configPostfix?configPostfix:"";
// Name shared libraries with their version number on some platforms.
if(const char* soversion = this->GetProperty("SOVERSION"))
{
if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib &&
this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION"))
{
outBase += "-";
outBase += soversion;
}
}
// Append the suffix.
outSuffix = targetSuffix?targetSuffix:"";
}
//----------------------------------------------------------------------------
std::string cmGeneratorTarget::GetPDBName(const std::string& config) const
{
std::string prefix;
std::string base;
std::string suffix;
this->Target->GetFullNameInternal(config, false, prefix, base, suffix);
this->GetFullNameInternal(config, false, prefix, base, suffix);
std::vector<std::string> props;
std::string configUpper =

View File

@ -119,6 +119,11 @@ public:
std::string GetAppBundleDirectory(const std::string& config,
bool contentOnly) const;
/** Get the full name of the target according to the settings in its
makefile. */
std::string GetFullName(const std::string& config="",
bool implib = false) const;
/** Return the install name directory for the target in the
* build tree. For example: "\@rpath/", "\@loader_path/",
* or "/full/path/to/library". */
@ -279,6 +284,12 @@ private:
mutable std::map<std::string, bool> DebugCompatiblePropertiesDone;
std::string GetFullNameInternal(const std::string& config,
bool implib) const;
void GetFullNameInternal(const std::string& config, bool implib,
std::string& outPrefix, std::string& outBase,
std::string& outSuffix) const;
struct CompatibleInterfacesBase
{
std::set<std::string> PropsBool;

View File

@ -2742,7 +2742,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
}
else
{
fullName = cmtarget.GetFullName(defConfig.c_str());
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget);
fullName = gtgt->GetFullName(defConfig.c_str());
}
fileRef->AddAttribute("path", this->CreateString(fullName.c_str()));
fileRef->AddAttribute("refType", this->CreateString("0"));
@ -3688,7 +3689,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
std::string universalFile = universal;
universalFile += *arch;
universalFile += "/";
universalFile += t->GetFullName(configName);
universalFile += gt->GetFullName(configName);
makefileStream << "\t/bin/rm -f "
<<
this->ConvertToRelativeForMake(universalFile.c_str())

View File

@ -1115,10 +1115,12 @@ void cmLocalVisualStudio6Generator
cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str());
if(tgt)
{
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(tgt);
lib = cmSystemTools::GetFilenameWithoutExtension
(tgt->GetFullName().c_str());
(gt->GetFullName().c_str());
libDebug = cmSystemTools::GetFilenameWithoutExtension
(tgt->GetFullName("Debug").c_str());
(gt->GetFullName("Debug").c_str());
lib += ".lib";
libDebug += ".lib";
}
@ -1258,8 +1260,8 @@ void cmLocalVisualStudio6Generator
extraLinkOptionsRelWithDebInfo += targetLinkFlags;
}
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
// Get standard libraries for this language.
if(targetBuilds)
@ -1328,11 +1330,11 @@ void cmLocalVisualStudio6Generator
target.GetType() == cmTarget::SHARED_LIBRARY ||
target.GetType() == cmTarget::MODULE_LIBRARY)
{
outputName = target.GetFullName();
outputNameDebug = target.GetFullName("Debug");
outputNameRelease = target.GetFullName("Release");
outputNameMinSizeRel = target.GetFullName("MinSizeRel");
outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo");
outputName = gt->GetFullName();
outputNameDebug = gt->GetFullName("Debug");
outputNameRelease = gt->GetFullName("Release");
outputNameMinSizeRel = gt->GetFullName("MinSizeRel");
outputNameRelWithDebInfo = gt->GetFullName("RelWithDebInfo");
}
else if(target.GetType() == cmTarget::OBJECT_LIBRARY)
{
@ -1429,10 +1431,10 @@ void cmLocalVisualStudio6Generator
fullPathImpRelease += "/";
fullPathImpMinSizeRel += "/";
fullPathImpRelWithDebInfo += "/";
fullPathImpDebug += target.GetFullName("Debug", true);
fullPathImpRelease += target.GetFullName("Release", true);
fullPathImpMinSizeRel += target.GetFullName("MinSizeRel", true);
fullPathImpRelWithDebInfo += target.GetFullName("RelWithDebInfo", true);
fullPathImpDebug += gt->GetFullName("Debug", true);
fullPathImpRelease += gt->GetFullName("Release", true);
fullPathImpMinSizeRel += gt->GetFullName("MinSizeRel", true);
fullPathImpRelWithDebInfo += gt->GetFullName("RelWithDebInfo", true);
targetImplibFlagDebug = "/implib:";
targetImplibFlagRelease = "/implib:";

View File

@ -803,7 +803,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
if (this->FortranProject)
{
// Intel Fortran >= 15.0 uses TargetName property.
std::string targetNameFull = target.GetFullName(configName);
std::string targetNameFull = gt->GetFullName(configName);
std::string targetName =
cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull);
std::string targetExt =
@ -1107,7 +1107,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
}
case cmTarget::STATIC_LIBRARY:
{
std::string targetNameFull = target.GetFullName(configName);
std::string targetNameFull = gt->GetFullName(configName);
std::string libpath = target.GetDirectory(configName);
libpath += "/";
libpath += targetNameFull;

View File

@ -3586,20 +3586,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName(
return false;
}
//----------------------------------------------------------------------------
std::string cmTarget::GetFullName(const std::string& config,
bool implib) const
{
if(this->IsImported())
{
return this->GetFullNameImported(config, implib);
}
else
{
return this->GetFullNameInternal(config, implib);
}
}
//----------------------------------------------------------------------------
std::string
cmTarget::GetFullNameImported(const std::string& config, bool implib) const
@ -3625,148 +3611,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const
return result;
}
//----------------------------------------------------------------------------
std::string
cmTarget::GetFullNameInternal(const std::string& config, bool implib) const
{
std::string prefix;
std::string base;
std::string suffix;
this->GetFullNameInternal(config, implib, prefix, base, suffix);
return prefix+base+suffix;
}
//----------------------------------------------------------------------------
void cmTarget::GetFullNameInternal(const std::string& config,
bool implib,
std::string& outPrefix,
std::string& outBase,
std::string& outSuffix) const
{
// Use just the target name for non-main target types.
if(this->GetType() != cmTarget::STATIC_LIBRARY &&
this->GetType() != cmTarget::SHARED_LIBRARY &&
this->GetType() != cmTarget::MODULE_LIBRARY &&
this->GetType() != cmTarget::EXECUTABLE)
{
outPrefix = "";
outBase = this->GetName();
outSuffix = "";
return;
}
// Return an empty name for the import library if this platform
// does not support import libraries.
if(implib &&
!this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
{
outPrefix = "";
outBase = "";
outSuffix = "";
return;
}
// The implib option is only allowed for shared libraries, module
// libraries, and executables.
if(this->GetType() != cmTarget::SHARED_LIBRARY &&
this->GetType() != cmTarget::MODULE_LIBRARY &&
this->GetType() != cmTarget::EXECUTABLE)
{
implib = false;
}
// Compute the full name for main target types.
const char* targetPrefix = (implib
? this->GetProperty("IMPORT_PREFIX")
: this->GetProperty("PREFIX"));
const char* targetSuffix = (implib
? this->GetProperty("IMPORT_SUFFIX")
: this->GetProperty("SUFFIX"));
const char* configPostfix = 0;
if(!config.empty())
{
std::string configProp = cmSystemTools::UpperCase(config);
configProp += "_POSTFIX";
configPostfix = this->GetProperty(configProp);
// Mac application bundles and frameworks have no postfix.
if(configPostfix &&
(this->IsAppBundleOnApple() || this->IsFrameworkOnApple()))
{
configPostfix = 0;
}
}
const char* prefixVar = this->GetPrefixVariableInternal(implib);
const char* suffixVar = this->GetSuffixVariableInternal(implib);
// Check for language-specific default prefix and suffix.
std::string ll = this->GetLinkerLanguage(config);
if(!ll.empty())
{
if(!targetSuffix && suffixVar && *suffixVar)
{
std::string langSuff = suffixVar + std::string("_") + ll;
targetSuffix = this->Makefile->GetDefinition(langSuff);
}
if(!targetPrefix && prefixVar && *prefixVar)
{
std::string langPrefix = prefixVar + std::string("_") + ll;
targetPrefix = this->Makefile->GetDefinition(langPrefix);
}
}
// if there is no prefix on the target use the cmake definition
if(!targetPrefix && prefixVar)
{
targetPrefix = this->Makefile->GetSafeDefinition(prefixVar);
}
// if there is no suffix on the target use the cmake definition
if(!targetSuffix && suffixVar)
{
targetSuffix = this->Makefile->GetSafeDefinition(suffixVar);
}
// frameworks have directory prefix but no suffix
std::string fw_prefix;
if(this->IsFrameworkOnApple())
{
fw_prefix = this->GetOutputName(config, false);
fw_prefix += ".framework/";
targetPrefix = fw_prefix.c_str();
targetSuffix = 0;
}
if(this->IsCFBundleOnApple())
{
fw_prefix = this->GetCFBundleDirectory(config, false);
fw_prefix += "/";
targetPrefix = fw_prefix.c_str();
targetSuffix = 0;
}
// Begin the final name with the prefix.
outPrefix = targetPrefix?targetPrefix:"";
// Append the target name or property-specified name.
outBase += this->GetOutputName(config, implib);
// Append the per-configuration postfix.
outBase += configPostfix?configPostfix:"";
// Name shared libraries with their version number on some platforms.
if(const char* soversion = this->GetProperty("SOVERSION"))
{
if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib &&
this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION"))
{
outBase += "-";
outBase += soversion;
}
}
// Append the suffix.
outSuffix = targetSuffix?targetSuffix:"";
}
//----------------------------------------------------------------------------
void cmTarget::ComputeVersionedName(std::string& vName,
std::string const& prefix,

View File

@ -368,11 +368,6 @@ public:
///! Return the preferred linker language for this target
std::string GetLinkerLanguage(const std::string& config = "") const;
/** Get the full name of the target according to the settings in its
makefile. */
std::string GetFullName(const std::string& config="",
bool implib = false) const;
/** Whether this library has \@rpath and platform supports it. */
bool HasMacOSXRpathInstallNameDir(const std::string& config) const;
@ -575,11 +570,6 @@ private:
const char* GetSuffixVariableInternal(bool implib) const;
const char* GetPrefixVariableInternal(bool implib) const;
std::string GetFullNameInternal(const std::string& config,
bool implib) const;
void GetFullNameInternal(const std::string& config, bool implib,
std::string& outPrefix, std::string& outBase,
std::string& outSuffix) const;
// Use a makefile variable to set a default for the given property.
// If the variable is not defined use the given default instead.

View File

@ -1774,7 +1774,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
else
{
outDir = this->Target->GetDirectory(config->c_str()) + "/";
targetNameFull = this->Target->GetFullName(config->c_str());
targetNameFull = this->GeneratorTarget->GetFullName(config->c_str());
}
this->ConvertToWindowsSlash(intermediateDir);
this->ConvertToWindowsSlash(outDir);