anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / development / libraries / catch2 / 3.nix
blobb005dc3f81166f492483a3992f67e90e1a860866
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , cmake
5 , python3
6 }:
8 stdenv.mkDerivation rec {
9   pname = "catch2";
10   version = "3.7.1";
12   src = fetchFromGitHub {
13     owner = "catchorg";
14     repo = "Catch2";
15     rev = "v${version}";
16     hash = "sha256-Zt53Qtry99RAheeh7V24Csg/aMW25DT/3CN/h+BaeoM=";
17   };
19   nativeBuildInputs = [
20     cmake
21   ];
23   hardeningDisable = [ "trivialautovarinit" ];
25   cmakeFlags = [
26     "-DCATCH_DEVELOPMENT_BUILD=ON"
27     "-DCATCH_BUILD_TESTING=${if doCheck then "ON" else "OFF"}"
28   ] ++ lib.optionals (stdenv.hostPlatform.isDarwin && doCheck) [
29     # test has a faulty path normalization technique that won't work in
30     # our darwin build environment https://github.com/catchorg/Catch2/issues/1691
31     "-DCMAKE_CTEST_ARGUMENTS=-E;ApprovalTests"
32   ];
34   env = lib.optionalAttrs stdenv.hostPlatform.isx86_32 {
35     # Tests fail on x86_32 if compiled with x87 floats: https://github.com/catchorg/Catch2/issues/2796
36     NIX_CFLAGS_COMPILE = "-msse2 -mfpmath=sse";
37   } // lib.optionalAttrs (stdenv.hostPlatform.isRiscV || stdenv.hostPlatform.isAarch32) {
38     # Build failure caused by -Werror: https://github.com/catchorg/Catch2/issues/2808
39     NIX_CFLAGS_COMPILE = "-Wno-error=cast-align";
40   };
42   doCheck = true;
44   nativeCheckInputs = [
45     python3
46   ];
48   meta = {
49     description = "Modern, C++-native, test framework for unit-tests";
50     homepage = "https://github.com/catchorg/Catch2";
51     changelog = "https://github.com/catchorg/Catch2/blob/${src.rev}/docs/release-notes.md";
52     license = lib.licenses.boost;
53     maintainers = with lib.maintainers; [ dotlambda ];
54     platforms = with lib.platforms; unix ++ windows;
55   };