1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch,
6 cmake,
7 static ? stdenv.hostPlatform.isStatic,
8 cxxStandard ? null,
9}:
10
11stdenv.mkDerivation rec {
12 pname = "abseil-cpp";
13 version = "20210324.2";
14
15 src = fetchFromGitHub {
16 owner = "abseil";
17 repo = "abseil-cpp";
18 rev = version;
19 sha256 = "sha256-fcxPhuI2eL/fnd6nT11p8DpUNwGNaXZmd03yOiZcOT0=";
20 };
21
22 patches = [
23 # Use CMAKE_INSTALL_FULL_{LIBDIR,INCLUDEDIR}
24 # https://github.com/abseil/abseil-cpp/pull/963
25 (fetchpatch {
26 url = "https://github.com/abseil/abseil-cpp/commit/5bfa70c75e621c5d5ec095c8c4c0c050dcb2957e.patch";
27 sha256 = "0nhjxqfxpi2pkfinnqvd5m4npf9l1kg39mjx9l3087ajhadaywl5";
28 })
29
30 # Bacport gcc-13 fix:
31 # https://github.com/abseil/abseil-cpp/pull/1187
32 (fetchpatch {
33 name = "gcc-13.patch";
34 url = "https://github.com/abseil/abseil-cpp/commit/36a4b073f1e7e02ed7d1ac140767e36f82f09b7c.patch";
35 hash = "sha256-aA7mwGEtv/cQINcawjkukmCvfNuqwUeDFssSiNKPdgg=";
36 })
37 ]
38 ++ lib.optionals stdenv.hostPlatform.isLoongArch64 [
39 # https://github.com/abseil/abseil-cpp/pull/1110
40 (fetchpatch {
41 url = "https://github.com/abseil/abseil-cpp/commit/808bc202fc13e85a7948db0d7fb58f0f051200b1.patch";
42 sha256 = "sha256-ayY/aV/xWOdEyFSDqV7B5WDGvZ0ASr/aeBeYwP5RZVc=";
43 })
44 ]
45 ++ lib.optionals stdenv.hostPlatform.isDarwin [
46 # Don’t propagate the path to CoreFoundation. Otherwise, it’s impossible to build packages
47 # that require a different SDK other than the default one.
48 ./cmake-core-foundation.patch
49 ];
50
51 cmakeFlags = [
52 "-DBUILD_SHARED_LIBS=${if static then "OFF" else "ON"}"
53 ]
54 ++ lib.optionals (cxxStandard != null) [
55 "-DCMAKE_CXX_STANDARD=${cxxStandard}"
56 ];
57
58 nativeBuildInputs = [ cmake ];
59
60 meta = with lib; {
61 description = "Open-source collection of C++ code designed to augment the C++ standard library";
62 homepage = "https://abseil.io/";
63 license = licenses.asl20;
64 platforms = platforms.all;
65 maintainers = [ maintainers.andersk ];
66 # Requires LFS64 APIs. 202401 and later are fine.
67 broken = stdenv.hostPlatform.isMusl;
68 };
69}