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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,13 @@ export namespace Crafter {
|
|||
ExternalBuilder builder = ExternalBuilder::None;
|
||||
std::vector<std::string> options;
|
||||
std::vector<fs::path> includeDirs;
|
||||
// Extra library search paths (each becomes a -L flag), interpreted
|
||||
// relative to the CMake build dir. Currently only honoured for
|
||||
// ExternalBuilder::CMake. The CMake builder always adds its
|
||||
// top-level build dir as a -L; libDirs is for projects (msquic,
|
||||
// others) whose CMakeLists set LIBRARY_OUTPUT_DIRECTORY to a subdir
|
||||
// of the build tree.
|
||||
std::vector<fs::path> libDirs;
|
||||
std::vector<std::string> libs;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue