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

Method FindTargetToUse

Source/cmMakefile.cxx:3872–3906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3870}
3871
3872cmTarget* cmMakefile::FindTargetToUse(
3873 std::string const& name, cmStateEnums::TargetDomainSet domains) const
3874{
3875 // Look for an imported target. These take priority because they
3876 // are more local in scope and do not have to be globally unique.
3877 auto targetName = name;
3878 if (domains.contains(cmStateEnums::TargetDomain::ALIAS)) {
3879 // Look for local alias targets.
3880 auto alias = this->AliasTargets.find(name);
3881 if (alias != this->AliasTargets.end()) {
3882 targetName = alias->second;
3883 }
3884 }
3885 auto const imported = this->ImportedTargets.find(targetName);
3886
3887 bool const useForeign =
3888 domains.contains(cmStateEnums::TargetDomain::FOREIGN);
3889 bool const useNative = domains.contains(cmStateEnums::TargetDomain::NATIVE);
3890
3891 if (imported != this->ImportedTargets.end()) {
3892 if (imported->second->IsForeign() ? useForeign : useNative) {
3893 return imported->second;
3894 }
3895 }
3896
3897 // Look for a target built in this directory.
3898 if (cmTarget* t = this->FindLocalNonAliasTarget(name)) {
3899 if (t->IsForeign() ? useForeign : useNative) {
3900 return t;
3901 }
3902 }
3903
3904 // Look for a target built in this project.
3905 return this->GetGlobalGenerator()->FindTarget(name, domains);
3906}
3907
3908bool cmMakefile::IsAlias(std::string const& name) const
3909{

Callers 15

EnforceUniqueNameMethod · 0.95
HandleLevel1Method · 0.80
HandleTargetModeFunction · 0.80
GenerateMethod · 0.80
cmAddExecutableCommandFunction · 0.80
cmAddLibraryCommandFunction · 0.80

Calls 6

GetGlobalGeneratorMethod · 0.95
FindTargetMethod · 0.80
findMethod · 0.45
endMethod · 0.45
IsForeignMethod · 0.45

Tested by

no test coverage detected