nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 68 lines 1.6 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 cmake, 6 ninja, 7 sanitiseHeaderPathsHook, 8 # Enable C++17 support 9 # https://github.com/google/googletest/issues/3081 10 # Projects that require a higher standard can override this package. 11 # For an example why that may be necessary, see: 12 # https://github.com/mhx/dwarfs/issues/188#issuecomment-1907574427 13 # Setting this to `null` does not pass any flags to set this. 14 cxx_standard ? ( 15 if 16 ( 17 (stdenv.cc.isGNU && (lib.versionOlder stdenv.cc.version "11.0")) 18 || (stdenv.cc.isClang && (lib.versionOlder stdenv.cc.version "16.0")) 19 ) 20 then 21 "17" 22 else 23 null 24 ), 25 static ? stdenv.hostPlatform.isStatic, 26}: 27 28stdenv.mkDerivation rec { 29 pname = "gtest"; 30 version = "1.17.0"; 31 32 outputs = [ 33 "out" 34 "dev" 35 ]; 36 37 src = fetchFromGitHub { 38 owner = "google"; 39 repo = "googletest"; 40 rev = "v${version}"; 41 hash = "sha256-HIHMxAUR4bjmFLoltJeIAVSulVQ6kVuIT2Ku+lwAx/4="; 42 }; 43 44 patches = [ 45 ./fix-cmake-config-includedir.patch 46 ]; 47 48 nativeBuildInputs = [ 49 cmake 50 ninja 51 sanitiseHeaderPathsHook 52 ]; 53 54 cmakeFlags = [ 55 "-DBUILD_SHARED_LIBS=${if static then "OFF" else "ON"}" 56 ] 57 ++ lib.optionals (cxx_standard != null) [ 58 "-DCMAKE_CXX_STANDARD=${cxx_standard}" 59 ]; 60 61 meta = with lib; { 62 description = "Google's framework for writing C++ tests"; 63 homepage = "https://github.com/google/googletest"; 64 license = licenses.bsd3; 65 platforms = platforms.all; 66 maintainers = with maintainers; [ ivan-tkatchev ]; 67 }; 68}