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 += "/";
location += this->Target->GetFullName("", false); location += this->GetFullName("", false);
return location.c_str(); return location.c_str();
} }
@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const
std::string prefix; std::string prefix;
std::string base; std::string base;
std::string suffix; 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. // Check for a per-configuration output directory target property.
std::string configUpper = cmSystemTools::UpperCase(config); std::string configUpper = cmSystemTools::UpperCase(config);
@ -896,13 +896,27 @@ std::string
cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, cmGeneratorTarget::GetAppBundleDirectory(const std::string& config,
bool contentOnly) const bool contentOnly) const
{ {
std::string fpath = this->Target->GetFullName(config, false); std::string fpath = this->GetFullName(config, false);
fpath += ".app/Contents"; fpath += ".app/Contents";
if(!contentOnly) if(!contentOnly)
fpath += "/MacOS"; fpath += "/MacOS";
return fpath; 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 std::string
cmGeneratorTarget::GetInstallNameDirForBuildTree( cmGeneratorTarget::GetInstallNameDirForBuildTree(
@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix,
const std::string& config, const std::string& config,
bool implib) const 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. // Add the full name of the target.
if(implib) if(implib)
{ {
fpath += this->Target->GetFullName(config, true); fpath += this->GetFullName(config, true);
} }
else if(realname) else if(realname)
{ {
@ -1663,7 +1677,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config,
} }
else else
{ {
fpath += this->Target->GetFullName(config, false); fpath += this->GetFullName(config, false);
} }
return fpath; return fpath;
} }
@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name,
std::string prefix; std::string prefix;
std::string base; std::string base;
std::string suffix; std::string suffix;
this->Target->GetFullNameInternal(config, false, prefix, base, suffix); this->GetFullNameInternal(config, false, prefix, base, suffix);
// The library name. // The library name.
name = prefix+base+suffix; name = prefix+base+suffix;
@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name,
if(this->GetType() == cmTarget::SHARED_LIBRARY || if(this->GetType() == cmTarget::SHARED_LIBRARY ||
this->GetType() == cmTarget::MODULE_LIBRARY) this->GetType() == cmTarget::MODULE_LIBRARY)
{ {
impName = this->Target->GetFullNameInternal(config, true); impName = this->GetFullNameInternal(config, true);
} }
else else
{ {
@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name,
std::string prefix; std::string prefix;
std::string base; std::string base;
std::string suffix; std::string suffix;
this->Target->GetFullNameInternal(config, false, prefix, base, suffix); this->GetFullNameInternal(config, false, prefix, base, suffix);
// The executable name. // The executable name.
name = prefix+base+suffix; name = prefix+base+suffix;
@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name,
#endif #endif
// The import library name. // The import library name.
impName = this->Target->GetFullNameInternal(config, true); impName = this->GetFullNameInternal(config, true);
// The program database file name. // The program database file name.
pdbName = this->GetPDBName(config); 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 cmGeneratorTarget::GetPDBName(const std::string& config) const
{ {
std::string prefix; std::string prefix;
std::string base; std::string base;
std::string suffix; std::string suffix;
this->Target->GetFullNameInternal(config, false, prefix, base, suffix); this->GetFullNameInternal(config, false, prefix, base, suffix);
std::vector<std::string> props; std::vector<std::string> props;
std::string configUpper = std::string configUpper =

View File

@ -119,6 +119,11 @@ public:
std::string GetAppBundleDirectory(const std::string& config, std::string GetAppBundleDirectory(const std::string& config,
bool contentOnly) const; 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 /** Return the install name directory for the target in the
* build tree. For example: "\@rpath/", "\@loader_path/", * build tree. For example: "\@rpath/", "\@loader_path/",
* or "/full/path/to/library". */ * or "/full/path/to/library". */
@ -279,6 +284,12 @@ private:
mutable std::map<std::string, bool> DebugCompatiblePropertiesDone; 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 struct CompatibleInterfacesBase
{ {
std::set<std::string> PropsBool; std::set<std::string> PropsBool;

View File

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

View File

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

View File

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

View File

@ -3586,20 +3586,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName(
return false; 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 std::string
cmTarget::GetFullNameImported(const std::string& config, bool implib) const cmTarget::GetFullNameImported(const std::string& config, bool implib) const
@ -3625,148 +3611,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const
return result; 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, void cmTarget::ComputeVersionedName(std::string& vName,
std::string const& prefix, std::string const& prefix,

View File

@ -368,11 +368,6 @@ public:
///! Return the preferred linker language for this target ///! Return the preferred linker language for this target
std::string GetLinkerLanguage(const std::string& config = "") const; 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. */ /** Whether this library has \@rpath and platform supports it. */
bool HasMacOSXRpathInstallNameDir(const std::string& config) const; bool HasMacOSXRpathInstallNameDir(const std::string& config) const;
@ -575,11 +570,6 @@ private:
const char* GetSuffixVariableInternal(bool implib) const; const char* GetSuffixVariableInternal(bool implib) const;
const char* GetPrefixVariableInternal(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. // Use a makefile variable to set a default for the given property.
// If the variable is not defined use the given default instead. // If the variable is not defined use the given default instead.

View File

@ -1774,7 +1774,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
else else
{ {
outDir = this->Target->GetDirectory(config->c_str()) + "/"; 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(intermediateDir);
this->ConvertToWindowsSlash(outDir); this->ConvertToWindowsSlash(outDir);