| 56 | } |
| 57 | |
| 58 | bool 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)) { |
nothing calls this directly
no test coverage detected