about summary refs log tree commit diff
path: root/pkgs/development/libraries/blitz/default.nix
blob: 4351e0ac729cbd696e8016049c5ff29861534ff4 (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
{ stdenv
, lib
, fetchFromGitHub
, fetchpatch
, cmake
, pkg-config
, gfortran
, texinfo
, python3
, boost
  # Select SIMD alignment width (in bytes) for vectorization.
, simdWidth ? 1
  # Pad arrays to simdWidth by default?
  # Note: Only useful if simdWidth > 1
, enablePadding ? false
  # Activate serialization through Boost.Serialize?
, enableSerialization ? true
  # Activate test-suite?
  # WARNING: Some of the tests require up to 1700MB of memory to compile.
, doCheck ? true
}:

let
  inherit (lib) optional optionals;
in
stdenv.mkDerivation rec {
  pname = "blitz++";
  version = "1.0.2";

  src = fetchFromGitHub {
    owner = "blitzpp";
    repo = "blitz";
    rev = version;
    hash = "sha256-wZDg+4lCd9iHvxuQQE/qs58NorkxZ0+mf+8PKQ57CDE=";
  };

  patches = [
    # https://github.com/blitzpp/blitz/pull/180
    (fetchpatch {
      name = "use-cmake-install-full-dir.patch";
      url = "https://github.com/blitzpp/blitz/commit/020f1d768c7fa3265cec244dc28f3dc8572719c5.patch";
      hash = "sha256-8hYFNyWrejjIWPN/HzIOphD4Aq6Soe0FFUBmwV4tpWQ=";
    })
  ];

  nativeBuildInputs = [
    cmake
    pkg-config
    python3
    texinfo
  ];

  buildInputs = [ gfortran texinfo boost ];

  cmakeFlags = optional enablePadding "-DARRAY_LENGTH_PADDING=ON"
    ++ optional enableSerialization "-DENABLE_SERIALISATION=ON"
    ++ optional stdenv.hostPlatform.is64bit "-DBZ_FULLY64BIT=ON";
    # FIXME ++ optional doCheck "-DBUILD_TESTING=ON";

  # skip broken library name detection
  ax_boost_user_serialization_lib = lib.optionalString stdenv.hostPlatform.isDarwin "boost_serialization";

  enableParallelBuilding = true;

  inherit doCheck;

  meta = with lib; {
    description = "Fast multi-dimensional array library for C++";
    homepage = "https://sourceforge.net/projects/blitz/";
    license = with licenses; [ artistic2 /* or */ bsd3 /* or */ lgpl3Plus ];
    platforms = platforms.unix;
    maintainers = with maintainers; [ ToxicFrog ];
    longDescription = ''
      Blitz++ is a C++ class library for scientific computing which provides
      performance on par with Fortran 77/90. It uses template techniques to
      achieve high performance. Blitz++ provides dense arrays and vectors,
      random number generators, and small vectors (useful for representing
      multicomponent or vector fields).
    '';
  };
}