diff options
author | Brad King <brad.king@kitware.com> | 2008-02-14 20:31:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-02-14 20:31:08 (GMT) |
commit | 67f8c0fd104fe6ec1b6c1df2ebce6fdb9b2c811f (patch) | |
tree | 6b51fadf24500dea382988525e51e9c0e6d449bb /Source | |
parent | 7b1c305d864977a524e21b7b837a8582eb487d7c (diff) | |
download | CMake-67f8c0fd104fe6ec1b6c1df2ebce6fdb9b2c811f.zip CMake-67f8c0fd104fe6ec1b6c1df2ebce6fdb9b2c811f.tar.gz CMake-67f8c0fd104fe6ec1b6c1df2ebce6fdb9b2c811f.tar.bz2 |
ENH: Allow multiple OS X applications bundles to be created in a single build directory. Converted Info.plist files to be generated directly instead of configured with make variables. The MACOSX_BUNDLE_* variables are now properties (and vars for compatibility).
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 21 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 83 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 6 | ||||
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 16 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 16 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 14 |
6 files changed, 115 insertions, 41 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index c2b0558..de62e8f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1482,18 +1482,15 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(target.GetPropertyAsBool("MACOSX_BUNDLE")) { productType = "com.apple.product-type.application"; - std::string f1 = - this->CurrentMakefile->GetModulesFile("MacOSXBundleInfo.plist.in"); - if ( f1.size() == 0 ) - { - cmSystemTools::Error("could not find Mac OSX bundle template file."); - } - std::string f2 = this->CurrentMakefile->GetCurrentOutputDirectory(); - f2 += "/Info.plist"; - this->CurrentMakefile->ConfigureFile(f1.c_str(), f2.c_str(), - false, false, false); - std::string path = - this->ConvertToRelativeForXCode(f2.c_str()); + std::string plist = this->CurrentMakefile->GetCurrentOutputDirectory(); + plist += cmake::GetCMakeFilesDirectory(); + plist += "/"; + plist += target.GetName(); + plist += "Info.plist"; + this->CurrentLocalGenerator + ->GenerateAppleInfoPList(&target, productName.c_str(), plist.c_str()); + std::string path = + this->ConvertToRelativeForXCode(plist.c_str()); buildSettings->AddAttribute("INFOPLIST_FILE", this->CreateString(path.c_str())); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 100b613..abf4a30 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2732,3 +2732,86 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const // Assume it is supported. return true; } + +//---------------------------------------------------------------------------- +static std::string cmLGInfoProp(cmTarget* target, const char* prop) +{ + if(const char* val = target->GetProperty(prop)) + { + return val; + } + else + { + // For compatibility check for a variable. + return target->GetMakefile()->GetSafeDefinition(prop); + } +} + +//---------------------------------------------------------------------------- +void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, + const char* targetName, + const char* fname) +{ + std::string info_EXECUTABLE_NAME = targetName; + + // Lookup the properties. + std::string info_INFO_STRING = + cmLGInfoProp(target, "MACOSX_BUNDLE_INFO_STRING"); + std::string info_ICON_FILE = + cmLGInfoProp(target, "MACOSX_BUNDLE_ICON_FILE"); + std::string info_GUI_IDENTIFIER = + cmLGInfoProp(target, "MACOSX_BUNDLE_GUI_IDENTIFIER"); + std::string info_LONG_VERSION_STRING = + cmLGInfoProp(target, "MACOSX_BUNDLE_LONG_VERSION_STRING"); + std::string info_BUNDLE_NAME = + cmLGInfoProp(target, "MACOSX_BUNDLE_BUNDLE_NAME"); + std::string info_SHORT_VERSION_STRING = + cmLGInfoProp(target, "MACOSX_BUNDLE_SHORT_VERSION_STRING"); + std::string info_BUNDLE_VERSION = + cmLGInfoProp(target, "MACOSX_BUNDLE_BUNDLE_VERSION"); + std::string info_COPYRIGHT = + cmLGInfoProp(target, "MACOSX_BUNDLE_COPYRIGHT"); + + // Generate the file. + cmGeneratedFileStream fout(fname); + fout.SetCopyIfDifferent(true); + fout << + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"\n" + " \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" + "<plist version=\"1.0\">\n" + "<dict>\n" + "\t<key>CFBundleDevelopmentRegion</key>\n" + "\t<string>English</string>\n" + "\t<key>CFBundleExecutable</key>\n" + "\t<string>" << info_EXECUTABLE_NAME << "</string>\n" + "\t<key>CFBundleGetInfoString</key>\n" + "\t<string>" << info_INFO_STRING << "</string>\n" + "\t<key>CFBundleIconFile</key>\n" + "\t<string>" << info_ICON_FILE << "</string>\n" + "\t<key>CFBundleIdentifier</key>\n" + "\t<string>" << info_GUI_IDENTIFIER << "</string>\n" + "\t<key>CFBundleInfoDictionaryVersion</key>\n" + "\t<string>6.0</string>\n" + "\t<key>CFBundleLongVersionString</key>\n" + "\t<string>" << info_LONG_VERSION_STRING << "</string>\n" + "\t<key>CFBundleName</key>\n" + "\t<string>" << info_BUNDLE_NAME << "</string>\n" + "\t<key>CFBundlePackageType</key>\n" + "\t<string>APPL</string>\n" + "\t<key>CFBundleShortVersionString</key>\n" + "\t<string>" << info_SHORT_VERSION_STRING << "</string>\n" + "\t<key>CFBundleSignature</key>\n" + "\t<string>????" /* break string to avoid trigraph */ "</string>\n" + "\t<key>CFBundleVersion</key>\n" + "\t<string>" << info_BUNDLE_VERSION << "</string>\n" + "\t<key>CSResourcesFileMapped</key>\n" + "\t<true/>\n" + "\t<key>LSRequiresCarbon</key>\n" + "\t<true/>\n" + "\t<key>NSHumanReadableCopyright</key>\n" + "\t<string>" << info_COPYRIGHT << "</string>\n" + "</dict>\n" + "</plist>\n" + ; +} diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index c55f6a3..6b3b7ea 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -269,6 +269,12 @@ public: bool NeedBackwardsCompatibility(unsigned int major, unsigned int minor, unsigned int patch = 0xFFu); + + /** + * Generate a Mac OS X application bundle Info.plist file. + */ + void GenerateAppleInfoPList(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/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index bb54f26..0114fa5 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -133,13 +133,6 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) outpath += "/"; // Make bundle directories - std::string f1 = - this->Makefile->GetModulesFile("MacOSXBundleInfo.plist.in"); - if ( f1.size() == 0 ) - { - cmSystemTools::Error("could not find Mac OSX bundle template file."); - } - std::vector<cmSourceFile*>::const_iterator sourceIt; for ( sourceIt = this->Target->GetSourceFiles().begin(); sourceIt != this->Target->GetSourceFiles().end(); @@ -162,11 +155,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Configure the Info.plist file. Note that it needs the executable name // to be set. - std::string f2 = macdir + "Info.plist"; - this->Makefile->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", - targetName.c_str()); - this->Makefile->ConfigureFile(f1.c_str(), f2.c_str(), - false, false, false); + std::string plist = macdir + "Info.plist"; + this->LocalGenerator->GenerateAppleInfoPList(this->Target, + targetName.c_str(), + plist.c_str()); } #endif std::string outpathImp; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index d0e2fcb..f611562 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -364,22 +364,6 @@ void cmMakefileLibraryTargetGenerator::CreateFramework( //cmSystemTools::MakeDirectory((macdir + "Libraries").c_str()); cmSystemTools::MakeDirectory((macdir + "Headers").c_str()); - // Configure the Info.plist file. Note that it needs the executable name - // to be set - std::string rsrcDir = macdir + "Resources/"; - cmSystemTools::MakeDirectory(rsrcDir.c_str()); - this->Makefile->AddDefinition("MACOSX_FRAMEWORK_NAME", - targetName.c_str()); - std::string f1 = - this->Makefile->GetModulesFile("MacOSXFrameworkInfo.plist.in"); - if ( f1.size() == 0 ) - { - cmSystemTools::Error( - "could not find Mac OSX framework Info.plist template file."); - } - std::string f2 = rsrcDir + "Info.plist"; - this->Makefile->ConfigureFile(f1.c_str(), f2.c_str(), - false, false, false); this->CopyFrameworkSources(targetName, outpath, version, "PRIVATE_HEADER", "PrivateHeaders"); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c043ece..0422ffc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -510,7 +510,19 @@ void cmTarget::DefineProperties(cmake *cm) "When this property is set to true the executable when built " "on Mac OS X will be created as an application bundle. " "This makes it a GUI executable that can be launched from " - "the Finder."); + "the Finder.\n" + "The bundle Info.plist file is generated automatically. " + "The following target properties may be set to specify " + "its content:" + " MACOSX_BUNDLE_INFO_STRING\n" + " MACOSX_BUNDLE_ICON_FILE\n" + " MACOSX_BUNDLE_GUI_IDENTIFIER\n" + " MACOSX_BUNDLE_LONG_VERSION_STRING\n" + " MACOSX_BUNDLE_BUNDLE_NAME\n" + " MACOSX_BUNDLE_SHORT_VERSION_STRING\n" + " MACOSX_BUNDLE_BUNDLE_VERSION\n" + " MACOSX_BUNDLE_COPYRIGHT\n" + ); cm->DefineProperty ("ENABLE_EXPORTS", cmProperty::TARGET, |