| 799 | using pkgProviders = std::unordered_map<std::string, std::string>; |
| 800 | |
| 801 | cmTarget* CreateCMakeTarget(std::string const& name, std::string const& prefix, |
| 802 | cmPkgConfigResult& pkg, pkgProviders& providers, |
| 803 | cmMakefile& mf) |
| 804 | { |
| 805 | auto* tgt = mf.AddForeignTarget("pkgcfg", cmStrCat(prefix, name)); |
| 806 | |
| 807 | tgt->AppendProperty("VERSION", pkg.Version()); |
| 808 | |
| 809 | auto libs = pkg.Libs(); |
| 810 | for (auto const& flag : libs.LibNames) { |
| 811 | tgt->AppendProperty("INTERFACE_LINK_LIBRARIES", flag.substr(2)); |
| 812 | } |
| 813 | for (auto const& flag : libs.LibDirs) { |
| 814 | tgt->AppendProperty("INTERFACE_LINK_DIRECTORIES", flag.substr(2)); |
| 815 | } |
| 816 | tgt->AppendProperty("INTERFACE_LINK_OPTIONS", |
| 817 | cmList::to_string(libs.LinkOptions)); |
| 818 | |
| 819 | auto cflags = pkg.Cflags(); |
| 820 | for (auto const& flag : cflags.Includes) { |
| 821 | tgt->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES", flag.substr(2)); |
| 822 | } |
| 823 | tgt->AppendProperty("INTERFACE_COMPILE_OPTIONS", |
| 824 | cmList::to_string(cflags.CompileOptions)); |
| 825 | |
| 826 | for (auto& dep : pkg.Requires()) { |
| 827 | auto it = providers.find(dep.Name); |
| 828 | if (it != providers.end()) { |
| 829 | tgt->AppendProperty("INTERFACE_LINK_LIBRARIES", it->second); |
| 830 | continue; |
| 831 | } |
| 832 | |
| 833 | tgt->AppendProperty("INTERFACE_LINK_LIBRARIES", |
| 834 | cmStrCat("@foreign_pkgcfg::", prefix, dep.Name)); |
| 835 | } |
| 836 | return tgt; |
| 837 | } |
| 838 | |
| 839 | bool CheckPackageDependencies( |
| 840 | std::string const& name, std::string const& prefix, cmPkgConfigResult& pkg, |
no test coverage detected
searching dependent graphs…