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

Function CreateCMakeTarget

Source/cmCMakePkgConfigCommand.cxx:801–837  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

799using pkgProviders = std::unordered_map<std::string, std::string>;
800
801cmTarget* 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
839bool CheckPackageDependencies(
840 std::string const& name, std::string const& prefix, cmPkgConfigResult& pkg,

Callers 1

PopulatePCTargetFunction · 0.85

Calls 11

to_stringFunction · 0.85
AddForeignTargetMethod · 0.80
VersionMethod · 0.80
LibsMethod · 0.80
CflagsMethod · 0.80
RequiresMethod · 0.80
cmStrCatFunction · 0.70
AppendPropertyMethod · 0.45
substrMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…