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

Method IsChrpathUsed

Source/cmGeneratorTarget.cxx:1432–1490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1430}
1431
1432bool cmGeneratorTarget::IsChrpathUsed(std::string const& config) const
1433{
1434 // Only certain target types have an rpath.
1435 if (!(this->GetType() == cmStateEnums::SHARED_LIBRARY ||
1436 this->GetType() == cmStateEnums::MODULE_LIBRARY ||
1437 this->GetType() == cmStateEnums::EXECUTABLE)) {
1438 return false;
1439 }
1440
1441 // If the target will not be installed we do not need to change its
1442 // rpath.
1443 if (!this->Target->GetHaveInstallRule()) {
1444 return false;
1445 }
1446
1447 // Skip chrpath if skipping rpath altogether.
1448 if (this->Makefile->IsOn("CMAKE_SKIP_RPATH")) {
1449 return false;
1450 }
1451
1452 // Skip chrpath if it does not need to be changed at install time.
1453 if (this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) {
1454 return false;
1455 }
1456
1457 // Allow the user to disable builtin chrpath explicitly.
1458 if (this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) {
1459 return false;
1460 }
1461
1462 if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
1463 return true;
1464 }
1465
1466 // Enable if the rpath flag uses a separator and the target uses
1467 // binaries we know how to edit.
1468 std::string ll = this->GetLinkerLanguage(config);
1469 if (!ll.empty()) {
1470 std::string sepVar =
1471 cmStrCat("CMAKE_SHARED_LIBRARY_RUNTIME_", ll, "_FLAG_SEP");
1472 cmValue sep = this->Makefile->GetDefinition(sepVar);
1473 if (cmNonempty(sep)) {
1474 // TODO: Add binary format check to ABI detection and get rid of
1475 // CMAKE_EXECUTABLE_FORMAT.
1476 if (cmValue fmt =
1477 this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) {
1478 if (*fmt == "ELF") {
1479 return true;
1480 }
1481#if defined(CMake_USE_XCOFF_PARSER)
1482 if (*fmt == "XCOFF") {
1483 return true;
1484 }
1485#endif
1486 }
1487 }
1488 }
1489 return false;

Callers 4

AddRPathCheckRuleMethod · 0.80
AddChrpathPatchRuleMethod · 0.80

Calls 9

GetTypeMethod · 0.95
GetPropertyAsBoolMethod · 0.95
GetLinkerLanguageMethod · 0.95
cmNonemptyFunction · 0.85
GetHaveInstallRuleMethod · 0.80
cmStrCatFunction · 0.70
IsOnMethod · 0.45
emptyMethod · 0.45
GetDefinitionMethod · 0.45

Tested by

no test coverage detected