summary refs log tree commit diff
path: root/pkgs/development/libraries/opencolorio/default.nix
blob: 9b5018ef41826d98a792ae5e410063e8e613b023 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{ stdenv
, lib
, fetchFromGitHub
, fetchpatch
, cmake
, expat
, yaml-cpp
, ilmbase
, pystring
, imath
, minizip-ng
# Only required on Linux
, glew
, freeglut
# Only required on Darwin
, Carbon
, GLUT
, Cocoa
# Python bindings
, pythonBindings ? true # Python bindings
, python3Packages
# Build apps
, buildApps ? true # Utility applications
, lcms2
, openexr_3
}:

stdenv.mkDerivation rec {
  pname = "opencolorio";
  version = "2.3.0";

  src = fetchFromGitHub {
    owner = "AcademySoftwareFoundation";
    repo = "OpenColorIO";
    rev = "v${version}";
    sha256 = "sha256-E4TmMEFzI3nKqiDFaAkNx44uo84sacvZqjbfWe3A8fE=";
  };

  patches = [
    (fetchpatch {
      # Taken from https://github.com/AcademySoftwareFoundation/OpenColorIO/pull/1891.
      name = "opencolorio-yaml-cpp-8.0-compat.patch";
      url = "https://github.com/AcademySoftwareFoundation/OpenColorIO/commit/e99b4afcf0408d8ec56fdf2b9380327c9284db00.patch";
      sha256 = "sha256-7eIvVWKcpE0lmuYdNqFQFHkW/sSSzQ//LNIMOC28KZg=";
    })
    # Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/25200.
    # Needed for zlib >= 1.3 && cmake < 3.27.4.
    ./broken-cmake-zlib-version.patch
  ];

  postPatch = lib.optionalString stdenv.isDarwin ''
    # these tests don't like being run headless on darwin. no builtin
    # way of skipping tests so this is what we're reduced to.
    substituteInPlace tests/cpu/Config_tests.cpp \
      --replace 'OCIO_ADD_TEST(Config, virtual_display)' 'static void _skip_virtual_display()' \
      --replace 'OCIO_ADD_TEST(Config, virtual_display_with_active_displays)' 'static void _skip_virtual_display_with_active_displays()'
  '';

  nativeBuildInputs = [ cmake ];
  buildInputs = [
    expat
    yaml-cpp
    ilmbase
    pystring
    imath
    minizip-ng
  ] ++ lib.optionals stdenv.hostPlatform.isLinux [ glew freeglut ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [ Carbon GLUT Cocoa ]
    ++ lib.optionals pythonBindings [ python3Packages.python python3Packages.pybind11 ]
    ++ lib.optionals buildApps [
      lcms2
      openexr_3
    ];

  cmakeFlags = [
    "-DOCIO_INSTALL_EXT_PACKAGES=NONE"
    "-DOCIO_USE_SSE2NEON=OFF"
    # GPU test fails with: freeglut (GPU tests): failed to open display ''
    "-DOCIO_BUILD_GPU_TESTS=OFF"
    "-Dminizip-ng_INCLUDE_DIR=${minizip-ng}/include/minizip-ng"
  ] ++ lib.optional (!pythonBindings) "-DOCIO_BUILD_PYTHON=OFF"
    ++ lib.optional (!buildApps) "-DOCIO_BUILD_APPS=OFF";

  # precision issues on non-x86
  doCheck = stdenv.isx86_64;
  # Tends to fail otherwise.
  enableParallelChecking = false;

  meta = with lib; {
    homepage = "https://opencolorio.org";
    description = "A color management framework for visual effects and animation";
    license = licenses.bsd3;
    maintainers = [ maintainers.rytone ];
    platforms = platforms.unix;
  };
}