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

Method ChangeRPath

Source/CPack/cmCPackAppImageGenerator.cxx:398–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396}
397
398bool cmCPackAppImageGenerator::ChangeRPath()
399{
400 // AppImages are mounted in random locations so we need RPATH to resolve to
401 // that location
402 std::string const newRPath = "$ORIGIN/../lib";
403
404 for (std::string const& file : this->files) {
405 cmELF elf(file.c_str());
406
407 auto const type = elf.GetFileType();
408 switch (type) {
409 case cmELF::FileType::FileTypeExecutable:
410 case cmELF::FileType::FileTypeSharedLibrary: {
411 std::string oldRPath;
412 auto const* rpath = elf.GetRPath();
413 if (rpath) {
414 oldRPath = rpath->Value;
415 } else {
416 auto const* runpath = elf.GetRunPath();
417 if (runpath) {
418 oldRPath = runpath->Value;
419 } else {
420 oldRPath = "";
421 }
422 }
423
424 if (cmSystemTools::StringStartsWith(oldRPath, "$ORIGIN")) {
425 // Skip libraries with ORIGIN RPATH set
426 continue;
427 }
428
429 if (!PatchElfSetRPath(file, newRPath)) {
430 return false;
431 }
432
433 break;
434 }
435 default:
436 cmCPackLogger(cmCPackLog::LOG_DEBUG,
437 "ELF <" << file << "> type: " << type << std::endl);
438 break;
439 }
440 }
441
442 return true;
443}
444
445bool cmCPackAppImageGenerator::PatchElfSetRPath(std::string const& file,
446 std::string const& rpath) const

Callers

nothing calls this directly

Calls 4

c_strMethod · 0.80
GetFileTypeMethod · 0.45
GetRPathMethod · 0.45
GetRunPathMethod · 0.45

Tested by

no test coverage detected