From d0f12061c32a2afe14c5b910bf6f86156552e3d3 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 24 May 2007 17:06:32 -0400 Subject: [PATCH] ENH: add copy header stuff --- Source/cmGlobalXCodeGenerator.cxx | 69 ++++++++++++++++++++++++++++++- Source/cmGlobalXCodeGenerator.h | 3 ++ 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index a796bae18..e6e431a7f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -729,6 +729,51 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, buildFiles->AddObject(xsf); } } + if(cmtarget.GetPropertyAsBool("FRAMEWORK")) + { + this->AddFrameworkPhases(&cmtarget, buildPhases); + } + } +} + +//---------------------------------------------------------------------------- +void cmGlobalXCodeGenerator::AddFrameworkPhases(cmTarget* target, + cmXCodeObject* buildPhases) +{ + const char* headers = target->GetProperty("FRAMEWORK_PUBLIC_HEADERS"); + if(!headers) + { + return; + } + + cmXCodeObject* copyHeaders = + this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase); + copyHeaders->SetComment("Copy files"); + copyHeaders->AddAttribute("buildActionMask", + this->CreateString("2147483647")); + copyHeaders->AddAttribute("dstSubfolderSpec", + this->CreateString("6")); + copyHeaders->AddAttribute("dstPath", + this->CreateString("Headers")); + buildPhases->AddObject(copyHeaders); + cmXCodeObject* headersToCopy = + this->CreateObject(cmXCodeObject::OBJECT_LIST); + copyHeaders->AddAttribute("files", headersToCopy); + std::vector headersVec; + cmSystemTools::ExpandListArgument(headers, + headersVec); + cmCustomCommandLines commandLines; + std::vector depends; + for(std::vector::iterator i = headersVec.begin(); + i != headersVec.end(); ++i) + { + 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); } } @@ -2008,8 +2053,28 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, cmtarget.GetSourceFiles().push_back (this->CurrentMakefile->AddSource(file)); } - - std::vector & classes = cmtarget.GetSourceFiles(); + std::vector classes = cmtarget.GetSourceFiles(); + // add framework copy headers + if(cmtarget.GetPropertyAsBool("FRAMEWORK")) + { + const char* headers = cmtarget.GetProperty("FRAMEWORK_PUBLIC_HEADERS"); + if(!headers) + { + return; + } + std::vector headersVec; + cmSystemTools::ExpandListArgument(headers, + headersVec); + cmCustomCommandLines commandLines; + std::vector depends; + for(std::vector::iterator i = headersVec.begin(); + i != headersVec.end(); ++i) + { + cmSourceFile* sf + = this->CurrentMakefile->GetOrCreateSource(i->c_str()); + classes.push_back(sf); + } + } for(std::vector::const_iterator s = classes.begin(); s != classes.end(); s++) { diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 5c8caa56e..9bfc62dea 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -65,6 +65,9 @@ public: const char* config, bool ignoreErrors, 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