summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-05-17 16:53:56 (GMT)
committerBrad King <brad.king@kitware.com>2008-05-17 16:53:56 (GMT)
commitc1b8ad4e1db7df8dacbf8df2454270afb66d475b (patch)
treebf5e0410690e6a2bedcbd868386412cc0a667d62 /Source/cmLocalGenerator.cxx
parentb9ede3c86d046baa36c79111f0d7ab4b42bdc8dc (diff)
downloadCMake-c1b8ad4e1db7df8dacbf8df2454270afb66d475b.zip
CMake-c1b8ad4e1db7df8dacbf8df2454270afb66d475b.tar.gz
CMake-c1b8ad4e1db7df8dacbf8df2454270afb66d475b.tar.bz2
ENH: Allow users to specify a custom Info.plist template
- Create MACOSX_BUNDLE_INFO_PLIST target property to specify template. - Look for MacOSXBundleInfo.plist.in in CMAKE_MODULE_PATH by default. - See issue #6983.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx108
1 files changed, 39 insertions, 69 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index b934126..5a2a6c6 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2776,16 +2776,11 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
}
//----------------------------------------------------------------------------
-static std::string cmLGInfoProp(cmTarget* target, const char* prop)
+static void cmLGInfoProp(cmMakefile* mf, 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);
+ mf->AddDefinition(prop, val);
}
}
@@ -2794,66 +2789,41 @@ 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"
- ;
+ // Find the Info.plist template.
+ const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST");
+ std::string inFile = (in && *in)? in : "MacOSXBundleInfo.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_BUNDLE_EXECUTABLE_NAME", targetName);
+ cmLGInfoProp(mf, target, "MACOSX_BUNDLE_INFO_STRING");
+ cmLGInfoProp(mf, target, "MACOSX_BUNDLE_ICON_FILE");
+ cmLGInfoProp(mf, target, "MACOSX_BUNDLE_GUI_IDENTIFIER");
+ cmLGInfoProp(mf, target, "MACOSX_BUNDLE_LONG_VERSION_STRING");
+ cmLGInfoProp(mf, target, "MACOSX_BUNDLE_BUNDLE_NAME");
+ cmLGInfoProp(mf, target, "MACOSX_BUNDLE_SHORT_VERSION_STRING");
+ cmLGInfoProp(mf, target, "MACOSX_BUNDLE_BUNDLE_VERSION");
+ cmLGInfoProp(mf, target, "MACOSX_BUNDLE_COPYRIGHT");
+ mf->ConfigureFile(inFile.c_str(), fname, false, false, false);
+ mf->PopScope();
}