| 4500 | } |
| 4501 | |
| 4502 | bool cmGlobalXCodeGenerator::CreateGroups( |
| 4503 | std::vector<cmLocalGenerator*>& generators) |
| 4504 | { |
| 4505 | for (auto& generator : generators) { |
| 4506 | for (auto const& gtgt : generator->GetGeneratorTargets()) { |
| 4507 | // Same skipping logic here as in CreateXCodeTargets so that we do not |
| 4508 | // end up with (empty anyhow) ZERO_CHECK, install, or test source |
| 4509 | // groups: |
| 4510 | // |
| 4511 | if (!gtgt->IsInBuildSystem() || |
| 4512 | gtgt->GetType() == cmStateEnums::GLOBAL_TARGET || |
| 4513 | gtgt->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET) { |
| 4514 | continue; |
| 4515 | } |
| 4516 | |
| 4517 | auto addSourceToGroup = [this, >gt, |
| 4518 | &generator](std::string const& source) { |
| 4519 | cmSourceGroup const* sourceGroup = generator->FindSourceGroup(source); |
| 4520 | cmXCodeObject* pbxgroup = |
| 4521 | this->CreateOrGetPBXGroup(gtgt.get(), sourceGroup); |
| 4522 | std::string key = GetGroupMapKeyFromPath(gtgt.get(), source); |
| 4523 | this->GroupMap[key] = pbxgroup; |
| 4524 | }; |
| 4525 | |
| 4526 | // Put cmSourceFile instances in proper groups: |
| 4527 | for (auto const& si : gtgt->GetAllConfigSources()) { |
| 4528 | cmSourceFile const* sf = si.Source; |
| 4529 | if (!sf->GetObjectLibrary().empty()) { |
| 4530 | // Object library files go on the link line instead. |
| 4531 | continue; |
| 4532 | } |
| 4533 | addSourceToGroup(sf->GetFullPath()); |
| 4534 | } |
| 4535 | |
| 4536 | // Add CMakeLists.txt file for user convenience. |
| 4537 | { |
| 4538 | std::string listfile = this->GetCMakeInstance()->GetCMakeListFile( |
| 4539 | gtgt->GetLocalGenerator()->GetCurrentSourceDirectory()); |
| 4540 | cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource( |
| 4541 | listfile, false, cmSourceFileLocationKind::Known); |
| 4542 | sf->SetSpecialSourceType(cmSourceFile::SpecialSourceType::CMakeLists); |
| 4543 | addSourceToGroup(sf->ResolveFullPath()); |
| 4544 | } |
| 4545 | |
| 4546 | // Add the Info.plist we are about to generate for an App Bundle. |
| 4547 | if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) { |
| 4548 | std::string plist = this->ComputeInfoPListLocation(gtgt.get()); |
| 4549 | cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource( |
| 4550 | plist, true, cmSourceFileLocationKind::Known); |
| 4551 | sf->SetSpecialSourceType( |
| 4552 | cmSourceFile::SpecialSourceType::BundleInfoPlist); |
| 4553 | addSourceToGroup(sf->ResolveFullPath()); |
| 4554 | } |
| 4555 | } |
| 4556 | } |
| 4557 | |
| 4558 | // Sort all children of each target group by name alphabetically. |
| 4559 | auto const getName = [](cmXCodeObject* obj) -> cm::string_view { |
no test coverage detected