| 27 | } |
| 28 | |
| 29 | bool 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 |
nothing calls this directly
no test coverage detected