From e8721af065934457b4ebf4ca819009ab5a2cb3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Sun, 8 Nov 2020 10:49:31 +0100 Subject: [PATCH] libtorch-bin: fix CMake library paths for split outputs The libtorch CMake files are in the `dev` output and used relative paths to locate the shared libraries. This fails, because the libraries are in the `out` output. This change patches the CMake files to use library paths from `out`. See #102146. --- pkgs/development/libraries/science/math/libtorch/bin.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/development/libraries/science/math/libtorch/bin.nix b/pkgs/development/libraries/science/math/libtorch/bin.nix index 6180c14c4d7..7c78f61af69 100644 --- a/pkgs/development/libraries/science/math/libtorch/bin.nix +++ b/pkgs/development/libraries/science/math/libtorch/bin.nix @@ -45,6 +45,14 @@ in stdenv.mkDerivation { # We do not care about Java support... rm -f $out/lib/lib*jni* 2> /dev/null || true + + # Fix up library paths for split outputs + substituteInPlace $dev/share/cmake/Torch/TorchConfig.cmake \ + --replace \''${TORCH_INSTALL_PREFIX}/lib "$out/lib" \ + + substituteInPlace \ + $dev/share/cmake/Caffe2/Caffe2Targets-release.cmake \ + --replace \''${_IMPORT_PREFIX}/lib "$out/lib" \ ''; postFixup = let