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

Method GenerateMainFile

Source/cmExportInstallPackageInfoGenerator.cxx:58–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58bool cmExportInstallPackageInfoGenerator::GenerateMainFile(std::ostream& os)
59{
60 std::vector<cmTargetExport const*> allTargets;
61 {
62 auto visitor = [&](cmTargetExport const* te) { allTargets.push_back(te); };
63
64 if (!this->CollectExports(visitor)) {
65 return false;
66 }
67 }
68
69 if (!this->CheckPackage()) {
70 return false;
71 }
72
73 Json::Value root = this->GeneratePackageInfo();
74 Json::Value& components = root["components"];
75
76 // Compute the relative import prefix for the file
77 std::string const& packagePath = this->GenerateImportPrefix();
78 if (packagePath.empty()) {
79 return false;
80 }
81 root["cps_path"] = packagePath;
82
83 // Create all the imported targets.
84 for (cmTargetExport const* te : allTargets) {
85 cmGeneratorTarget* gt = te->Target;
86 cmStateEnums::TargetType targetType = this->GetExportTargetType(te);
87
88 Json::Value* const component =
89 this->GenerateImportTarget(components, gt, targetType);
90 if (!component) {
91 return false;
92 }
93
94 ImportPropertyMap properties;
95 if (!this->PopulateInterfaceProperties(te, properties)) {
96 return false;
97 }
98 this->PopulateInterfaceLinkLibrariesProperty(
99 gt, cmGeneratorExpression::InstallInterface, properties);
100
101 if (targetType != cmStateEnums::INTERFACE_LIBRARY) {
102 this->RequiresConfigFiles = true;
103 }
104
105 // De-duplicate include directories prior to generation.
106 auto it = properties.find("INTERFACE_INCLUDE_DIRECTORIES");
107 if (it != properties.end()) {
108 auto list = cmList{ it->second };
109 list = cmList{ list.begin(), cmRemoveDuplicates(list) };
110 properties["INTERFACE_INCLUDE_DIRECTORIES"] = list.to_string();
111 }
112
113 // Set configuration-agnostic properties for component.
114 this->GenerateInterfaceProperties(*component, gt, properties);
115 if (!this->GenerateFileSetProperties(*component, gt, te, packagePath)) {

Callers

nothing calls this directly

Calls 15

GenerateImportPrefixMethod · 0.95
cmRemoveDuplicatesFunction · 0.85
push_backMethod · 0.80
CheckPackageMethod · 0.80
GeneratePackageInfoMethod · 0.80
to_stringMethod · 0.80
WritePackageInfoMethod · 0.80
CollectExportsMethod · 0.45

Tested by

no test coverage detected