1{ lib, stdenv, fetchFromGitHub, cmake, python3, validatePkgConfig, fetchpatch }:
2
3stdenv.mkDerivation rec {
4 pname = "jsoncpp";
5 version = "1.9.4";
6
7 outputs = ["out" "dev"];
8
9 src = fetchFromGitHub {
10 owner = "open-source-parsers";
11 repo = "jsoncpp";
12 rev = version;
13 sha256 = "0qnx5y6c90fphl9mj9d20j2dfgy6s5yr5l0xnzid0vh71zrp6jwv";
14 };
15
16 patches = [
17 # Fix for https://github.com/open-source-parsers/jsoncpp/issues/1235.
18 (fetchpatch {
19 url = "https://github.com/open-source-parsers/jsoncpp/commit/ac2870298ed5b5a96a688d9df07461b31f83e906.patch";
20 sha256 = "02wswhiwypmf1jn3rj9q1fw164kljiv4l8h0q6wyijzr77hq4wsg";
21 })
22 ];
23
24 /* During darwin bootstrap, we have a cp that doesn't understand the
25 * --reflink=auto flag, which is used in the default unpackPhase for dirs
26 */
27 unpackPhase = ''
28 cp -a ${src} ${src.name}
29 chmod -R +w ${src.name}
30 export sourceRoot=${src.name}
31 '';
32
33 # Hack to be able to run the test, broken because we use
34 # CMAKE_SKIP_BUILD_RPATH to avoid cmake resetting rpath on install
35 preBuild = if stdenv.isDarwin then ''
36 export DYLD_LIBRARY_PATH="$PWD/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH"
37 '' else ''
38 export LD_LIBRARY_PATH="$PWD/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
39 '';
40
41 nativeBuildInputs = [ cmake python3 validatePkgConfig ];
42
43 cmakeFlags = [
44 "-DBUILD_SHARED_LIBS=ON"
45 "-DBUILD_STATIC_LIBS=OFF"
46 "-DBUILD_OBJECT_LIBS=OFF"
47 "-DJSONCPP_WITH_CMAKE_PACKAGE=ON"
48 ];
49
50 meta = with lib; {
51 homepage = "https://github.com/open-source-parsers/jsoncpp";
52 description = "A C++ library for interacting with JSON";
53 maintainers = with maintainers; [ ttuegel cpages ];
54 license = licenses.mit;
55 platforms = platforms.all;
56 };
57}