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

Method GenerateMainFile

Source/cmExportBuildPackageInfoGenerator.cxx:29–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29bool cmExportBuildPackageInfoGenerator::GenerateMainFile(std::ostream& os)
30{
31 if (!this->CollectExports([&](cmGeneratorTarget const*) {})) {
32 return false;
33 }
34
35 if (!this->CheckPackage()) {
36 return false;
37 }
38
39 Json::Value root = this->GeneratePackageInfo();
40 root["cps_path"] = "@prefix@";
41
42 Json::Value& components = root["components"];
43
44 // Create all the imported targets.
45 for (auto const& exp : this->Exports) {
46 cmGeneratorTarget* const target = exp.Target;
47 cmStateEnums::TargetType targetType = this->GetExportTargetType(target);
48
49 Json::Value* const component =
50 this->GenerateImportTarget(components, target, targetType);
51 if (!component) {
52 return false;
53 }
54
55 ImportPropertyMap properties;
56 if (!this->PopulateInterfaceProperties(target, properties)) {
57 return false;
58 }
59 this->PopulateInterfaceLinkLibrariesProperty(
60 target, cmGeneratorExpression::InstallInterface, properties);
61
62 if (targetType != cmStateEnums::INTERFACE_LIBRARY) {
63 auto configurations = Json::Value{ Json::objectValue };
64
65 // Add per-configuration properties.
66 for (std::string const& c : this->Configurations) {
67 this->GenerateInterfacePropertiesConfig(configurations, target, c);
68 }
69
70 if (!configurations.empty()) {
71 (*component)["configurations"] = configurations;
72 }
73 }
74
75 // De-duplicate include directories prior to generation.
76 auto it = properties.find("INTERFACE_INCLUDE_DIRECTORIES");
77 if (it != properties.end()) {
78 auto list = cmList{ it->second };
79 list = cmList{ list.begin(), cmRemoveDuplicates(list) };
80 properties["INTERFACE_INCLUDE_DIRECTORIES"] = list.to_string();
81 }
82
83 // Set configuration-agnostic properties for component.
84 this->GenerateInterfaceProperties(*component, target, properties);
85 }
86

Callers

nothing calls this directly

Calls 15

cmRemoveDuplicatesFunction · 0.85
CheckPackageMethod · 0.80
GeneratePackageInfoMethod · 0.80
to_stringMethod · 0.80
WritePackageInfoMethod · 0.80
CollectExportsMethod · 0.45
GetExportTargetTypeMethod · 0.45
GenerateImportTargetMethod · 0.45

Tested by

no test coverage detected