Skip to content

Commit 028e1a5

Browse files
authored
toml11: only build tests when they're enabled & use system doctest/nlohmann_json (NixOS#450200)
2 parents de62247 + e463f58 commit 028e1a5

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pkgs/by-name/to/toml11/package.nix

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
stdenv,
44
fetchFromGitHub,
55
cmake,
6+
doctest,
67
fetchpatch,
8+
nlohmann_json,
79
}:
810

911
stdenv.mkDerivation (finalAttrs: {
@@ -14,8 +16,7 @@ stdenv.mkDerivation (finalAttrs: {
1416
owner = "ToruNiina";
1517
repo = "toml11";
1618
tag = "v${finalAttrs.version}";
17-
hash = "sha256-NnM+I43UVcd72Y9h+ysAAc7s5gZ78mjVwIMReTJ7G5M=";
18-
fetchSubmodules = true;
19+
hash = "sha256-sgWKYxNT22nw376ttGsTdg0AMzOwp8QH3E8mx0BZJTQ=";
1920
};
2021

2122
patches = [
@@ -26,11 +27,21 @@ stdenv.mkDerivation (finalAttrs: {
2627
})
2728
];
2829

30+
# Required to use the system `doctest` over upstream's submodule
31+
postPatch = lib.optionalString finalAttrs.finalPackage.doCheck ''
32+
substituteInPlace tests/*.{c,h}pp \
33+
--replace-warn '"doctest.h"' '"doctest/doctest.h"'
34+
'';
35+
2936
nativeBuildInputs = [
3037
cmake
3138
];
3239
cmakeFlags = [
33-
(lib.cmakeBool "TOML11_BUILD_TOML_TESTS" true)
40+
(lib.cmakeBool "TOML11_BUILD_TOML_TESTS" finalAttrs.finalPackage.doCheck)
41+
];
42+
checkInputs = [
43+
doctest
44+
nlohmann_json
3445
];
3546
doCheck = true;
3647

0 commit comments

Comments
 (0)