about summary refs log tree commit diff
path: root/pkgs/tools/compression/zfp/default.nix
blob: 0b337f61336657ed046d7daf7612e64b835c7c73 (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
{ cmake, cudatoolkit, fetchFromGitHub, gfortran, lib, llvmPackages, python3Packages, stdenv, targetPlatform
, enableCfp ? true
, enableCuda ? false
, enableExamples ? true
, enableFortran ? builtins.elem targetPlatform.system gfortran.meta.platforms
, enableOpenMP ? true
, enablePython ? true
, enableUtilities ? true }:

stdenv.mkDerivation rec {
  pname = "zfp";
  version = "0.5.5";

  src = fetchFromGitHub {
    owner = "LLNL";
    repo = "zfp";
    rev = version;
    sha256 = "19ycflz35qsrzfcvxdyy0mgbykfghfi9y5v684jb4awjp7nf562c";
  };

  nativeBuildInputs = [ cmake ];

  buildInputs = lib.optional enableCuda cudatoolkit
    ++ lib.optional enableFortran gfortran
    ++ lib.optional enableOpenMP llvmPackages.openmp
    ++ lib.optionals enablePython (with python3Packages; [ cython numpy python ]);

  cmakeFlags = [
    # More tests not enabled by default
    ''-DZFP_BINARY_DIR=${placeholder "out"}''
    ''-DZFP_BUILD_TESTING_LARGE=ON''
  ]
    ++ lib.optionals targetPlatform.isDarwin [
      "-DCMAKE_INSTALL_BINDIR=bin"
      "-DCMAKE_INSTALL_LIBDIR=lib"
    ]
    ++ lib.optional enableCfp "-DBUILD_CFP=ON"
    ++ lib.optional enableCuda "-DZFP_WITH_CUDA=ON"
    ++ lib.optional enableExamples "-DBUILD_EXAMPLES=ON"
    ++ lib.optional enableFortran "-DBUILD_ZFORP=ON"
    ++ lib.optional enableOpenMP "-DZFP_WITH_OPENMP=ON"
    ++ lib.optional enablePython "-DBUILD_ZFPY=ON"
    ++ ([ "-DBUILD_UTILITIES=${if enableUtilities then "ON" else "OFF"}" ]);

  preCheck = lib.optional targetPlatform.isDarwin ''
    export DYLD_LIBRARY_PATH="$out/lib:$DYLD_LIBRARY_PATH"
  '';

  doCheck = true;

  meta = with lib; {
    homepage = "https://computing.llnl.gov/projects/zfp";
    description = "Library for random-access compression of floating-point arrays";
    license = licenses.bsd3;
    maintainers = [ maintainers.spease ];
    # 64-bit only
    platforms = platforms.aarch64 ++ platforms.x86_64;
  };
}