This commit is contained in:
parent
d7a9c85ea6
commit
659103a123
2 changed files with 21 additions and 1 deletions
|
|
@ -269,7 +269,20 @@ ExternalBuildResult Crafter::BuildExternal(
|
|||
}
|
||||
|
||||
if (dep.builder == ExternalBuilder::CMake) {
|
||||
result.linkFlags.push_back(std::format("-L{}", fs::absolute(cmakeBuildDir).string()));
|
||||
// Each search path gets both a -L (link-time) and a -Wl,-rpath
|
||||
// (runtime-loader). The rpath stays embedded in the produced
|
||||
// binary so it picks up shared deps from the cache without any
|
||||
// LD_LIBRARY_PATH gymnastics. Static deps (.a) ignore the rpath
|
||||
// harmlessly.
|
||||
std::string buildDirAbs = fs::absolute(cmakeBuildDir).string();
|
||||
result.linkFlags.push_back(std::format("-L{}", buildDirAbs));
|
||||
result.linkFlags.push_back(std::format("-Wl,-rpath,{}", buildDirAbs));
|
||||
for (const fs::path& libDir : dep.libDirs) {
|
||||
fs::path full = libDir.is_absolute() ? libDir : cmakeBuildDir / libDir;
|
||||
std::string fullAbs = fs::absolute(full).string();
|
||||
result.linkFlags.push_back(std::format("-L{}", fullAbs));
|
||||
result.linkFlags.push_back(std::format("-Wl,-rpath,{}", fullAbs));
|
||||
}
|
||||
for (const std::string& lib : dep.libs) {
|
||||
result.linkFlags.push_back(std::format("-l{}", lib));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue