| 4310 | } |
| 4311 | |
| 4312 | void cmGlobalXCodeGenerator::AddEmbeddedObjects( |
| 4313 | cmXCodeObject* target, std::string const& copyFilesBuildPhaseName, |
| 4314 | std::string const& embedPropertyName, std::string const& dstSubfolderSpec, |
| 4315 | int actionsOnByDefault, std::string const& defaultDstPath) |
| 4316 | { |
| 4317 | cmGeneratorTarget* gt = target->GetTarget(); |
| 4318 | if (!gt) { |
| 4319 | cmSystemTools::Error("Error no target on xobject\n"); |
| 4320 | return; |
| 4321 | } |
| 4322 | if (!gt->IsInBuildSystem()) { |
| 4323 | return; |
| 4324 | } |
| 4325 | bool isFrameworkTarget = gt->IsFrameworkOnApple(); |
| 4326 | bool isBundleTarget = gt->GetPropertyAsBool("MACOSX_BUNDLE"); |
| 4327 | bool isCFBundleTarget = gt->IsCFBundleOnApple(); |
| 4328 | if (!(isFrameworkTarget || isBundleTarget || isCFBundleTarget)) { |
| 4329 | return; |
| 4330 | } |
| 4331 | cmValue files = gt->GetProperty(embedPropertyName); |
| 4332 | if (!files) { |
| 4333 | return; |
| 4334 | } |
| 4335 | |
| 4336 | // Create an "Embedded Frameworks" build phase |
| 4337 | auto* copyFilesBuildPhase = |
| 4338 | this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase); |
| 4339 | copyFilesBuildPhase->SetComment(copyFilesBuildPhaseName); |
| 4340 | copyFilesBuildPhase->AddAttribute("buildActionMask", |
| 4341 | this->CreateString("2147483647")); |
| 4342 | copyFilesBuildPhase->AddAttribute("dstSubfolderSpec", |
| 4343 | this->CreateString(dstSubfolderSpec)); |
| 4344 | copyFilesBuildPhase->AddAttribute( |
| 4345 | "name", this->CreateString(copyFilesBuildPhaseName)); |
| 4346 | if (cmValue fwEmbedPath = |
| 4347 | gt->GetProperty(cmStrCat(embedPropertyName, "_PATH"))) { |
| 4348 | copyFilesBuildPhase->AddAttribute("dstPath", |
| 4349 | this->CreateString(*fwEmbedPath)); |
| 4350 | } else { |
| 4351 | copyFilesBuildPhase->AddAttribute("dstPath", |
| 4352 | this->CreateString(defaultDstPath)); |
| 4353 | } |
| 4354 | copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", |
| 4355 | this->CreateString("0")); |
| 4356 | cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); |
| 4357 | // Collect all embedded frameworks and dylibs and add them to build phase |
| 4358 | cmList relFiles{ *files }; |
| 4359 | for (std::string const& relFile : relFiles) { |
| 4360 | cmXCodeObject* buildFile{ nullptr }; |
| 4361 | std::string filePath = relFile; |
| 4362 | auto* genTarget = this->FindGeneratorTarget(relFile); |
| 4363 | if (genTarget) { |
| 4364 | // This is a target - get it's product path reference |
| 4365 | auto* xcTarget = this->FindXCodeTarget(genTarget); |
| 4366 | if (!xcTarget) { |
| 4367 | cmSystemTools::Error( |
| 4368 | cmStrCat("Can not find a target for ", genTarget->GetName())); |
| 4369 | continue; |
no test coverage detected