at 23.11-beta 1.7 kB view raw
1{ lib 2, stdenv 3, fetchFromGitHub 4, cmake 5, python3 6, validatePkgConfig 7, secureMemory ? false 8, enableStatic ? stdenv.hostPlatform.isStatic 9}: 10 11stdenv.mkDerivation rec { 12 pname = "jsoncpp"; 13 version = "1.9.5"; 14 15 outputs = ["out" "dev"]; 16 17 src = fetchFromGitHub { 18 owner = "open-source-parsers"; 19 repo = "jsoncpp"; 20 rev = version; 21 sha256 = "sha256-OyfJD19g8cT9wOD0hyJyEw4TbaxZ9eY04396U/7R+hs="; 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 postPatch = lib.optionalString secureMemory '' 34 sed -i 's/#define JSONCPP_USING_SECURE_MEMORY 0/#define JSONCPP_USING_SECURE_MEMORY 1/' include/json/version.h 35 ''; 36 37 nativeBuildInputs = [ cmake python3 validatePkgConfig ]; 38 39 cmakeFlags = [ 40 "-DBUILD_SHARED_LIBS=ON" 41 "-DBUILD_OBJECT_LIBS=OFF" 42 "-DJSONCPP_WITH_CMAKE_PACKAGE=ON" 43 "-DBUILD_STATIC_LIBS=${if enableStatic then "ON" else "OFF"}" 44 ] 45 # the test's won't compile if secureMemory is used because there is no 46 # comparison operators and conversion functions between 47 # std::basic_string<..., Json::SecureAllocator<char>> vs. 48 # std::basic_string<..., [default allocator]> 49 ++ lib.optional ((stdenv.buildPlatform != stdenv.hostPlatform) || secureMemory) "-DJSONCPP_WITH_TESTS=OFF"; 50 51 meta = with lib; { 52 homepage = "https://github.com/open-source-parsers/jsoncpp"; 53 description = "A C++ library for interacting with JSON"; 54 maintainers = with maintainers; [ ttuegel cpages ]; 55 license = licenses.mit; 56 platforms = platforms.all; 57 }; 58}