Unverified Commit 7677e0f7 authored by Cameron Bytheway's avatar Cameron Bytheway
Browse files

openscad: fix lib3mf linking

This change explicitly sets the LIB3MF_INCLUDEPATH and LIB3MF_LIBPATH
environment variables instead of relying on `pkg-config` resolution.
This is due to the following issues with the existing build logic:

* The library name was using `lib3MF` instead of `lib3mf`. `pkg-config`
  is case-sensitive and is unable to find the former.
* The current `lib3mf` nix artifact exports multiple language bindings
  in the `includedir`. Each language needs to refer to the correct path
  inside of it.
parent 7b56d9dd
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@
, wrapGAppsHook3
, qtwayland
, cairo
, openscad
, runCommand
}:

mkDerivation rec {
@@ -69,7 +71,11 @@ mkDerivation rec {
    ++ lib.optional spacenavSupport libspnav
  ;

  qmakeFlags = [ "VERSION=${version}" ] ++
  qmakeFlags = [
    "VERSION=${version}"
    "LIB3MF_INCLUDEPATH=${lib3mf.dev}/include/lib3mf/Bindings/Cpp"
    "LIB3MF_LIBPATH=${lib3mf}/lib"
  ] ++
    lib.optionals spacenavSupport [
      "ENABLE_SPNAV=1"
      "SPNAV_INCLUDEPATH=${libspnav}/include"
@@ -112,4 +118,14 @@ mkDerivation rec {
    maintainers = with lib.maintainers; [ bjornfor raskin gebner ];
    mainProgram = "openscad";
  };

  passthru.tests = {
    lib3mf_support = runCommand "${pname}-lib3mf-support-test" {
      nativeBuildInputs = [ openscad ];
    } ''
      echo "cube([1, 1, 1]);" | openscad -o cube.3mf -
      echo "import(\"cube.3mf\");" | openscad -o cube-import.3mf -
      mv cube-import.3mf $out
    '';
  };
}