ENH: Improvements to the Xcode generator. Build frameworks using native Copy Headers and Copy Bundle Resources phases. Fix bugs: eliminate folders with no names, ensure source files show up in multiple targets, remove empty utility targets from Sources subtrees, ensure that fileRefs only show up once in each grouping folder.

This commit is contained in:
David Cole 2007-08-14 11:45:15 -04:00
parent f13c3eef83
commit fa61182de8
14 changed files with 473 additions and 231 deletions

View File

@ -17,6 +17,7 @@
#include "cmGlobalXCode21Generator.h" #include "cmGlobalXCode21Generator.h"
#include "cmXCode21Object.h" #include "cmXCode21Object.h"
//----------------------------------------------------------------------------
cmGlobalXCode21Generator::cmGlobalXCode21Generator() cmGlobalXCode21Generator::cmGlobalXCode21Generator()
{ {
this->XcodeVersion = 21; this->XcodeVersion = 21;

View File

@ -25,6 +25,7 @@ PURPOSE. See the above copyright notices for more information.
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmOrderLinkDirectories.h" #include "cmOrderLinkDirectories.h"
//----------------------------------------------------------------------------
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
#include "cmXMLParser.h" #include "cmXMLParser.h"
@ -61,7 +62,6 @@ public:
}; };
#endif #endif
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGlobalXCodeGenerator::cmGlobalXCodeGenerator() cmGlobalXCodeGenerator::cmGlobalXCodeGenerator()
{ {
@ -69,6 +69,7 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator()
this->RootObject = 0; this->RootObject = 0;
this->MainGroupChildren = 0; this->MainGroupChildren = 0;
this->SourcesGroupChildren = 0; this->SourcesGroupChildren = 0;
this->ResourcesGroupChildren = 0;
this->CurrentMakefile = 0; this->CurrentMakefile = 0;
this->CurrentLocalGenerator = 0; this->CurrentLocalGenerator = 0;
this->XcodeVersion = 15; this->XcodeVersion = 15;
@ -266,6 +267,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& gens) std::vector<cmLocalGenerator*>& gens)
{ {
cmMakefile* mf = root->GetMakefile(); cmMakefile* mf = root->GetMakefile();
// Add ALL_BUILD // Add ALL_BUILD
const char* no_working_directory = 0; const char* no_working_directory = 0;
std::vector<std::string> no_depends; std::vector<std::string> no_depends;
@ -273,7 +275,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
no_working_directory, no_working_directory,
"echo", "Build all projects"); "echo", "Build all projects");
cmTarget* allbuild = mf->FindTarget("ALL_BUILD", false); cmTarget* allbuild = mf->FindTarget("ALL_BUILD", false);
// Add XCODE depend helper // Add XCODE depend helper
std::string dir = mf->GetCurrentOutputDirectory(); std::string dir = mf->GetCurrentOutputDirectory();
cmCustomCommandLine makecommand; cmCustomCommandLine makecommand;
@ -326,7 +328,6 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalXCodeGenerator::CreateReRunCMakeFile(cmLocalGenerator* root) void cmGlobalXCodeGenerator::CreateReRunCMakeFile(cmLocalGenerator* root)
{ {
@ -373,6 +374,7 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects()
this->GroupMap.clear(); this->GroupMap.clear();
this->GroupNameMap.clear(); this->GroupNameMap.clear();
this->TargetGroup.clear(); this->TargetGroup.clear();
this->FileRefs.clear();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -419,38 +421,110 @@ cmXCodeObject* cmGlobalXCodeGenerator
return obj; return obj;
} }
//----------------------------------------------------------------------------
bool IsResource(cmSourceFile* sf)
{
const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION");
bool isResource =
(sf->GetPropertyAsBool("FRAMEWORK_RESOURCE") ||
(location && cmStdString(location) == "Resources"));
return isResource;
}
//----------------------------------------------------------------------------
cmStdString GetGroupMapKey(cmTarget& cmtarget, cmSourceFile* sf)
{
cmStdString key(cmtarget.GetName());
key += "-";
key += sf->GetFullPath();
return key;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmXCodeObject* cmXCodeObject*
cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
cmSourceFile* sf, cmSourceFile* sf,
cmTarget& cmtarget) cmTarget& cmtarget)
{ {
// Add flags from target and source file properties.
std::string flags; std::string flags;
// Add flags from source file properties.
if(cmtarget.GetProperty("COMPILE_FLAGS")) if(cmtarget.GetProperty("COMPILE_FLAGS"))
{ {
lg->AppendFlags(flags, cmtarget.GetProperty("COMPILE_FLAGS")); lg->AppendFlags(flags, cmtarget.GetProperty("COMPILE_FLAGS"));
} }
lg->AppendFlags(flags, sf->GetProperty("COMPILE_FLAGS")); lg->AppendFlags(flags, sf->GetProperty("COMPILE_FLAGS"));
cmSystemTools::ReplaceString(flags, "\"", "\\\""); cmSystemTools::ReplaceString(flags, "\"", "\\\"");
cmXCodeObject* fileRef =
this->CreateObject(cmXCodeObject::PBXFileReference);
cmXCodeObject* group = this->GroupMap[sf]; // Using a map and the full path guarantees that we will always get the same
cmXCodeObject* children = group->GetObject("children"); // fileRef object for any given full path.
children->AddObject(fileRef); //
cmXCodeObject* buildFile = this->CreateObject(cmXCodeObject::PBXBuildFile);
std::string fname = sf->GetFullPath(); std::string fname = sf->GetFullPath();
std::string comment = fname; cmXCodeObject* fileRef = this->FileRefs[fname];
comment += " in "; if(!fileRef)
std::string gname = group->GetObject("name")->GetString(); {
comment += gname.substr(1, gname.size()-2); fileRef = this->CreateObject(cmXCodeObject::PBXFileReference);
buildFile->SetComment(comment.c_str()); std::string comment = fname;
fileRef->SetComment(fname.c_str()); comment += " in ";
//std::string gname = group->GetObject("name")->GetString();
//comment += gname.substr(1, gname.size()-2);
fileRef->SetComment(fname.c_str());
this->FileRefs[fname] = fileRef;
}
cmStdString key = GetGroupMapKey(cmtarget, sf);
cmXCodeObject* group = this->GroupMap[key];
cmXCodeObject* children = group->GetObject("children");
if (!children->HasObject(fileRef))
{
children->AddObject(fileRef);
}
cmXCodeObject* buildFile = this->CreateObject(cmXCodeObject::PBXBuildFile);
buildFile->SetComment(fileRef->GetComment());
buildFile->AddAttribute("fileRef", this->CreateObjectReference(fileRef)); buildFile->AddAttribute("fileRef", this->CreateObjectReference(fileRef));
cmXCodeObject* settings = cmXCodeObject* settings =
this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags.c_str())); settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags.c_str()));
// Is this a resource file in this target? Add it to the resources group...
//
bool isResource = IsResource(sf);
// Is this a "private" or "public" framework header file?
// Set the ATTRIBUTES attribute appropriately...
//
if(cmtarget.GetType() == cmTarget::SHARED_LIBRARY &&
cmtarget.GetPropertyAsBool("FRAMEWORK"))
{
if(sf->GetPropertyAsBool("FRAMEWORK_PRIVATE_HEADER"))
{
cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
attrs->AddObject(this->CreateString("Private"));
settings->AddAttribute("ATTRIBUTES", attrs);
isResource = true;
}
else if(sf->GetPropertyAsBool("FRAMEWORK_PUBLIC_HEADER"))
{
cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
attrs->AddObject(this->CreateString("Public"));
settings->AddAttribute("ATTRIBUTES", attrs);
isResource = true;
}
}
// Add the fileRef to the top level Resources group/folder if it is not
// already there.
//
if(isResource && this->ResourcesGroupChildren &&
!this->ResourcesGroupChildren->HasObject(fileRef))
{
this->ResourcesGroupChildren->AddObject(fileRef);
}
buildFile->AddAttribute("settings", settings); buildFile->AddAttribute("settings", settings);
fileRef->AddAttribute("fileEncoding", this->CreateString("4")); fileRef->AddAttribute("fileEncoding", this->CreateString("4"));
const char* lang = const char* lang =
@ -524,7 +598,7 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
bool cmGlobalXCodeGenerator::SpecialTargetEmitted(std::string const& tname) bool cmGlobalXCodeGenerator::SpecialTargetEmitted(std::string const& tname)
{ {
if(tname == "ALL_BUILD" || tname == "XCODE_DEPEND_HELPER" || if(tname == "ALL_BUILD" || tname == "XCODE_DEPEND_HELPER" ||
tname == "install" || tname == "RUN_TESTS" ) tname == "install" || tname == "package" || tname == "RUN_TESTS" )
{ {
if(this->TargetDoneSet.find(tname) != this->TargetDoneSet.end()) if(this->TargetDoneSet.find(tname) != this->TargetDoneSet.end())
{ {
@ -536,7 +610,7 @@ bool cmGlobalXCodeGenerator::SpecialTargetEmitted(std::string const& tname)
return false; return false;
} }
//----------------------------------------------------------------------------
void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen) void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen)
{ {
this->CurrentLocalGenerator = gen; this->CurrentLocalGenerator = gen;
@ -572,18 +646,18 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen)
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
std::vector<cmXCodeObject*>& std::vector<cmXCodeObject*>&
targets) targets)
{ {
this->SetCurrentLocalGenerator(gen); this->SetCurrentLocalGenerator(gen);
cmTargets &tgts = this->CurrentMakefile->GetTargets(); cmTargets &tgts = this->CurrentMakefile->GetTargets();
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;
// make sure ALL_BUILD, INSTALL, etc are only done once // make sure ALL_BUILD, INSTALL, etc are only done once
if(this->SpecialTargetEmitted(l->first.c_str())) if(this->SpecialTargetEmitted(l->first.c_str()))
{ {
@ -597,31 +671,22 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
continue; continue;
} }
// create source build phase // organize the sources
cmXCodeObject* sourceBuildPhase = std::vector<cmSourceFile*> const &classes = cmtarget.GetSourceFiles();
this->CreateObject(cmXCodeObject::PBXSourcesBuildPhase);
sourceBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647"));
sourceBuildPhase->SetComment("Sources");
cmXCodeObject* buildFiles =
this->CreateObject(cmXCodeObject::OBJECT_LIST);
sourceBuildPhase->AddAttribute("files", buildFiles);
sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
this->CreateString("0"));
std::vector<cmSourceFile*> const &classes = l->second.GetSourceFiles();
// add all the sources
std::vector<cmXCodeObject*> externalObjFiles; std::vector<cmXCodeObject*> externalObjFiles;
std::vector<cmXCodeObject*> headerFiles; std::vector<cmXCodeObject*> headerFiles;
std::vector<cmXCodeObject*> specialBundleFiles; std::vector<cmXCodeObject*> resourceFiles;
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); std::vector<cmXCodeObject*> sourceFiles;
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i) i != classes.end(); ++i)
{ {
cmXCodeObject* xsf = cmXCodeObject* xsf =
this->CreateXCodeSourceFile(this->CurrentLocalGenerator, this->CreateXCodeSourceFile(this->CurrentLocalGenerator,
*i, cmtarget); *i, cmtarget);
cmXCodeObject* fr = xsf->GetObject("fileRef"); cmXCodeObject* fr = xsf->GetObject("fileRef");
cmXCodeObject* filetype = cmXCodeObject* filetype =
fr->GetObject()->GetObject("lastKnownFileType"); fr->GetObject()->GetObject("lastKnownFileType");
if(strcmp(filetype->GetString(), "\"compiled.mach-o.objfile\"") == 0) if(strcmp(filetype->GetString(), "\"compiled.mach-o.objfile\"") == 0)
{ {
externalObjFiles.push_back(xsf); externalObjFiles.push_back(xsf);
@ -630,76 +695,106 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
{ {
headerFiles.push_back(xsf); headerFiles.push_back(xsf);
} }
else if(IsResource(*i))
{
resourceFiles.push_back(xsf);
}
else else
{ {
buildFiles->AddObject(xsf); sourceFiles.push_back(xsf);
} }
} }
// create header build phase
cmXCodeObject* headerBuildPhase =
this->CreateObject(cmXCodeObject::PBXHeadersBuildPhase);
headerBuildPhase->SetComment("Headers");
headerBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
for(std::vector<cmXCodeObject*>::iterator i = headerFiles.begin();
i != headerFiles.end(); ++i)
{
buildFiles->AddObject(*i);
}
headerBuildPhase->AddAttribute("files", buildFiles);
headerBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
this->CreateString("0"));
// create framework build phase
cmXCodeObject* frameworkBuildPhase =
this->CreateObject(cmXCodeObject::PBXFrameworksBuildPhase);
frameworkBuildPhase->SetComment("Frameworks");
frameworkBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
frameworkBuildPhase->AddAttribute("files", buildFiles);
for(std::vector<cmXCodeObject*>::iterator i = externalObjFiles.begin();
i != externalObjFiles.end(); ++i)
{
buildFiles->AddObject(*i);
}
frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
this->CreateString("0"));
cmXCodeObject* buildPhases =
this->CreateObject(cmXCodeObject::OBJECT_LIST);
this->CreateCustomCommands(buildPhases, sourceBuildPhase,
headerBuildPhase, frameworkBuildPhase,
cmtarget);
targets.push_back(this->CreateXCodeTarget(l->second, buildPhases));
// copy files build phase // some build phases only apply to bundles and/or frameworks
typedef std::map<cmStdString, std::vector<cmSourceFile*> > bool isFrameworkTarget = cmtarget.GetType() == cmTarget::SHARED_LIBRARY &&
mapOfVectorOfSourceFiles; cmtarget.GetPropertyAsBool("FRAMEWORK");
mapOfVectorOfSourceFiles bundleFiles; bool isBundleTarget = cmtarget.GetPropertyAsBool("MACOSX_BUNDLE");
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i) cmXCodeObject* buildFiles = 0;
// create source build phase
cmXCodeObject* sourceBuildPhase = 0;
if (!sourceFiles.empty())
{ {
const char* resLoc = (*i)->GetProperty("MACOSX_PACKAGE_LOCATION"); sourceBuildPhase =
if ( !resLoc ) this->CreateObject(cmXCodeObject::PBXSourcesBuildPhase);
sourceBuildPhase->SetComment("Sources");
sourceBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
for(std::vector<cmXCodeObject*>::iterator i = sourceFiles.begin();
i != sourceFiles.end(); ++i)
{ {
continue; buildFiles->AddObject(*i);
} }
bundleFiles[resLoc].push_back(*i); sourceBuildPhase->AddAttribute("files", buildFiles);
sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
this->CreateString("0"));
} }
mapOfVectorOfSourceFiles::iterator mit;
for ( mit = bundleFiles.begin(); mit != bundleFiles.end(); ++ mit ) // create header build phase - only for framework targets
cmXCodeObject* headerBuildPhase = 0;
if (!headerFiles.empty() && isFrameworkTarget)
{ {
cmXCodeObject* copyFilesBuildPhase; headerBuildPhase =
if ( mit->first == "Resources" ) this->CreateObject(cmXCodeObject::PBXHeadersBuildPhase);
headerBuildPhase->SetComment("Headers");
headerBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
for(std::vector<cmXCodeObject*>::iterator i = headerFiles.begin();
i != headerFiles.end(); ++i)
{ {
copyFilesBuildPhase buildFiles->AddObject(*i);
= this->CreateObject(cmXCodeObject::PBXResourcesBuildPhase);
} }
else headerBuildPhase->AddAttribute("files", buildFiles);
headerBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
this->CreateString("0"));
}
// create resource build phase - only for framework or bundle targets
cmXCodeObject* resourceBuildPhase = 0;
if (!resourceFiles.empty() && (isFrameworkTarget || isBundleTarget))
{
resourceBuildPhase =
this->CreateObject(cmXCodeObject::PBXResourcesBuildPhase);
resourceBuildPhase->SetComment("Resources");
resourceBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
for(std::vector<cmXCodeObject*>::iterator i = resourceFiles.begin();
i != resourceFiles.end(); ++i)
{ {
copyFilesBuildPhase buildFiles->AddObject(*i);
= this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase); }
resourceBuildPhase->AddAttribute("files", buildFiles);
resourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
this->CreateString("0"));
}
// create vector of "non-resource content file" build phases - only for
// framework or bundle targets
std::vector<cmXCodeObject*> contentBuildPhases;
if (isFrameworkTarget || isBundleTarget)
{
typedef std::map<cmStdString, std::vector<cmSourceFile*> >
mapOfVectorOfSourceFiles;
mapOfVectorOfSourceFiles bundleFiles;
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i)
{
const char* contentLoc = (*i)->GetProperty("MACOSX_PACKAGE_LOCATION");
if ( !contentLoc || cmStdString(contentLoc) == "Resources" )
{
continue;
}
bundleFiles[contentLoc].push_back(*i);
}
mapOfVectorOfSourceFiles::iterator mit;
for ( mit = bundleFiles.begin(); mit != bundleFiles.end(); ++ mit )
{
cmXCodeObject* copyFilesBuildPhase =
this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
copyFilesBuildPhase->SetComment("Copy files"); copyFilesBuildPhase->SetComment("Copy files");
copyFilesBuildPhase->AddAttribute("buildActionMask", copyFilesBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647")); this->CreateString("2147483647"));
@ -712,73 +807,58 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
} }
copyFilesBuildPhase->AddAttribute("dstPath", copyFilesBuildPhase->AddAttribute("dstPath",
this->CreateString(ostr.str().c_str())); this->CreateString(ostr.str().c_str()));
} copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", this->CreateString("0"));
this->CreateString("0")); buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
buildPhases->AddObject(copyFilesBuildPhase); copyFilesBuildPhase->AddAttribute("files", buildFiles);
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); std::vector<cmSourceFile*>::iterator sfIt;
copyFilesBuildPhase->AddAttribute("files", buildFiles); for ( sfIt = mit->second.begin(); sfIt != mit->second.end(); ++ sfIt )
std::vector<cmSourceFile*>::iterator sfIt; {
for ( sfIt = mit->second.begin(); sfIt != mit->second.end(); ++ sfIt ) cmXCodeObject* xsf =
{ this->CreateXCodeSourceFile(this->CurrentLocalGenerator,
cmXCodeObject* xsf = *sfIt, cmtarget);
this->CreateXCodeSourceFile(this->CurrentLocalGenerator, buildFiles->AddObject(xsf);
*sfIt, cmtarget); }
buildFiles->AddObject(xsf); contentBuildPhases.push_back(copyFilesBuildPhase);
} }
} }
if (cmtarget.GetType() == cmTarget::SHARED_LIBRARY &&
cmtarget.GetPropertyAsBool("FRAMEWORK"))
{
this->AddFrameworkPhases(&cmtarget, buildPhases);
}
}
}
//---------------------------------------------------------------------------- // create framework build phase
void cmGlobalXCodeGenerator::AddFrameworkPhases(cmTarget* target, cmXCodeObject* frameworkBuildPhase = 0;
cmXCodeObject* buildPhases) if (!externalObjFiles.empty())
{ {
const char* headers = target->GetProperty("FRAMEWORK_PUBLIC_HEADERS"); frameworkBuildPhase =
if(!headers) this->CreateObject(cmXCodeObject::PBXFrameworksBuildPhase);
{ frameworkBuildPhase->SetComment("Frameworks");
return; frameworkBuildPhase->AddAttribute("buildActionMask",
} this->CreateString("2147483647"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
cmXCodeObject* copyHeaders = frameworkBuildPhase->AddAttribute("files", buildFiles);
this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase); for(std::vector<cmXCodeObject*>::iterator i = externalObjFiles.begin();
copyHeaders->SetComment("Copy files"); i != externalObjFiles.end(); ++i)
copyHeaders->AddAttribute("buildActionMask", {
this->CreateString("2147483647")); buildFiles->AddObject(*i);
copyHeaders->AddAttribute("dstSubfolderSpec", }
this->CreateString("6")); frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
copyHeaders->AddAttribute("dstPath", this->CreateString("0"));
this->CreateString("Headers")); }
buildPhases->AddObject(copyHeaders);
cmXCodeObject* headersToCopy = // create list of build phases and create the XCode target
this->CreateObject(cmXCodeObject::OBJECT_LIST); cmXCodeObject* buildPhases =
copyHeaders->AddAttribute("files", headersToCopy); this->CreateObject(cmXCodeObject::OBJECT_LIST);
std::vector<std::string> headersVec;
cmSystemTools::ExpandListArgument(headers, this->CreateCustomCommands(buildPhases, sourceBuildPhase,
headersVec); headerBuildPhase, resourceBuildPhase,
cmCustomCommandLines commandLines; contentBuildPhases,
std::vector<std::string> depends; frameworkBuildPhase, cmtarget);
for(std::vector<std::string>::iterator i = headersVec.begin();
i != headersVec.end(); ++i) targets.push_back(this->CreateXCodeTarget(cmtarget, buildPhases));
{
cmCustomCommandLine line;
cmSourceFile* sf = this->CurrentMakefile->GetOrCreateSource(i->c_str());
cmXCodeObject* xsf =
this->CreateXCodeSourceFile(this->CurrentLocalGenerator,
sf, *target);
//std::cerr << "copy header " << sf->GetFullPath() << "\n";
headersToCopy->AddObject(xsf);
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmXCodeObject* cmXCodeObject*
cmGlobalXCodeGenerator::CreateBuildPhase(const char* name, cmGlobalXCodeGenerator::CreateBuildPhase(const char* name,
const char* name2, const char* name2,
cmTarget& cmtarget, cmTarget& cmtarget,
const std::vector<cmCustomCommand>& const std::vector<cmCustomCommand>&
@ -812,6 +892,10 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
cmXCodeObject* cmXCodeObject*
headerBuildPhase, headerBuildPhase,
cmXCodeObject* cmXCodeObject*
resourceBuildPhase,
std::vector<cmXCodeObject*>
contentBuildPhases,
cmXCodeObject*
frameworkBuildPhase, frameworkBuildPhase,
cmTarget& cmtarget) cmTarget& cmtarget)
{ {
@ -846,15 +930,19 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
cmXCodeObject* preBuildPhase = cmXCodeObject* preBuildPhase =
this->CreateBuildPhase("CMake PreBuild Rules", "preBuildCommands", this->CreateBuildPhase("CMake PreBuild Rules", "preBuildCommands",
cmtarget, prebuild); cmtarget, prebuild);
// create prebuild phase // create prelink phase
cmXCodeObject* preLinkPhase = cmXCodeObject* preLinkPhase =
this->CreateBuildPhase("CMake PreLink Rules", "preLinkCommands", this->CreateBuildPhase("CMake PreLink Rules", "preLinkCommands",
cmtarget, prelink); cmtarget, prelink);
// create prebuild phase // create postbuild phase
cmXCodeObject* postBuildPhase = cmXCodeObject* postBuildPhase =
this->CreateBuildPhase("CMake PostBuild Rules", "postBuildPhase", this->CreateBuildPhase("CMake PostBuild Rules", "postBuildPhase",
cmtarget, postbuild); cmtarget, postbuild);
// the order here is the order they will be built in
// The order here is the order they will be built in.
// The order "headers, resources, sources" mimics a native project generated
// from an xcode template...
//
if(preBuildPhase) if(preBuildPhase)
{ {
buildPhases->AddObject(preBuildPhase); buildPhases->AddObject(preBuildPhase);
@ -863,14 +951,23 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
{ {
buildPhases->AddObject(cmakeRulesBuildPhase); buildPhases->AddObject(cmakeRulesBuildPhase);
} }
if(sourceBuildPhase)
{
buildPhases->AddObject(sourceBuildPhase);
}
if(headerBuildPhase) if(headerBuildPhase)
{ {
buildPhases->AddObject(headerBuildPhase); buildPhases->AddObject(headerBuildPhase);
} }
if(resourceBuildPhase)
{
buildPhases->AddObject(resourceBuildPhase);
}
std::vector<cmXCodeObject*>::iterator cit;
for (cit = contentBuildPhases.begin(); cit != contentBuildPhases.end(); ++cit)
{
buildPhases->AddObject(*cit);
}
if(sourceBuildPhase)
{
buildPhases->AddObject(sourceBuildPhase);
}
if(preLinkPhase) if(preLinkPhase)
{ {
buildPhases->AddObject(preLinkPhase); buildPhases->AddObject(preLinkPhase);
@ -1312,27 +1409,33 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
{ {
fileType = "wrapper.framework"; fileType = "wrapper.framework";
productType = "com.apple.product-type.framework"; productType = "com.apple.product-type.framework";
break;
const char* version = target.GetProperty("FRAMEWORK_VERSION");
buildSettings->AddAttribute("FRAMEWORK_VERSION",
this->CreateString(version));
} }
fileType = "compiled.mach-o.dylib"; else
productType = "com.apple.product-type.library.dynamic";
buildSettings->AddAttribute("LIBRARY_STYLE",
this->CreateString("DYNAMIC"));
buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
this->CreateString("1"));
buildSettings->AddAttribute("DYLIB_CURRENT_VERSION",
this->CreateString("1"));
// Add the flags to create a shared library.
std::string createFlags =
this->LookupFlags("CMAKE_SHARED_LIBRARY_CREATE_", lang, "_FLAGS",
"-dynamiclib");
if(!createFlags.empty())
{ {
extraLinkOptions += " "; fileType = "compiled.mach-o.dylib";
extraLinkOptions += createFlags; productType = "com.apple.product-type.library.dynamic";
// Add the flags to create a shared library.
std::string createFlags =
this->LookupFlags("CMAKE_SHARED_LIBRARY_CREATE_", lang, "_FLAGS",
"-dynamiclib");
if(!createFlags.empty())
{
extraLinkOptions += " ";
extraLinkOptions += createFlags;
}
} }
buildSettings->AddAttribute("LIBRARY_STYLE",
this->CreateString("DYNAMIC"));
buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
this->CreateString("1"));
buildSettings->AddAttribute("DYLIB_CURRENT_VERSION",
this->CreateString("1"));
break; break;
} }
case cmTarget::EXECUTABLE: case cmTarget::EXECUTABLE:
@ -1577,7 +1680,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
target->SetComment(cmtarget.GetName()); target->SetComment(cmtarget.GetName());
cmXCodeObject* buildPhases = cmXCodeObject* buildPhases =
this->CreateObject(cmXCodeObject::OBJECT_LIST); this->CreateObject(cmXCodeObject::OBJECT_LIST);
this->CreateCustomCommands(buildPhases, 0, 0, 0, cmtarget); std::vector<cmXCodeObject*> emptyContentVector;
this->CreateCustomCommands(buildPhases, 0, 0, 0, emptyContentVector, 0, cmtarget);
target->AddAttribute("buildPhases", buildPhases); target->AddAttribute("buildPhases", buildPhases);
cmXCodeObject* buildSettings = cmXCodeObject* buildSettings =
this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
@ -1785,7 +1889,6 @@ void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target,
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalXCodeGenerator::AppendOrAddBuildSetting(cmXCodeObject* settings, void cmGlobalXCodeGenerator::AppendOrAddBuildSetting(cmXCodeObject* settings,
const char* attribute, const char* attribute,
@ -2042,6 +2145,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;
// Same skipping logic here as in CreateXCodeTargets so that we do not
// end up with (empty anyhow) ALL_BUILD and XCODE_DEPEND_HELPER source
// groups:
//
if(cmtarget.GetType() == cmTarget::UTILITY ||
cmtarget.GetType() == cmTarget::GLOBAL_TARGET)
{
continue;
}
// add the soon to be generated Info.plist file as a source for a // add the soon to be generated Info.plist file as a source for a
// MACOSX_BUNDLE file // MACOSX_BUNDLE file
if(cmtarget.GetPropertyAsBool("MACOSX_BUNDLE")) if(cmtarget.GetPropertyAsBool("MACOSX_BUNDLE"))
@ -2053,29 +2167,9 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
this->CurrentMakefile->GetOrCreateSource(plistFile.c_str(), true); this->CurrentMakefile->GetOrCreateSource(plistFile.c_str(), true);
cmtarget.AddSourceFile(sf); cmtarget.AddSourceFile(sf);
} }
std::vector<cmSourceFile*> classes = cmtarget.GetSourceFiles(); std::vector<cmSourceFile*> classes = cmtarget.GetSourceFiles();
// add framework copy headers
if (cmtarget.GetType() == cmTarget::SHARED_LIBRARY &&
cmtarget.GetPropertyAsBool("FRAMEWORK"))
{
const char* headers = cmtarget.GetProperty("FRAMEWORK_PUBLIC_HEADERS");
if(!headers)
{
return;
}
std::vector<std::string> headersVec;
cmSystemTools::ExpandListArgument(headers,
headersVec);
cmCustomCommandLines commandLines;
std::vector<std::string> depends;
for(std::vector<std::string>::iterator h = headersVec.begin();
h != headersVec.end(); ++h)
{
cmSourceFile* sf
= this->CurrentMakefile->GetOrCreateSource(h->c_str());
classes.push_back(sf);
}
}
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++)
{ {
@ -2086,11 +2180,13 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
mf->FindSourceGroup(source.c_str(), sourceGroups); mf->FindSourceGroup(source.c_str(), sourceGroups);
cmXCodeObject* pbxgroup = cmXCodeObject* pbxgroup =
this->CreateOrGetPBXGroup(cmtarget, &sourceGroup); this->CreateOrGetPBXGroup(cmtarget, &sourceGroup);
this->GroupMap[sf] = pbxgroup; cmStdString key = GetGroupMapKey(cmtarget, sf);
this->GroupMap[key] = pbxgroup;
} }
} }
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmXCodeObject* cmGlobalXCodeGenerator cmXCodeObject* cmGlobalXCodeGenerator
::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg) ::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg)
@ -2098,7 +2194,7 @@ cmXCodeObject* cmGlobalXCodeGenerator
cmStdString s = cmtarget.GetName(); cmStdString s = cmtarget.GetName();
s += "/"; s += "/";
s += sg->GetName(); s += sg->GetName();
std::map<cmStdString, cmXCodeObject* >::iterator i = std::map<cmStdString, cmXCodeObject* >::iterator i =
this->GroupNameMap.find(s); this->GroupNameMap.find(s);
if(i != this->GroupNameMap.end()) if(i != this->GroupNameMap.end())
{ {
@ -2125,7 +2221,16 @@ cmXCodeObject* cmGlobalXCodeGenerator
tgroup->AddAttribute("sourceTree", this->CreateString("<group>")); tgroup->AddAttribute("sourceTree", this->CreateString("<group>"));
this->SourcesGroupChildren->AddObject(tgroup); this->SourcesGroupChildren->AddObject(tgroup);
} }
// If it's the default source group (empty name) then put the source file
// directly in the tgroup...
//
if (cmStdString(sg->GetName()) == "")
{
this->GroupNameMap[s] = tgroup;
return tgroup;
}
cmXCodeObject* tgroupChildren = tgroup->GetObject("children"); cmXCodeObject* tgroupChildren = tgroup->GetObject("children");
cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup); cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
cmXCodeObject* groupChildren = cmXCodeObject* groupChildren =
@ -2151,6 +2256,7 @@ void cmGlobalXCodeGenerator
this->ClearXCodeObjects(); this->ClearXCodeObjects();
this->RootObject = 0; this->RootObject = 0;
this->SourcesGroupChildren = 0; this->SourcesGroupChildren = 0;
this->ResourcesGroupChildren = 0;
this->MainGroupChildren = 0; this->MainGroupChildren = 0;
cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO")); group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO"));
@ -2209,9 +2315,22 @@ void cmGlobalXCodeGenerator
} }
sourcesGroup->AddAttribute("sourceTree", this->CreateString("<group>")); sourcesGroup->AddAttribute("sourceTree", this->CreateString("<group>"));
this->MainGroupChildren->AddObject(sourcesGroup); this->MainGroupChildren->AddObject(sourcesGroup);
cmXCodeObject* resourcesGroup = this->CreateObject(cmXCodeObject::PBXGroup);
this->ResourcesGroupChildren =
this->CreateObject(cmXCodeObject::OBJECT_LIST);
resourcesGroup->AddAttribute("name", this->CreateString("Resources"));
resourcesGroup->AddAttribute("children", this->ResourcesGroupChildren);
if(this->XcodeVersion == 15)
{
resourcesGroup->AddAttribute("refType", this->CreateString("4"));
}
resourcesGroup->AddAttribute("sourceTree", this->CreateString("<group>"));
this->MainGroupChildren->AddObject(resourcesGroup);
// now create the cmake groups // now create the cmake groups
this->CreateGroups(root, generators); this->CreateGroups(root, generators);
cmXCodeObject* productGroup = this->CreateObject(cmXCodeObject::PBXGroup); cmXCodeObject* productGroup = this->CreateObject(cmXCodeObject::PBXGroup);
productGroup->AddAttribute("name", this->CreateString("Products")); productGroup->AddAttribute("name", this->CreateString("Products"));
if(this->XcodeVersion == 15) if(this->XcodeVersion == 15)
@ -2533,7 +2652,7 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root,
if(this->XcodeVersion > 20) if(this->XcodeVersion > 20)
{ {
xcodeDir += "proj"; xcodeDir += "proj";
} }
cmSystemTools::MakeDirectory(xcodeDir.c_str()); cmSystemTools::MakeDirectory(xcodeDir.c_str());
std::string xcodeProjFile = xcodeDir + "/project.pbxproj"; std::string xcodeProjFile = xcodeDir + "/project.pbxproj";
cmGeneratedFileStream fout(xcodeProjFile.c_str()); cmGeneratedFileStream fout(xcodeProjFile.c_str());
@ -2609,6 +2728,7 @@ std::string cmGlobalXCodeGenerator::ConvertToRelativeForXCode(const char* p)
} }
} }
//----------------------------------------------------------------------------
std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p) std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p)
{ {
std::string ret = p; std::string ret = p;
@ -2622,6 +2742,7 @@ std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p)
return ret; return ret;
} }
//----------------------------------------------------------------------------
void cmGlobalXCodeGenerator:: void cmGlobalXCodeGenerator::
GetTargetObjectFileDirectories(cmTarget* target, GetTargetObjectFileDirectories(cmTarget* target,
std::vector<std::string>& std::vector<std::string>&

View File

@ -65,9 +65,6 @@ public:
const char* config, const char* config,
bool ignoreErrors, bool ignoreErrors,
bool fast); bool fast);
// add extra build phases for a framework target
void AddFrameworkPhases(cmTarget*, cmXCodeObject* buildPhases);
/** /**
* Generate the all required files for building this project/tree. This * Generate the all required files for building this project/tree. This
@ -101,9 +98,11 @@ private:
void CreateCustomCommands(cmXCodeObject* buildPhases, void CreateCustomCommands(cmXCodeObject* buildPhases,
cmXCodeObject* sourceBuildPhase, cmXCodeObject* sourceBuildPhase,
cmXCodeObject* headerBuildPhase, cmXCodeObject* headerBuildPhase,
cmXCodeObject* resourceBuildPhase,
std::vector<cmXCodeObject*> contentBuildPhases,
cmXCodeObject* frameworkBuildPhase, cmXCodeObject* frameworkBuildPhase,
cmTarget& cmtarget); cmTarget& cmtarget);
void AddCommandsToBuildPhase(cmXCodeObject* buildphase, void AddCommandsToBuildPhase(cmXCodeObject* buildphase,
cmTarget& target, cmTarget& target,
std::vector<cmCustomCommand> std::vector<cmCustomCommand>
@ -184,6 +183,7 @@ protected:
private: private:
cmXCodeObject* MainGroupChildren; cmXCodeObject* MainGroupChildren;
cmXCodeObject* SourcesGroupChildren; cmXCodeObject* SourcesGroupChildren;
cmXCodeObject* ResourcesGroupChildren;
cmMakefile* CurrentMakefile; cmMakefile* CurrentMakefile;
cmLocalGenerator* CurrentLocalGenerator; cmLocalGenerator* CurrentLocalGenerator;
std::vector<std::string> CurrentConfigurationTypes; std::vector<std::string> CurrentConfigurationTypes;
@ -193,9 +193,10 @@ private:
std::set<cmStdString> TargetDoneSet; std::set<cmStdString> TargetDoneSet;
std::vector<std::string> CurrentOutputDirectoryComponents; std::vector<std::string> CurrentOutputDirectoryComponents;
std::vector<std::string> ProjectOutputDirectoryComponents; std::vector<std::string> ProjectOutputDirectoryComponents;
std::map<cmSourceFile*, cmXCodeObject* > GroupMap; std::map<cmStdString, cmXCodeObject* > GroupMap;
std::map<cmStdString, cmXCodeObject* > GroupNameMap; std::map<cmStdString, cmXCodeObject* > GroupNameMap;
std::map<cmStdString, cmXCodeObject* > TargetGroup; std::map<cmStdString, cmXCodeObject* > TargetGroup;
std::map<cmStdString, cmXCodeObject* > FileRefs;
std::vector<std::string> Architectures; std::vector<std::string> Architectures;
}; };

View File

@ -1704,19 +1704,26 @@ cmLocalUnixMakefileGenerator3
target.GetExecutableNames(targetName, targetNameReal, targetNameImport, target.GetExecutableNames(targetName, targetNameReal, targetNameImport,
targetNamePDB, this->ConfigurationName.c_str()); targetNamePDB, this->ConfigurationName.c_str());
std::string obj; std::string obj;
// Construct the full path version of the names.
//
// If target is a MACOSX_BUNDLE target, then the package location is
// relative to "${targetDir}/${targetName}.app/Contents"... else it is
// relative to "${targetDir}"...
//
obj = target.GetDirectory();
obj += "/";
if ( target.GetPropertyAsBool("MACOSX_BUNDLE") ) if ( target.GetPropertyAsBool("MACOSX_BUNDLE") )
{ {
// Construct the full path version of the names.
obj = target.GetDirectory();
obj += "/";
obj += targetName + ".app/Contents/"; obj += targetName + ".app/Contents/";
obj += fileTargetDirectory;
} }
else else
{ {
// Framework not handled yet // Emit warning here...? MACOSX_PACKAGE_LOCATION is "most useful" in a
abort(); // MACOSX_BUNDLE...
} }
obj += fileTargetDirectory;
obj = cmSystemTools::RelativePath obj = cmSystemTools::RelativePath
(this->Makefile->GetHomeOutputDirectory(), obj.c_str()); (this->Makefile->GetHomeOutputDirectory(), obj.c_str());
obj += "/"; obj += "/";

View File

@ -1,7 +1,24 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmLocalXCodeGenerator.h" #include "cmLocalXCodeGenerator.h"
#include "cmGlobalXCodeGenerator.h" #include "cmGlobalXCodeGenerator.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
//----------------------------------------------------------------------------
cmLocalXCodeGenerator::cmLocalXCodeGenerator() cmLocalXCodeGenerator::cmLocalXCodeGenerator()
{ {
// the global generator does this, so do not // the global generator does this, so do not
@ -9,10 +26,12 @@ cmLocalXCodeGenerator::cmLocalXCodeGenerator()
this->EmitUniversalBinaryFlags = false; this->EmitUniversalBinaryFlags = false;
} }
//----------------------------------------------------------------------------
cmLocalXCodeGenerator::~cmLocalXCodeGenerator() cmLocalXCodeGenerator::~cmLocalXCodeGenerator()
{ {
} }
//----------------------------------------------------------------------------
std::string std::string
cmLocalXCodeGenerator::GetTargetDirectory(cmTarget const&) const cmLocalXCodeGenerator::GetTargetDirectory(cmTarget const&) const
{ {
@ -20,6 +39,7 @@ cmLocalXCodeGenerator::GetTargetDirectory(cmTarget const&) const
return ""; return "";
} }
//----------------------------------------------------------------------------
void cmLocalXCodeGenerator:: void cmLocalXCodeGenerator::
GetTargetObjectFileDirectories(cmTarget* target, GetTargetObjectFileDirectories(cmTarget* target,
std::vector<std::string>& std::vector<std::string>&

View File

@ -1,6 +1,23 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmXCode21Object.h" #include "cmXCode21Object.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
//----------------------------------------------------------------------------
cmXCode21Object::cmXCode21Object(PBXType ptype, Type type) cmXCode21Object::cmXCode21Object(PBXType ptype, Type type)
:cmXCodeObject(ptype, type) :cmXCodeObject(ptype, type)
{ {
@ -24,7 +41,7 @@ void cmXCode21Object::PrintComment(std::ostream& out)
out << " */"; out << " */";
} }
//----------------------------------------------------------------------------
void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v, void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v,
std::ostream& out, PBXType t) std::ostream& out, PBXType t)
{ {
@ -56,6 +73,7 @@ void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v,
out << "/* End " << PBXTypeNames[t] << " section */\n"; out << "/* End " << PBXTypeNames[t] << " section */\n";
} }
//----------------------------------------------------------------------------
void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v, void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v,
std::ostream& out) std::ostream& out)
{ {

View File

@ -1,3 +1,19 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmXCode21Object_h #ifndef cmXCode21Object_h
#define cmXCode21Object_h #define cmXCode21Object_h

View File

@ -17,6 +17,7 @@
#include "cmXCodeObject.h" #include "cmXCodeObject.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
//----------------------------------------------------------------------------
const char* cmXCodeObject::PBXTypeNames[] = { const char* cmXCodeObject::PBXTypeNames[] = {
"PBXGroup", "PBXBuildStyle", "PBXProject", "PBXHeadersBuildPhase", "PBXGroup", "PBXBuildStyle", "PBXProject", "PBXHeadersBuildPhase",
"PBXSourcesBuildPhase", "PBXFrameworksBuildPhase", "PBXNativeTarget", "PBXSourcesBuildPhase", "PBXFrameworksBuildPhase", "PBXNativeTarget",
@ -30,12 +31,12 @@ const char* cmXCodeObject::PBXTypeNames[] = {
"None" "None"
}; };
//----------------------------------------------------------------------------
cmXCodeObject::~cmXCodeObject() cmXCodeObject::~cmXCodeObject()
{ {
this->Version = 15; this->Version = 15;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmXCodeObject::cmXCodeObject(PBXType ptype, Type type) cmXCodeObject::cmXCodeObject(PBXType ptype, Type type)
{ {
@ -143,7 +144,33 @@ void cmXCodeObject::Print(std::ostream& out)
object->ObjectAttributes.end(); ++j) object->ObjectAttributes.end(); ++j)
{ {
cmXCodeObject::Indent(4 *indentFactor, out); cmXCodeObject::Indent(4 *indentFactor, out);
out << j->first << " = " << j->second->String << ";";
if(j->second->TypeValue == STRING)
{
out << j->first << " = " << j->second->String << ";";
}
else if(j->second->TypeValue == OBJECT_LIST)
{
out << j->first << " = (";
for(unsigned int k = 0; k < j->second->List.size(); k++)
{
if(j->second->List[k]->TypeValue == STRING)
{
out << j->second->List[k]->String << ", ";
}
else
{
out << "List_" << k << "_TypeValue_IS_NOT_STRING, ";
}
}
out << ");";
}
else
{
out << j->first << " = error_unexpected_TypeValue_" <<
j->second->TypeValue << ";";
}
out << separator; out << separator;
} }
cmXCodeObject::Indent(3 *indentFactor, out); cmXCodeObject::Indent(3 *indentFactor, out);
@ -189,7 +216,7 @@ void cmXCodeObject::PrintList(std::vector<cmXCodeObject*> const& objs,
out << "};\n"; out << "};\n";
} }
//----------------------------------------------------------------------------
void cmXCodeObject::CopyAttributes(cmXCodeObject* copy) void cmXCodeObject::CopyAttributes(cmXCodeObject* copy)
{ {
this->ObjectAttributes = copy->ObjectAttributes; this->ObjectAttributes = copy->ObjectAttributes;
@ -198,6 +225,7 @@ void cmXCodeObject::CopyAttributes(cmXCodeObject* copy)
this->Object = copy->Object; this->Object = copy->Object;
} }
//----------------------------------------------------------------------------
void cmXCodeObject::SetString(const char* s) void cmXCodeObject::SetString(const char* s)
{ {
std::string ss = s; std::string ss = s;

View File

@ -1,11 +1,29 @@
project(Framework) project(Framework)
add_library(foo SHARED foo.cxx foo.h) add_library(foo SHARED
foo.cxx
foo.h
foo2.h
fooPublic.h
fooPrivate.h
fooNeither.h
fooBoth.h
test.lua
)
set_target_properties(foo PROPERTIES set_target_properties(foo PROPERTIES
FRAMEWORK TRUE FRAMEWORK TRUE
FRAMEWORK_PUBLIC_HEADERS "foo.h;foo2.h" FRAMEWORK_VERSION ver3
FRAMEWORK_VERSION ver2 )
FRAMEWORK_RESOURCES "test.lua" # fooNeither.h is marked neither public nor private...
# fooBoth.h is marked both public and private... (private wins...)
set_source_files_properties(foo.h foo2.h fooPublic.h fooBoth.h PROPERTIES
FRAMEWORK_PUBLIC_HEADER TRUE
)
set_source_files_properties(fooPrivate.h fooBoth.h PROPERTIES
FRAMEWORK_PRIVATE_HEADER TRUE
)
set_source_files_properties(test.lua PROPERTIES
FRAMEWORK_RESOURCE TRUE
) )
add_executable(bar bar.cxx) add_executable(bar bar.cxx)
target_link_libraries(bar foo) target_link_libraries(bar foo)
@ -16,12 +34,19 @@ target_link_libraries(bar foo)
# a framework... The framework properties only apply when the library type # a framework... The framework properties only apply when the library type
# is SHARED. # is SHARED.
# #
add_library(fooStatic STATIC foo.cxx foo.h) add_library(fooStatic STATIC
foo.cxx
foo.h
foo2.h
fooPublic.h
fooPrivate.h
fooNeither.h
fooBoth.h
test.lua
)
set_target_properties(fooStatic PROPERTIES set_target_properties(fooStatic PROPERTIES
FRAMEWORK TRUE FRAMEWORK TRUE
FRAMEWORK_PUBLIC_HEADERS "foo.h;foo2.h" FRAMEWORK_VERSION none
FRAMEWORK_VERSION ver2
FRAMEWORK_RESOURCES "test.lua"
) )
add_executable(barStatic bar.cxx) add_executable(barStatic bar.cxx)
target_link_libraries(barStatic fooStatic) target_link_libraries(barStatic fooStatic)

View File

@ -0,0 +1 @@
fooBothh

View File

@ -0,0 +1 @@
fooNeitherh

View File

@ -0,0 +1 @@
fooPrivateh

View File

@ -0,0 +1 @@
fooPublich

View File

@ -0,0 +1 @@
test.lua