Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / libhwy / default.nix
blobb2f32cbe7252d0dc3118fa5c0fe4ddce46c675bc
1 { lib
2 , stdenv
3 , cmake
4 , ninja
5 , gtest
6 , fetchFromGitHub
7 }:
9 stdenv.mkDerivation rec {
10   pname = "libhwy";
11   version = "1.0.7";
13   src = fetchFromGitHub {
14     owner = "google";
15     repo = "highway";
16     rev = version;
17     hash = "sha256-Z+mAR9nSAbCskUvo6oK79Yd85bu0HtI2aR5THS1EozM=";
18   };
20   nativeBuildInputs = [ cmake ninja ];
22   # Required for case-insensitive filesystems ("BUILD" exists)
23   dontUseCmakeBuildDir = true;
25   cmakeFlags = let
26     libExt = stdenv.hostPlatform.extensions.library;
27   in [
28     "-GNinja"
29     "-DCMAKE_INSTALL_LIBDIR=lib"
30     "-DCMAKE_INSTALL_INCLUDEDIR=include"
31   ] ++ lib.optionals doCheck [
32     "-DHWY_SYSTEM_GTEST:BOOL=ON"
33     "-DGTEST_INCLUDE_DIR=${lib.getDev gtest}/include"
34     "-DGTEST_LIBRARY=${lib.getLib gtest}/lib/libgtest${libExt}"
35     "-DGTEST_MAIN_LIBRARY=${lib.getLib gtest}/lib/libgtest_main${libExt}"
36   ] ++ lib.optionals stdenv.hostPlatform.isAarch32 [
37     "-DHWY_CMAKE_ARM7=ON"
38   ] ++ lib.optionals stdenv.hostPlatform.isx86_32 [
39     # Quoting CMakelists.txt:
40     #   This must be set on 32-bit x86 with GCC < 13.1, otherwise math_test will be
41     #   skipped. For GCC 13.1+, you can also build with -fexcess-precision=standard.
42     # Fixes tests:
43     #   HwyMathTestGroup/HwyMathTest.TestAllAtanh/EMU128
44     #   HwyMathTestGroup/HwyMathTest.TestAllLog1p/EMU128
45     "-DHWY_CMAKE_SSE2=ON"
46   ];
48   # hydra's darwin machines run into https://github.com/libjxl/libjxl/issues/408
49   doCheck = !stdenv.hostPlatform.isDarwin;
51   meta = with lib; {
52     description = "Performance-portable, length-agnostic SIMD with runtime dispatch";
53     homepage = "https://github.com/google/highway";
54     license = with licenses; [ asl20 bsd3 ];
55     platforms = platforms.unix;
56     maintainers = with maintainers; [ zhaofengli ];
57   };