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

Method GetRealDependency

Source/cmLocalGenerator.cxx:2308–2401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2306}
2307
2308bool cmLocalGenerator::GetRealDependency(std::string const& inName,
2309 std::string const& config,
2310 std::string& dep)
2311{
2312 // Older CMake code may specify the dependency using the target
2313 // output file rather than the target name. Such code would have
2314 // been written before there was support for target properties that
2315 // modify the name so stripping down to just the file name should
2316 // produce the target name in this case.
2317 std::string name = cmSystemTools::GetFilenameName(inName);
2318
2319 // If the input name is the empty string, there is no real
2320 // dependency. Short-circuit the other checks:
2321 if (name.empty()) {
2322 return false;
2323 }
2324 if (cmHasSuffix(name, ".exe"_s)) {
2325 name = cmSystemTools::GetFilenameWithoutLastExtension(name);
2326 }
2327
2328 // Look for a CMake target with the given name.
2329 if (cmGeneratorTarget* target = this->FindGeneratorTargetToUse(name)) {
2330 // make sure it is not just a coincidence that the target name
2331 // found is part of the inName
2332 if (cmSystemTools::FileIsFullPath(inName)) {
2333 std::string tLocation;
2334 if (target->GetType() >= cmStateEnums::EXECUTABLE &&
2335 target->GetType() <= cmStateEnums::MODULE_LIBRARY) {
2336 tLocation = target->GetLocation(config);
2337 tLocation = cmSystemTools::GetFilenamePath(tLocation);
2338 tLocation = cmSystemTools::CollapseFullPath(tLocation);
2339 }
2340 std::string depLocation =
2341 cmSystemTools::GetFilenamePath(std::string(inName));
2342 depLocation = cmSystemTools::CollapseFullPath(depLocation);
2343 if (depLocation != tLocation) {
2344 // it is a full path to a depend that has the same name
2345 // as a target but is in a different location so do not use
2346 // the target as the depend
2347 dep = inName;
2348 return true;
2349 }
2350 }
2351 switch (target->GetType()) {
2352 case cmStateEnums::EXECUTABLE:
2353 case cmStateEnums::STATIC_LIBRARY:
2354 case cmStateEnums::SHARED_LIBRARY:
2355 case cmStateEnums::MODULE_LIBRARY:
2356 case cmStateEnums::UNKNOWN_LIBRARY:
2357 dep = target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact,
2358 /*realname=*/true);
2359 return true;
2360 case cmStateEnums::OBJECT_LIBRARY:
2361 // An object library has no single file on which to depend.
2362 // This was listed to get the target-level dependency.
2363 case cmStateEnums::INTERFACE_LIBRARY:
2364 // An interface library has no file on which to depend.
2365 // This was listed to get the target-level dependency.

Callers 7

AppendCustomDependMethod · 0.80
GetDependsMethod · 0.80
WriteCustomRuleMethod · 0.80
WriteCustomRuleMethod · 0.80

Calls 9

cmHasSuffixFunction · 0.85
GetSourceMethod · 0.80
cmStrCatFunction · 0.70
FileExistsFunction · 0.50
emptyMethod · 0.45
GetTypeMethod · 0.45
GetLocationMethod · 0.45
GetFullPathMethod · 0.45

Tested by

no test coverage detected