about summary refs log tree commit diff
path: root/pkgs/by-name/pa/parallel-hashmap/package.nix
blob: 767b760c920a5c5aa2657712db7e3afa95f4beb7 (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
{ lib
, stdenv
, fetchFromGitHub
, cmake
, gtest
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "parallel-hashmap";
  version = "1.3.12";

  src = fetchFromGitHub {
    owner = "greg7mdp";
    repo = "parallel-hashmap";
    rev = "refs/tags/v${finalAttrs.version}";
    hash = "sha256-6KhzXUxa4WOsRrPmSSgguFxRGTOTIaxiJBFFSzOhch0=";
  };

  postPatch = ''
    # don't download googletest, but build it from source
    # https://github.com/greg7mdp/parallel-hashmap/blob/be6a2c79857c9ea76760ca6ce782e1609713428e/CMakeLists.txt#L98
    substituteInPlace CMakeLists.txt \
      --replace "include(cmake/DownloadGTest.cmake)" "add_subdirectory(${gtest.src} ./googletest-build EXCLUDE_FROM_ALL)"
  '';

  nativeBuildInputs = [
    cmake
  ];

  cmakeFlags = [
    "-DPHMAP_BUILD_TESTS=${if finalAttrs.doCheck then "ON" else "OFF"}"
    "-DPHMAP_BUILD_EXAMPLES=OFF"
  ];

  nativeCheckInputs = [
    gtest
  ];

  doCheck = true;

  meta = with lib; {
    description = "A family of header-only, very fast and memory-friendly hashmap and btree containers";
    homepage = "https://github.com/greg7mdp/parallel-hashmap";
    changelog = "https://github.com/greg7mdp/parallel-hashmap/releases/tag/${finalAttrs.src.rev}";
    license = licenses.asl20;
    platforms = platforms.unix;
    maintainers = with maintainers; [ natsukium ];
  };
})