Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / rapidjson / default.nix
blobb200193aa2114ed189315efc40fc0bf600963709
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , fetchpatch
5 , pkg-config
6 , cmake
7 , gtest
8 , valgrind
9 }:
11 stdenv.mkDerivation rec {
12   pname = "rapidjson";
13   version = "1.1.0";
15   src = fetchFromGitHub {
16     owner = "Tencent";
17     repo = "rapidjson";
18     rev = "v${version}";
19     sha256 = "1jixgb8w97l9gdh3inihz7avz7i770gy2j2irvvlyrq3wi41f5ab";
20   };
22   patches = [
23     (fetchpatch {
24       url = "https://src.fedoraproject.org/rpms/rapidjson/raw/48402da9f19d060ffcd40bf2b2e6987212c58b0c/f/rapidjson-1.1.0-c++20.patch";
25       sha256 = "1qm62iad1xfsixv1li7qy475xc7gc04hmi2q21qdk6l69gk7mf82";
26     })
27     (fetchpatch {
28       name = "do-not-include-gtest-src-dir.patch";
29       url = "https://git.alpinelinux.org/aports/plain/community/rapidjson/do-not-include-gtest-src-dir.patch?id=9e5eefc7a5fcf5938a8dc8a3be8c75e9e6809909";
30       hash = "sha256-BjSZEwfCXA/9V+kxQ/2JPWbc26jQn35CfN8+8NW24s4=";
31     })
32     # One of these three tests reports memcpy overlap after update to glibc-2.38
33     ./test-skip-valgrind.diff
34   ];
36   postPatch = ''
37     find -name CMakeLists.txt | xargs \
38       sed -i -e "s/-Werror//g" -e "s/-march=native//g"
39   '';
41   nativeBuildInputs = [ pkg-config cmake ];
43   # for tests, adding gtest to checkInputs does not work
44   # https://github.com/NixOS/nixpkgs/pull/212200
45   buildInputs = [ gtest ];
46   cmakeFlags = [ "-DGTEST_SOURCE_DIR=${gtest.dev}/include" ];
48   nativeCheckInputs = [ valgrind ];
49   doCheck = !stdenv.hostPlatform.isStatic && !stdenv.isDarwin;
51   meta = with lib; {
52     description = "Fast JSON parser/generator for C++ with both SAX/DOM style API";
53     homepage = "http://rapidjson.org/";
54     license = licenses.mit;
55     platforms = platforms.unix;
56     maintainers = with maintainers; [ dotlambda ];
57   };