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