about summary refs log tree commit diff
path: root/pkgs/development/libraries/forge/default.nix
blob: c5fe5dcc9af10a3980fce0943da4ec8503a670b9 (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
{ boost
, cmake
, expat
, fetchFromGitHub
, fontconfig
, freeimage
, freetype
, git
, glfw3
, glm
, lib
, libGLU
, libGL
, mesa
, opencl-clhpp
, pkg-config
, stdenv
, SDL2
}:

stdenv.mkDerivation rec {
  pname = "forge";
  version = "1.0.8";

  src = fetchFromGitHub {
    owner = "arrayfire";
    repo = pname;
    rev = "v1.0.8";
    sha256 = "sha256-lSZAwcqAHiuZkpYcVfwvZCfNmEF3xGN9S/HuZQrGeKU=";
  };
  glad = fetchFromGitHub {
    owner = "arrayfire";
    repo = "glad";
    rev = "b94680aee5b8ce01ae1644c5f2661769366c765a";
    sha256 = "sha256-CrZy76gOGMpy9f1NuMK4tokZ57U//zYeNH5ZYY0SC2U=";
  };

  postPatch = ''
    mkdir -p ./extern/fg_glad-src
    cp -R --no-preserve=mode,ownership ${glad}/* ./extern/fg_glad-src/
    ln -s ${opencl-clhpp} ./extern/cl2hpp

    substituteInPlace CMakeModules/ForgeConfigureDepsVars.cmake \
      --replace 'set(BUILD_OFFLINE OFF)' 'set(BUILD_OFFLINE ON)'
  '';

  cmakeFlags = [ "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" ];

  nativeBuildInputs = [
    cmake
    # ArrayFire have their own CMake functions for downloading the
    # dependencies, and it uses git. Even though we bypass that system by
    # downloading the dependencies beforehand, CMake files still invoke git for
    # checking...
    git
    pkg-config
  ];

  buildInputs = [
    boost.out
    boost.dev
    expat
    fontconfig
    freeimage
    freetype
    glfw3
    glm
    libGL
    libGLU
    opencl-clhpp
    SDL2
  ] ++ lib.optionals (!stdenv.isDarwin) [
    mesa
  ];

  meta = with lib; {
    description = "An OpenGL interop library that can be used with ArrayFire or any other application using CUDA or OpenCL compute backend";
    longDescription = ''
      An OpenGL interop library that can be used with ArrayFire or any other application using CUDA or OpenCL compute backend.
      The goal of Forge is to provide high performance OpenGL visualizations for C/C++ applications that use CUDA/OpenCL.
      Forge uses OpenGL >=3.3 forward compatible contexts, so please make sure you have capable hardware before trying it out.
    '';
    license = licenses.bsd3;
    homepage = "https://arrayfire.com/";
    platforms = platforms.linux ++ platforms.darwin;
    maintainers = with maintainers; [ chessai twesterhout ];
  };
}