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