ENH: fix bundles for Mac and Xcode

This commit is contained in:
Bill Hoffman 2006-01-05 09:13:06 -05:00
parent 11cd7b0b3f
commit 7b1440ab9f
4 changed files with 50 additions and 23 deletions

View File

@ -64,29 +64,6 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args)
if ( use_macbundle)
{
tgt->SetProperty("MACOSX_BUNDLE", "ON");
#ifdef __APPLE__
std::string f1 = m_Makefile->GetModulesFile("MacOSXBundleInfo.plist.in");
if ( f1.size() == 0 )
{
this->SetError("could not find Mac OSX bundle template file.");
return false;
}
std::string macdir = m_Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
if ( macdir.size() == 0 )
{
macdir = m_Makefile->GetCurrentOutputDirectory();
}
if(macdir.size() && macdir[macdir.size()-1] != '/')
{
macdir += "/";
}
macdir += exename + ".app/Contents/";
std::string f2 = macdir + "Info.plist";
macdir += "MacOS";
cmSystemTools::MakeDirectory(macdir.c_str());
m_Makefile->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", exename.c_str());
m_Makefile->ConfigureFile(f1.c_str(), f2.c_str(), false, false, false);
#endif
}
return true;

View File

@ -505,6 +505,10 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
{
sourcecode += ".cpp.objc";
}
else if(ext == "plist")
{
sourcecode += ".text.plist";
}
else if(!lang)
{
sourcecode += ext;
@ -1146,7 +1150,20 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
fileType = "compiled.mach-o.executable";
if(target.GetPropertyAsBool("MACOSX_BUNDLE"))
{
std::string f1 = m_CurrentMakefile->GetModulesFile("MacOSXBundleInfo.plist.in");
if ( f1.size() == 0 )
{
cmSystemTools::Error("could not find Mac OSX bundle template file.");
}
std::string f2 = m_CurrentMakefile->GetCurrentOutputDirectory();
f2 += "/Info.plist";
m_CurrentMakefile->ConfigureFile(f1.c_str(), f2.c_str(), false, false, false);
productType = "com.apple.product-type.application";
std::string path =
this->ConvertToRelativeForXCode(f2.c_str());
buildSettings->AddAttribute("INFOPLIST_FILE",
this->CreateString(path.c_str()));
}
else
{
@ -1777,6 +1794,17 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
{
cmTarget& cmtarget = l->second;
// add the soon to be generated Info.plist file as a source for a MACOSX_BUNDLE
// file
if(cmtarget.GetPropertyAsBool("MACOSX_BUNDLE"))
{
cmSourceFile file;
file.SetName("Info.plist", m_CurrentMakefile->GetCurrentOutputDirectory(),
m_CurrentMakefile->GetSourceExtensions(),
m_CurrentMakefile->GetHeaderExtensions());
cmtarget.GetSourceFiles().push_back(m_CurrentMakefile->AddSource(file));
}
std::vector<cmSourceFile*> & classes = cmtarget.GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
s != classes.end(); s++)

View File

@ -1373,6 +1373,27 @@ cmLocalUnixMakefileGenerator3
// Make bundle directories
outpath += target.GetName();
outpath += ".app/Contents/MacOS/";
std::string f1 = m_Makefile->GetModulesFile("MacOSXBundleInfo.plist.in");
if ( f1.size() == 0 )
{
cmSystemTools::Error("could not find Mac OSX bundle template file.");
}
std::string macdir = m_Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
if ( macdir.size() == 0 )
{
macdir = m_Makefile->GetCurrentOutputDirectory();
}
if(macdir.size() && macdir[macdir.size()-1] != '/')
{
macdir += "/";
}
macdir += target.GetName();
macdir += ".app/Contents/";
std::string f2 = macdir + "Info.plist";
macdir += "MacOS";
cmSystemTools::MakeDirectory(macdir.c_str());
m_Makefile->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", target.GetName());
m_Makefile->ConfigureFile(f1.c_str(), f2.c_str(), false, false, false);
}
#endif
std::string targetFullPath = outpath + targetName;

View File

@ -73,6 +73,7 @@ cmMakefile::cmMakefile()
"\\.(C|M|c|c\\+\\+|cc|cpp|cxx|m|mm|rc|def|r|odl|idl|hpj|bat)$");
this->AddSourceGroup("Header Files", "\\.(h|h\\+\\+|hm|hpp|hxx|in|txx|inl)$");
this->AddSourceGroup("CMake Rules", "\\.rule$");
this->AddSourceGroup("Resources", "\\.plist$");
this->AddDefaultDefinitions();
m_cmDefineRegex.compile("#cmakedefine[ \t]+([A-Za-z_0-9]*)");
m_cmDefine01Regex.compile("#cmakedefine01[ \t]+([A-Za-z_0-9]*)");