summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx180
1 files changed, 169 insertions, 11 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 0fdf646..436e5dd 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -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,7 +896,7 @@ 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";
@@ -905,6 +905,20 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config,
//----------------------------------------------------------------------------
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(
const std::string& config) const
{
@@ -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 =