1{ lib
2, stdenv
3, fetchFromGitHub
4, nix-update-script
5, cmake
6, python3
7, gtest
8, withAnimation ? true
9, withTranscoder ? true
10, eigen
11, ghc_filesystem
12, tinygltf
13}:
14
15let
16 cmakeBool = b: if b then "ON" else "OFF";
17in
18stdenv.mkDerivation (finalAttrs: {
19 version = "1.5.7";
20 pname = "draco";
21
22 src = fetchFromGitHub {
23 owner = "google";
24 repo = "draco";
25 rev = finalAttrs.version;
26 hash = "sha256-p0Mn4kGeBBKL7Hoz4IBgb6Go6MdkgE7WZgxAnt1tE/0=";
27 fetchSubmodules = true;
28 };
29
30 # ld: unknown option: --start-group
31 postPatch = ''
32 substituteInPlace cmake/draco_targets.cmake \
33 --replace "^Clang" "^AppleClang"
34 '';
35
36 buildInputs = [ gtest ]
37 ++ lib.optionals withTranscoder [ eigen ghc_filesystem tinygltf ];
38
39 nativeBuildInputs = [ cmake python3 ];
40
41 cmakeFlags = [
42 "-DDRACO_ANIMATION_ENCODING=${cmakeBool withAnimation}"
43 "-DDRACO_GOOGLETEST_PATH=${gtest}"
44 "-DBUILD_SHARED_LIBS=${cmakeBool true}"
45 "-DDRACO_TRANSCODER_SUPPORTED=${cmakeBool withTranscoder}"
46 ] ++ lib.optionals withTranscoder [
47 "-DDRACO_EIGEN_PATH=${eigen}/include/eigen3"
48 "-DDRACO_FILESYSTEM_PATH=${ghc_filesystem}"
49 "-DDRACO_TINYGLTF_PATH=${tinygltf}"
50 ];
51
52 CXXFLAGS = [
53 # error: expected ')' before 'value' in 'explicit GltfValue(uint8_t value)'
54 "-include cstdint"
55 ];
56
57 passthru.updateScript = nix-update-script { };
58
59 meta = with lib; {
60 description = "Library for compressing and decompressing 3D geometric meshes and point clouds";
61 homepage = "https://google.github.io/draco/";
62 changelog = "https://github.com/google/draco/releases/tag/${finalAttrs.version}";
63 license = licenses.asl20;
64 maintainers = with maintainers; [ jansol ];
65 platforms = platforms.all;
66 };
67})