1{ lib, stdenv, fetchFromGitHub, cmake, ninja, automaticcomponenttoolkit
2, pkg-config, libzip, gtest, openssl, libuuid, libossp_uuid }:
3
4stdenv.mkDerivation rec {
5 pname = "lib3mf";
6 version = "2.2.0";
7
8 src = fetchFromGitHub {
9 owner = "3MFConsortium";
10 repo = pname;
11 rev = "v${version}";
12 sha256 = "sha256-WMTTYYgpCIM86a6Jw8iah/YVXN9T5youzEieWL/d+Bc=";
13 };
14
15 nativeBuildInputs = [ cmake ninja pkg-config ];
16
17 outputs = [ "out" "dev" ];
18
19 cmakeFlags = [
20 "-DCMAKE_INSTALL_INCLUDEDIR=include/lib3mf"
21 "-DUSE_INCLUDED_ZLIB=OFF"
22 "-DUSE_INCLUDED_LIBZIP=OFF"
23 "-DUSE_INCLUDED_GTEST=OFF"
24 "-DUSE_INCLUDED_SSL=OFF"
25 ];
26
27 buildInputs = [
28 libzip gtest openssl
29 ] ++ (if stdenv.isDarwin then [ libossp_uuid ] else [ libuuid ]);
30
31 postPatch = ''
32 # This lets us build the tests properly on aarch64-darwin.
33 substituteInPlace CMakeLists.txt \
34 --replace 'SET(CMAKE_OSX_ARCHITECTURES "x86_64")' ""
35
36 # fix libdir=''${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
37 sed -i 's,libdir=''${\(exec_\)\?prefix}/,libdir=,' lib3mf.pc.in
38
39 # replace bundled binaries
40 for i in AutomaticComponentToolkit/bin/act.*; do
41 ln -sf ${automaticcomponenttoolkit}/bin/act $i
42 done
43 '';
44
45 meta = with lib; {
46 description = "Reference implementation of the 3D Manufacturing Format file standard";
47 homepage = "https://3mf.io/";
48 license = licenses.bsd2;
49 maintainers = with maintainers; [ gebner ];
50 platforms = platforms.all;
51 };
52}