cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget.

This commit is contained in:
Stephen Kelly 2015-08-04 19:19:48 +02:00
parent d6bb319b09
commit 6da99de323
5 changed files with 57 additions and 56 deletions

View File

@ -903,6 +903,48 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config,
return fpath; return fpath;
} }
//----------------------------------------------------------------------------
std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config,
bool contentOnly) const
{
std::string fpath;
fpath += this->Target->GetOutputName(config, false);
fpath += ".";
const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION");
if (!ext)
{
if (this->Target->IsXCTestOnApple())
{
ext = "xctest";
}
else
{
ext = "bundle";
}
}
fpath += ext;
fpath += "/Contents";
if(!contentOnly)
fpath += "/MacOS";
return fpath;
}
//----------------------------------------------------------------------------
std::string
cmGeneratorTarget::GetFrameworkDirectory(const std::string& config,
bool rootDir) const
{
std::string fpath;
fpath += this->Target->GetOutputName(config, false);
fpath += ".framework";
if(!rootDir)
{
fpath += "/Versions/";
fpath += this->Target->GetFrameworkVersion();
}
return fpath;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const
@ -1007,11 +1049,11 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base,
} }
if(this->Target->IsFrameworkOnApple()) if(this->Target->IsFrameworkOnApple())
{ {
fpath += this->Target->GetFrameworkDirectory(config, contentOnly); fpath += this->GetFrameworkDirectory(config, contentOnly);
} }
if(this->Target->IsCFBundleOnApple()) if(this->Target->IsCFBundleOnApple())
{ {
fpath += this->Target->GetCFBundleDirectory(config, contentOnly); fpath += this->GetCFBundleDirectory(config, contentOnly);
} }
return fpath; return fpath;
} }
@ -1982,7 +2024,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
if(this->Target->IsCFBundleOnApple()) if(this->Target->IsCFBundleOnApple())
{ {
fw_prefix = this->Target->GetCFBundleDirectory(config, false); fw_prefix = this->GetCFBundleDirectory(config, false);
fw_prefix += "/"; fw_prefix += "/";
targetPrefix = fw_prefix.c_str(); targetPrefix = fw_prefix.c_str();
targetSuffix = 0; targetSuffix = 0;

View File

@ -124,6 +124,14 @@ public:
std::string GetFullName(const std::string& config="", std::string GetFullName(const std::string& config="",
bool implib = false) const; bool implib = false) const;
/** @return the Mac framework directory without the base. */
std::string GetFrameworkDirectory(const std::string& config,
bool rootDir) const;
/** @return the Mac CFBundle directory without the base */
std::string GetCFBundleDirectory(const std::string& config,
bool contentOnly) 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". */

View File

@ -77,11 +77,11 @@ void cmOSXBundleGenerator::CreateFramework(
// Compute the location of the top-level foo.framework directory. // Compute the location of the top-level foo.framework directory.
std::string contentdir = outpath + "/" + std::string contentdir = outpath + "/" +
this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); this->GT->GetFrameworkDirectory(this->ConfigName, true);
contentdir += "/"; contentdir += "/";
std::string newoutpath = outpath + "/" + std::string newoutpath = outpath + "/" +
this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); this->GT->GetFrameworkDirectory(this->ConfigName, false);
std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); std::string frameworkVersion = this->GT->Target->GetFrameworkVersion();
@ -172,14 +172,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
// Compute bundle directory names. // Compute bundle directory names.
std::string out = root; std::string out = root;
out += "/"; out += "/";
out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); out += this->GT->GetCFBundleDirectory(this->ConfigName, false);
cmSystemTools::MakeDirectory(out.c_str()); cmSystemTools::MakeDirectory(out.c_str());
this->Makefile->AddCMakeOutputFile(out); this->Makefile->AddCMakeOutputFile(out);
// Configure the Info.plist file. Note that it needs the executable name // Configure the Info.plist file. Note that it needs the executable name
// to be set. // to be set.
std::string plist = root + "/" + std::string plist = root + "/" +
this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); this->GT->GetCFBundleDirectory(this->ConfigName, true);
plist += "/Info.plist"; plist += "/Info.plist";
std::string name = cmSystemTools::GetFilenameName(targetName); std::string name = cmSystemTools::GetFilenameName(targetName);
this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target,

View File

@ -5125,47 +5125,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const
return lib; return lib;
} }
//----------------------------------------------------------------------------
std::string cmTarget::GetFrameworkDirectory(const std::string& config,
bool rootDir) const
{
std::string fpath;
fpath += this->GetOutputName(config, false);
fpath += ".framework";
if(!rootDir)
{
fpath += "/Versions/";
fpath += this->GetFrameworkVersion();
}
return fpath;
}
//----------------------------------------------------------------------------
std::string cmTarget::GetCFBundleDirectory(const std::string& config,
bool contentOnly) const
{
std::string fpath;
fpath += this->GetOutputName(config, false);
fpath += ".";
const char *ext = this->GetProperty("BUNDLE_EXTENSION");
if (!ext)
{
if (this->IsXCTestOnApple())
{
ext = "xctest";
}
else
{
ext = "bundle";
}
}
fpath += ext;
fpath += "/Contents";
if(!contentOnly)
fpath += "/MacOS";
return fpath;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTargetInternalPointer::cmTargetInternalPointer() cmTargetInternalPointer::cmTargetInternalPointer()
{ {

View File

@ -460,14 +460,6 @@ public:
/** @return whether this target have a well defined output file name. */ /** @return whether this target have a well defined output file name. */
bool HaveWellDefinedOutputFiles() const; bool HaveWellDefinedOutputFiles() const;
/** @return the Mac framework directory without the base. */
std::string GetFrameworkDirectory(const std::string& config,
bool rootDir) const;
/** @return the Mac CFBundle directory without the base */
std::string GetCFBundleDirectory(const std::string& config,
bool contentOnly) const;
std::vector<std::string> GetIncludeDirectories( std::vector<std::string> GetIncludeDirectories(
const std::string& config, const std::string& config,
const std::string& language) const; const std::string& language) const;