about summary refs log tree commit diff
path: root/pkgs/development/libraries/gtest/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries/gtest/default.nix')
-rw-r--r--pkgs/development/libraries/gtest/default.nix24
1 files changed, 17 insertions, 7 deletions
diff --git a/pkgs/development/libraries/gtest/default.nix b/pkgs/development/libraries/gtest/default.nix
index 51e0c685a43d2..7e44794620c03 100644
--- a/pkgs/development/libraries/gtest/default.nix
+++ b/pkgs/development/libraries/gtest/default.nix
@@ -3,6 +3,21 @@
 , fetchFromGitHub
 , cmake
 , ninja
+# Enable C++17 support
+#     https://github.com/google/googletest/issues/3081
+# Projects that require a higher standard can override this package.
+# For an example why that may be necessary, see:
+#     https://github.com/mhx/dwarfs/issues/188#issuecomment-1907574427
+# Setting this to `null` does not pass any flags to set this.
+, cxx_standard ? (
+    if (
+      (stdenv.cc.isGNU && (lib.versionOlder stdenv.cc.version "11.0"))
+      ||
+      (stdenv.cc.isClang && (lib.versionOlder stdenv.cc.version "16.0"))
+    )
+      then "17"
+      else null
+  )
 , static ? stdenv.hostPlatform.isStatic,
 }:
 
@@ -27,13 +42,8 @@ stdenv.mkDerivation rec {
 
   cmakeFlags = [
     "-DBUILD_SHARED_LIBS=${if static then "OFF" else "ON"}"
-  ] ++ lib.optionals (
-    (stdenv.cc.isGNU && (lib.versionOlder stdenv.cc.version "11.0"))
-    || (stdenv.cc.isClang && (lib.versionOlder stdenv.cc.version "16.0"))
-  ) [
-    # Enable C++17 support
-    # https://github.com/google/googletest/issues/3081
-    "-DCMAKE_CXX_STANDARD=17"
+  ] ++ lib.optionals (cxx_standard != null) [
+    "-DCMAKE_CXX_STANDARD=${cxx_standard}"
   ];
 
   meta = with lib; {