ENH: fix bundles for Mac and Xcode
This commit is contained in:
parent
11cd7b0b3f
commit
7b1440ab9f
|
@ -64,29 +64,6 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args)
|
||||||
if ( use_macbundle)
|
if ( use_macbundle)
|
||||||
{
|
{
|
||||||
tgt->SetProperty("MACOSX_BUNDLE", "ON");
|
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;
|
return true;
|
||||||
|
|
|
@ -505,6 +505,10 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
|
||||||
{
|
{
|
||||||
sourcecode += ".cpp.objc";
|
sourcecode += ".cpp.objc";
|
||||||
}
|
}
|
||||||
|
else if(ext == "plist")
|
||||||
|
{
|
||||||
|
sourcecode += ".text.plist";
|
||||||
|
}
|
||||||
else if(!lang)
|
else if(!lang)
|
||||||
{
|
{
|
||||||
sourcecode += ext;
|
sourcecode += ext;
|
||||||
|
@ -1146,7 +1150,20 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
||||||
fileType = "compiled.mach-o.executable";
|
fileType = "compiled.mach-o.executable";
|
||||||
if(target.GetPropertyAsBool("MACOSX_BUNDLE"))
|
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";
|
productType = "com.apple.product-type.application";
|
||||||
|
std::string path =
|
||||||
|
this->ConvertToRelativeForXCode(f2.c_str());
|
||||||
|
buildSettings->AddAttribute("INFOPLIST_FILE",
|
||||||
|
this->CreateString(path.c_str()));
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1777,6 +1794,17 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
|
||||||
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
|
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
|
||||||
{
|
{
|
||||||
cmTarget& cmtarget = l->second;
|
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();
|
std::vector<cmSourceFile*> & classes = cmtarget.GetSourceFiles();
|
||||||
for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
|
for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
|
||||||
s != classes.end(); s++)
|
s != classes.end(); s++)
|
||||||
|
|
|
@ -1373,6 +1373,27 @@ cmLocalUnixMakefileGenerator3
|
||||||
// Make bundle directories
|
// Make bundle directories
|
||||||
outpath += target.GetName();
|
outpath += target.GetName();
|
||||||
outpath += ".app/Contents/MacOS/";
|
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
|
#endif
|
||||||
std::string targetFullPath = outpath + targetName;
|
std::string targetFullPath = outpath + targetName;
|
||||||
|
|
|
@ -73,6 +73,7 @@ cmMakefile::cmMakefile()
|
||||||
"\\.(C|M|c|c\\+\\+|cc|cpp|cxx|m|mm|rc|def|r|odl|idl|hpj|bat)$");
|
"\\.(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("Header Files", "\\.(h|h\\+\\+|hm|hpp|hxx|in|txx|inl)$");
|
||||||
this->AddSourceGroup("CMake Rules", "\\.rule$");
|
this->AddSourceGroup("CMake Rules", "\\.rule$");
|
||||||
|
this->AddSourceGroup("Resources", "\\.plist$");
|
||||||
this->AddDefaultDefinitions();
|
this->AddDefaultDefinitions();
|
||||||
m_cmDefineRegex.compile("#cmakedefine[ \t]+([A-Za-z_0-9]*)");
|
m_cmDefineRegex.compile("#cmakedefine[ \t]+([A-Za-z_0-9]*)");
|
||||||
m_cmDefine01Regex.compile("#cmakedefine01[ \t]+([A-Za-z_0-9]*)");
|
m_cmDefine01Regex.compile("#cmakedefine01[ \t]+([A-Za-z_0-9]*)");
|
||||||
|
|
Loading…
Reference in New Issue