MCPcopy Create free account
hub / github.com/Kitware/CMake / ForTarget

Method ForTarget

Source/cmBuildDatabase.cxx:425–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

423}
424
425cmBuildDatabase cmBuildDatabase::ForTarget(cmGeneratorTarget* gt,
426 std::string const& config)
427{
428 cmBuildDatabase db;
429
430 Set set;
431 set.Name = cmStrCat(gt->GetName(), '@', config);
432 set.FamilyName = gt->GetFamilyName();
433 if (auto* cli = gt->GetLinkInformation(config)) {
434 std::set<cmGeneratorTarget const*> emitted;
435 std::vector<cmGeneratorTarget const*> targets;
436 for (auto const& item : cli->GetItems()) {
437 auto const* linkee = item.Target;
438 if (linkee && linkee->HaveCxx20ModuleSources() &&
439 !linkee->IsImported() && emitted.insert(linkee).second) {
440 set.VisibleSets.push_back(cmStrCat(linkee->GetName(), '@', config));
441 }
442 }
443 }
444
445 for (auto const& sfbt : gt->GetSourceFiles(config)) {
446 auto const* sf = sfbt.Value;
447
448 bool isCXXModule = false;
449 bool isPrivate = true;
450 if (sf->GetLanguage() == "CXX"_s) {
451 auto const* fs = gt->GetFileSetForSource(config, sf);
452 if (fs && fs->GetType() == "CXX_MODULES"_s) {
453 isCXXModule = true;
454 isPrivate = !cmFileSetVisibilityIsForInterface(fs->GetVisibility());
455 }
456 }
457
458 TranslationUnit tu;
459
460 // FIXME: Makefiles will want this to be the current working directory.
461 tu.WorkDirectory = gt->GetLocalGenerator()->GetBinaryDirectory();
462 tu.Source = sf->GetFullPath();
463 if (!gt->IsSynthetic()) {
464 auto* gg = gt->GetGlobalGenerator();
465 std::string const objectDir = gg->ConvertToOutputPath(
466 cmStrCat(gt->GetSupportDirectory(), gg->GetConfigDirectory(config)));
467 std::string const objectFileName = gt->GetObjectName(sf);
468 tu.Object = cmStrCat(objectDir, '/', objectFileName);
469 }
470 if (isCXXModule) {
471 tu.Provides[PlaceholderName] = PlaceholderName;
472 }
473
474 cmGeneratorTarget::ClassifiedFlags classifiedFlags =
475 gt->GetClassifiedFlagsForSource(sf, config);
476 for (auto const& classifiedFlag : classifiedFlags) {
477 if (classifiedFlag.Classification ==
478 cmGeneratorTarget::FlagClassification::BaselineFlag) {
479 tu.BaselineArguments.push_back(classifiedFlag.Flag);
480 tu.LocalArguments.push_back(classifiedFlag.Flag);
481 } else if (classifiedFlag.Classification ==
482 cmGeneratorTarget::FlagClassification::PrivateFlag) {

Callers

nothing calls this directly

Calls 15

moveFunction · 0.85
GetFamilyNameMethod · 0.80
GetLinkInformationMethod · 0.80
GetItemsMethod · 0.80
push_backMethod · 0.80
GetSourceFilesMethod · 0.80
GetLanguageMethod · 0.80
GetFileSetForSourceMethod · 0.80
GetVisibilityMethod · 0.80
GetSupportDirectoryMethod · 0.80

Tested by

no test coverage detected