1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, ninja
6, static ? stdenv.hostPlatform.isStatic,
7}:
8
9stdenv.mkDerivation rec {
10 pname = "gtest";
11 version = "1.12.1";
12
13 outputs = [ "out" "dev" ];
14
15 src = fetchFromGitHub {
16 owner = "google";
17 repo = "googletest";
18 rev = "release-${version}";
19 hash = "sha256-W+OxRTVtemt2esw4P7IyGWXOonUN5ZuscjvzqkYvZbM=";
20 };
21
22 patches = [
23 ./fix-cmake-config-includedir.patch
24 ];
25
26 nativeBuildInputs = [ cmake ninja ];
27
28 cmakeFlags = [
29 "-DBUILD_SHARED_LIBS=${if static then "OFF" else "ON"}"
30 ] ++ lib.optionals (
31 (stdenv.cc.isGNU && (lib.versionOlder stdenv.cc.version "11.0"))
32 || (stdenv.cc.isClang && (lib.versionOlder stdenv.cc.version "16.0"))
33 ) [
34 # Enable C++17 support
35 # https://github.com/google/googletest/issues/3081
36 "-DCMAKE_CXX_STANDARD=17"
37 ];
38
39 meta = with lib; {
40 description = "Google's framework for writing C++ tests";
41 homepage = "https://github.com/google/googletest";
42 license = licenses.bsd3;
43 platforms = platforms.all;
44 maintainers = with maintainers; [ ivan-tkatchev ];
45 };
46}