diff options
-rw-r--r-- | Modules/MacOSXFrameworkInfo.plist.in | 26 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 12 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 40 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 7 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 13 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 20 |
7 files changed, 117 insertions, 3 deletions
diff --git a/Modules/MacOSXFrameworkInfo.plist.in b/Modules/MacOSXFrameworkInfo.plist.in new file mode 100644 index 0000000..18eaef2 --- /dev/null +++ b/Modules/MacOSXFrameworkInfo.plist.in @@ -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> diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 2e00d13..f9d4445 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1436,6 +1436,18 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string version = target.GetFrameworkVersion(); buildSettings->AddAttribute("FRAMEWORK_VERSION", 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 { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 52322ff..c192263 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2863,3 +2863,43 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, mf->ConfigureFile(inFile.c_str(), fname, false, false, false); 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(); +} diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 1be0aa4..d528d2f 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -275,6 +275,13 @@ public: */ void GenerateAppleInfoPList(cmTarget* target, const char* targetName, const char* fname); + + /** + * Generate a Mac OS X framework Info.plist file. + */ + void GenerateFrameworkInfoPList(cmTarget* target, + const char* targetName, + const char* fname); protected: /** Construct a comment for a custom command. */ std::string ConstructComment(const cmCustomCommand& cc, diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 7bd12a0..9c0cc38 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -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 // drive rules to create these files at build time. std::string oldName; @@ -388,7 +397,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules if(this->Target->IsFrameworkOnApple()) { outpath = this->MacContentDirectory; - this->CreateFramework(); + this->CreateFramework(targetName); } else if(relink) { diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index e5f9482..8aa17cd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -37,7 +37,7 @@ protected: bool relink); // MacOSX Framework support methods void WriteFrameworkRules(bool relink); - void CreateFramework(); + void CreateFramework(std::string const& targetName); // Store the computd framework version for OS X Frameworks. std::string FrameworkVersion; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e4d7307..0fbae69 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -589,6 +589,26 @@ void cmTarget::DefineProperties(cmake *cm) "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 ("ENABLE_EXPORTS", cmProperty::TARGET, "Specify whether an executable exports symbols for loadable modules.", "Normally an executable does not export any symbols because it is " |