OS X: Fix getting of CFBundle LOCATION property.

This fixes bug #13797.
The kinds of changes applied in 373faae5 for frameworks are now
applied to CFBundle.  The prefix and suffix for CFBundles are
now handled in cmTarget::GetFullNameInternal.
This commit is contained in:
Clinton Stimpson 2013-06-01 22:47:18 -06:00
parent 373faae5e1
commit 483e208482
8 changed files with 29 additions and 51 deletions

View File

@ -351,21 +351,7 @@ cmExportInstallFileGenerator
prop += suffix; prop += suffix;
// Append the installed file name. // Append the installed file name.
if(target->IsCFBundleOnApple()) if(target->IsAppBundleOnApple())
{
const char *ext = target->GetProperty("BUNDLE_EXTENSION");
if (!ext)
{
ext = "bundle";
}
value += itgen->GetInstallFilename(target, config);
value += ".";
value += ext;
value += "/";
value += itgen->GetInstallFilename(target, config);
}
else if(target->IsAppBundleOnApple())
{ {
value += itgen->GetInstallFilename(target, config); value += itgen->GetInstallFilename(target, config);
value += ".app/Contents/MacOS/"; value += ".app/Contents/MacOS/";

View File

@ -746,12 +746,6 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
} }
} }
if(cmtarget.IsCFBundleOnApple())
{
cmtarget.SetProperty("PREFIX", "");
cmtarget.SetProperty("SUFFIX", "");
}
// Add the fileRef to the top level Resources group/folder if it is not // Add the fileRef to the top level Resources group/folder if it is not
// already there. // already there.
// //
@ -1823,7 +1817,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
pndir = target.GetDirectory(configName); pndir = target.GetDirectory(configName);
} }
if(target.IsFrameworkOnApple()) if(target.IsFrameworkOnApple() || target.IsCFBundleOnApple())
{ {
pnprefix = ""; pnprefix = "";
} }

View File

@ -24,8 +24,6 @@ cmMakefileLibraryTargetGenerator
::cmMakefileLibraryTargetGenerator(cmTarget* target): ::cmMakefileLibraryTargetGenerator(cmTarget* target):
cmMakefileTargetGenerator(target) cmMakefileTargetGenerator(target)
{ {
cmOSXBundleGenerator::PrepareTargetProperties(this->Target);
this->CustomCommandDriver = OnDepends; this->CustomCommandDriver = OnDepends;
this->Target->GetLibraryNames( this->Target->GetLibraryNames(
this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameOut, this->TargetNameSO, this->TargetNameReal,

View File

@ -36,8 +36,6 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
, TargetNamePDB() , TargetNamePDB()
, TargetLinkLanguage(0) , TargetLinkLanguage(0)
{ {
cmOSXBundleGenerator::PrepareTargetProperties(target);
this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
if (target->GetType() == cmTarget::EXECUTABLE) if (target->GetType() == cmTarget::EXECUTABLE)
target->GetExecutableNames(this->TargetNameOut, target->GetExecutableNames(this->TargetNameOut,

View File

@ -16,15 +16,6 @@
#include <cassert> #include <cassert>
void cmOSXBundleGenerator::PrepareTargetProperties(cmTarget* target)
{
if(target->IsCFBundleOnApple())
{
target->SetProperty("PREFIX", "");
target->SetProperty("SUFFIX", "");
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmOSXBundleGenerator:: cmOSXBundleGenerator::
cmOSXBundleGenerator(cmTarget* target, cmOSXBundleGenerator(cmTarget* target,
@ -173,31 +164,27 @@ void cmOSXBundleGenerator::CreateFramework(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
std::string& outpath) const std::string& root)
{ {
if (this->MustSkip()) if (this->MustSkip())
return; return;
// Compute bundle directory names. // Compute bundle directory names.
std::string out = outpath; std::string out = root;
out += "/"; out += "/";
out += this->Target->GetCFBundleDirectory(this->ConfigName, true); out += this->Target->GetCFBundleDirectory(this->ConfigName, false);
std::string top = out;
out += "/MacOS";
cmSystemTools::MakeDirectory(out.c_str()); cmSystemTools::MakeDirectory(out.c_str());
this->Makefile->AddCMakeOutputFile(out.c_str()); this->Makefile->AddCMakeOutputFile(out.c_str());
std::string newoutpath = 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 = top; std::string plist =
this->Target->GetCFBundleDirectory(this->ConfigName, true);
plist += "/Info.plist"; plist += "/Info.plist";
this->LocalGenerator->GenerateAppleInfoPList(this->Target, this->LocalGenerator->GenerateAppleInfoPList(this->Target,
targetName.c_str(), targetName.c_str(),
plist.c_str()); plist.c_str());
this->Makefile->AddCMakeOutputFile(plist.c_str()); this->Makefile->AddCMakeOutputFile(plist.c_str());
outpath = newoutpath;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -25,8 +25,6 @@ class cmLocalGenerator;
class cmOSXBundleGenerator class cmOSXBundleGenerator
{ {
public: public:
static void PrepareTargetProperties(cmTarget* target);
cmOSXBundleGenerator(cmTarget* target, cmOSXBundleGenerator(cmTarget* target,
const char* configName); const char* configName);
@ -38,9 +36,9 @@ public:
void CreateFramework(const std::string& targetName, void CreateFramework(const std::string& targetName,
const std::string& root); const std::string& root);
// create a cf bundle at a given root and return the // create a cf bundle at a given root
// directory within the bundle that contains the library void CreateCFBundle(const std::string& targetName,
void CreateCFBundle(const std::string& targetName, std::string& outpath); const std::string& root);
struct MacOSXContentGeneratorType struct MacOSXContentGeneratorType
{ {

View File

@ -3278,7 +3278,7 @@ const char* cmTarget::NormalGetLocation(const char* config)
this->Location += cfgid; this->Location += cfgid;
} }
if(this->IsCFBundleOnApple() || this->IsAppBundleOnApple()) if(this->IsAppBundleOnApple())
{ {
std::string macdir = this->BuildMacContentDirectory("", config, false); std::string macdir = this->BuildMacContentDirectory("", config, false);
if(!macdir.empty()) if(!macdir.empty())
@ -3891,7 +3891,7 @@ std::string cmTarget::NormalGetFullPath(const char* config, bool implib,
{ {
std::string fpath = this->GetDirectory(config, implib); std::string fpath = this->GetDirectory(config, implib);
fpath += "/"; fpath += "/";
if(this->IsCFBundleOnApple() || this->IsAppBundleOnApple()) if(this->IsAppBundleOnApple())
{ {
fpath = this->BuildMacContentDirectory(fpath, config, false); fpath = this->BuildMacContentDirectory(fpath, config, false);
fpath += "/"; fpath += "/";
@ -4037,6 +4037,21 @@ void cmTarget::GetFullNameInternal(const char* config,
targetSuffix = 0; targetSuffix = 0;
} }
if(this->IsCFBundleOnApple())
{
fw_prefix = this->GetOutputName(config, false);
fw_prefix += ".";
const char *ext = this->GetProperty("BUNDLE_EXTENSION");
if (!ext)
{
ext = "bundle";
}
fw_prefix += ext;
fw_prefix += "/Contents/MacOS/";
targetPrefix = fw_prefix.c_str();
targetSuffix = 0;
}
// Begin the final name with the prefix. // Begin the final name with the prefix.
outPrefix = targetPrefix?targetPrefix:""; outPrefix = targetPrefix?targetPrefix:"";

View File

@ -54,3 +54,5 @@ set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings
${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc
PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/English.lproj") PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/English.lproj")
export(TARGETS CFBundleTest FILE ${CMAKE_CURRENT_BINARY_DIR}/exp.cmake)