ENH: Create Info.plist files in OS X Frameworks
A Mac OS X Framework should provide a Resources/Info.plist file containing meta-data about the framework. This change generates a default Info.plist for frameworks and provides an interface for users to customize it.
This commit is contained in:
parent
a54e97cf94
commit
f89dae7a94
26
Modules/MacOSXFrameworkInfo.plist.in
Normal file
26
Modules/MacOSXFrameworkInfo.plist.in
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>${MACOSX_FRAMEWORK_NAME}</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string>${MACOSX_FRAMEWORK_ICON_FILE}</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>${MACOSX_FRAMEWORK_IDENTIFIER}</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>FMWK</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>${MACOSX_FRAMEWORK_BUNDLE_VERSION}</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>${MACOSX_FRAMEWORK_SHORT_VERSION_STRING}</string>
|
||||||
|
<key>CSResourcesFileMapped</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
@ -1436,6 +1436,18 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
|||||||
std::string version = target.GetFrameworkVersion();
|
std::string version = target.GetFrameworkVersion();
|
||||||
buildSettings->AddAttribute("FRAMEWORK_VERSION",
|
buildSettings->AddAttribute("FRAMEWORK_VERSION",
|
||||||
this->CreateString(version.c_str()));
|
this->CreateString(version.c_str()));
|
||||||
|
|
||||||
|
std::string plist = this->ComputeInfoPListLocation(target);
|
||||||
|
// Xcode will create the final version of Info.plist at build time,
|
||||||
|
// so let it replace the framework name. This avoids creating
|
||||||
|
// a per-configuration Info.plist file.
|
||||||
|
this->CurrentLocalGenerator
|
||||||
|
->GenerateFrameworkInfoPList(&target, "$(EXECUTABLE_NAME)",
|
||||||
|
plist.c_str());
|
||||||
|
std::string path =
|
||||||
|
this->ConvertToRelativeForXCode(plist.c_str());
|
||||||
|
buildSettings->AddAttribute("INFOPLIST_FILE",
|
||||||
|
this->CreateString(path.c_str()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2863,3 +2863,43 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
|
|||||||
mf->ConfigureFile(inFile.c_str(), fname, false, false, false);
|
mf->ConfigureFile(inFile.c_str(), fname, false, false, false);
|
||||||
mf->PopScope();
|
mf->PopScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target,
|
||||||
|
const char* targetName,
|
||||||
|
const char* fname)
|
||||||
|
{
|
||||||
|
// Find the Info.plist template.
|
||||||
|
const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
|
||||||
|
std::string inFile = (in && *in)? in : "MacOSXFrameworkInfo.plist.in";
|
||||||
|
if(!cmSystemTools::FileIsFullPath(inFile.c_str()))
|
||||||
|
{
|
||||||
|
std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
|
||||||
|
if(!inMod.empty())
|
||||||
|
{
|
||||||
|
inFile = inMod;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!cmSystemTools::FileExists(inFile.c_str(), true))
|
||||||
|
{
|
||||||
|
cmOStringStream e;
|
||||||
|
e << "Target " << target->GetName() << " Info.plist template \""
|
||||||
|
<< inFile << "\" could not be found.";
|
||||||
|
cmSystemTools::Error(e.str().c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert target properties to variables in an isolated makefile
|
||||||
|
// scope to configure the file. If properties are set they will
|
||||||
|
// override user make variables. If not the configuration will fall
|
||||||
|
// back to the directory-level values set by the user.
|
||||||
|
cmMakefile* mf = this->Makefile;
|
||||||
|
mf->PushScope();
|
||||||
|
mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName);
|
||||||
|
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE");
|
||||||
|
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER");
|
||||||
|
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING");
|
||||||
|
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_BUNDLE_VERSION");
|
||||||
|
mf->ConfigureFile(inFile.c_str(), fname, false, false, false);
|
||||||
|
mf->PopScope();
|
||||||
|
}
|
||||||
|
@ -275,6 +275,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
void GenerateAppleInfoPList(cmTarget* target, const char* targetName,
|
void GenerateAppleInfoPList(cmTarget* target, const char* targetName,
|
||||||
const char* fname);
|
const char* fname);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a Mac OS X framework Info.plist file.
|
||||||
|
*/
|
||||||
|
void GenerateFrameworkInfoPList(cmTarget* target,
|
||||||
|
const char* targetName,
|
||||||
|
const char* fname);
|
||||||
protected:
|
protected:
|
||||||
/** Construct a comment for a custom command. */
|
/** Construct a comment for a custom command. */
|
||||||
std::string ConstructComment(const cmCustomCommand& cc,
|
std::string ConstructComment(const cmCustomCommand& cc,
|
||||||
|
@ -235,8 +235,17 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmMakefileLibraryTargetGenerator::CreateFramework()
|
void
|
||||||
|
cmMakefileLibraryTargetGenerator
|
||||||
|
::CreateFramework(std::string const& targetName)
|
||||||
{
|
{
|
||||||
|
// Configure the Info.plist file into the Resources directory.
|
||||||
|
this->MacContentFolders.insert("Resources");
|
||||||
|
std::string plist = this->MacContentDirectory + "Resources/Info.plist";
|
||||||
|
this->LocalGenerator->GenerateFrameworkInfoPList(this->Target,
|
||||||
|
targetName.c_str(),
|
||||||
|
plist.c_str());
|
||||||
|
|
||||||
// TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to
|
// TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to
|
||||||
// drive rules to create these files at build time.
|
// drive rules to create these files at build time.
|
||||||
std::string oldName;
|
std::string oldName;
|
||||||
@ -388,7 +397,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||||||
if(this->Target->IsFrameworkOnApple())
|
if(this->Target->IsFrameworkOnApple())
|
||||||
{
|
{
|
||||||
outpath = this->MacContentDirectory;
|
outpath = this->MacContentDirectory;
|
||||||
this->CreateFramework();
|
this->CreateFramework(targetName);
|
||||||
}
|
}
|
||||||
else if(relink)
|
else if(relink)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ protected:
|
|||||||
bool relink);
|
bool relink);
|
||||||
// MacOSX Framework support methods
|
// MacOSX Framework support methods
|
||||||
void WriteFrameworkRules(bool relink);
|
void WriteFrameworkRules(bool relink);
|
||||||
void CreateFramework();
|
void CreateFramework(std::string const& targetName);
|
||||||
|
|
||||||
// Store the computd framework version for OS X Frameworks.
|
// Store the computd framework version for OS X Frameworks.
|
||||||
std::string FrameworkVersion;
|
std::string FrameworkVersion;
|
||||||
|
@ -588,6 +588,26 @@ void cmTarget::DefineProperties(cmake *cm)
|
|||||||
"If a custom Info.plist is specified by this property it may of course "
|
"If a custom Info.plist is specified by this property it may of course "
|
||||||
"hard-code all the settings instead of using the target properties.");
|
"hard-code all the settings instead of using the target properties.");
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("MACOSX_FRAMEWORK_INFO_PLIST", cmProperty::TARGET,
|
||||||
|
"Specify a custom Info.plist template for a Mac OS X Framework.",
|
||||||
|
"An library target with FRAMEWORK enabled will be built as a "
|
||||||
|
"framework on Mac OS X. "
|
||||||
|
"By default its Info.plist file is created by configuring a template "
|
||||||
|
"called MacOSXFrameworkInfo.plist.in located in the CMAKE_MODULE_PATH. "
|
||||||
|
"This property specifies an alternative template file name which "
|
||||||
|
"may be a full path.\n"
|
||||||
|
"The following target properties may be set to specify content to "
|
||||||
|
"be configured into the file:\n"
|
||||||
|
" MACOSX_FRAMEWORK_ICON_FILE\n"
|
||||||
|
" MACOSX_FRAMEWORK_IDENTIFIER\n"
|
||||||
|
" MACOSX_FRAMEWORK_SHORT_VERSION_STRING\n"
|
||||||
|
" MACOSX_FRAMEWORK_BUNDLE_VERSION\n"
|
||||||
|
"CMake variables of the same name may be set to affect all targets "
|
||||||
|
"in a directory that do not have each specific property set. "
|
||||||
|
"If a custom Info.plist is specified by this property it may of course "
|
||||||
|
"hard-code all the settings instead of using the target properties.");
|
||||||
|
|
||||||
cm->DefineProperty
|
cm->DefineProperty
|
||||||
("ENABLE_EXPORTS", cmProperty::TARGET,
|
("ENABLE_EXPORTS", cmProperty::TARGET,
|
||||||
"Specify whether an executable exports symbols for loadable modules.",
|
"Specify whether an executable exports symbols for loadable modules.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user