external dep lib dir
Some checks failed
CI / build-test-release (push) Failing after 13m55s

This commit is contained in:
Jorijn van der Graaf 2026-05-06 03:59:19 +02:00
commit 659103a123
2 changed files with 21 additions and 1 deletions

View file

@ -269,7 +269,20 @@ ExternalBuildResult Crafter::BuildExternal(
} }
if (dep.builder == ExternalBuilder::CMake) { 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) { for (const std::string& lib : dep.libs) {
result.linkFlags.push_back(std::format("-l{}", lib)); result.linkFlags.push_back(std::format("-l{}", lib));
} }

View file

@ -43,6 +43,13 @@ export namespace Crafter {
ExternalBuilder builder = ExternalBuilder::None; ExternalBuilder builder = ExternalBuilder::None;
std::vector<std::string> options; std::vector<std::string> options;
std::vector<fs::path> includeDirs; 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; std::vector<std::string> libs;
}; };