1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, cmake
6, static ? stdenv.hostPlatform.isStatic
7, cxxStandard ? null
8}:
9
10stdenv.mkDerivation rec {
11 pname = "abseil-cpp";
12 version = "20210324.2";
13
14 src = fetchFromGitHub {
15 owner = "abseil";
16 repo = "abseil-cpp";
17 rev = version;
18 sha256 = "sha256-fcxPhuI2eL/fnd6nT11p8DpUNwGNaXZmd03yOiZcOT0=";
19 };
20
21 patches = [
22 # Use CMAKE_INSTALL_FULL_{LIBDIR,INCLUDEDIR}
23 # https://github.com/abseil/abseil-cpp/pull/963
24 (fetchpatch {
25 url = "https://github.com/abseil/abseil-cpp/commit/5bfa70c75e621c5d5ec095c8c4c0c050dcb2957e.patch";
26 sha256 = "0nhjxqfxpi2pkfinnqvd5m4npf9l1kg39mjx9l3087ajhadaywl5";
27 })
28 ] ++ lib.optionals stdenv.hostPlatform.isLoongArch64 [
29 # https://github.com/abseil/abseil-cpp/pull/1110
30 (fetchpatch {
31 url = "https://github.com/abseil/abseil-cpp/commit/808bc202fc13e85a7948db0d7fb58f0f051200b1.patch";
32 sha256 = "sha256-ayY/aV/xWOdEyFSDqV7B5WDGvZ0ASr/aeBeYwP5RZVc=";
33 })
34 ];
35
36 cmakeFlags = [
37 "-DBUILD_SHARED_LIBS=${if static then "OFF" else "ON"}"
38 ] ++ lib.optionals (cxxStandard != null) [
39 "-DCMAKE_CXX_STANDARD=${cxxStandard}"
40 ];
41
42 nativeBuildInputs = [ cmake ];
43
44 meta = with lib; {
45 description = "An open-source collection of C++ code designed to augment the C++ standard library";
46 homepage = "https://abseil.io/";
47 license = licenses.asl20;
48 platforms = platforms.all;
49 maintainers = [ maintainers.andersk ];
50 };
51}