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 patches = [ ./upgrade-to-cpp-14.patch ];
16
17 nativeBuildInputs = [ cmake ninja pkg-config ];
18
19 outputs = [ "out" "dev" ];
20
21 cmakeFlags = [
22 "-DCMAKE_INSTALL_INCLUDEDIR=include/lib3mf"
23 "-DUSE_INCLUDED_ZLIB=OFF"
24 "-DUSE_INCLUDED_LIBZIP=OFF"
25 "-DUSE_INCLUDED_GTEST=OFF"
26 "-DUSE_INCLUDED_SSL=OFF"
27 ];
28
29 buildInputs = [
30 libzip gtest openssl
31 ] ++ (if stdenv.isDarwin then [ libossp_uuid ] else [ libuuid ]);
32
33 postPatch = ''
34 # This lets us build the tests properly on aarch64-darwin.
35 substituteInPlace CMakeLists.txt \
36 --replace 'SET(CMAKE_OSX_ARCHITECTURES "x86_64")' ""
37
38 # fix libdir=''${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
39 sed -i 's,libdir=''${\(exec_\)\?prefix}/,libdir=,' lib3mf.pc.in
40
41 # replace bundled binaries
42 for i in AutomaticComponentToolkit/bin/act.*; do
43 ln -sf ${automaticcomponenttoolkit}/bin/act $i
44 done
45 '';
46
47 meta = with lib; {
48 description = "Reference implementation of the 3D Manufacturing Format file standard";
49 homepage = "https://3mf.io/";
50 license = licenses.bsd2;
51 maintainers = with maintainers; [ gebner ];
52 platforms = platforms.all;
53 };
54}