lol
1{ lib
2, stdenv
3, fetchpatch
4, fetchurl
5, blas
6, cmake
7, eigen
8, gflags
9, glog
10, suitesparse
11, runTests ? false
12, enableStatic ? stdenv.hostPlatform.isStatic
13, withBlas ? true
14}:
15
16# gflags is required to run tests
17assert runTests -> gflags != null;
18
19stdenv.mkDerivation rec {
20 pname = "ceres-solver";
21 version = "2.0.0";
22
23 src = fetchurl {
24 url = "http://ceres-solver.org/ceres-solver-${version}.tar.gz";
25 sha256 = "00vng9vnmdb1qga01m0why90m0041w7bn6kxa2h4m26aflfqla8h";
26 };
27
28 outputs = [ "out" "dev" ];
29
30 patches = [
31 # Enable GNUInstallDirs, see: https://github.com/ceres-solver/ceres-solver/pull/706
32 (fetchpatch {
33 url = "https://github.com/ceres-solver/ceres-solver/commit/4998c549396d36a491f1c0638fe57824a40bcb0d.patch";
34 sha256 = "sha256-mF6Zh2fDVzg2kD4nI2dd9rp4NpvPErmwfdYo5JaBmCA=";
35 })
36 ];
37
38 nativeBuildInputs = [ cmake ];
39 buildInputs = lib.optional runTests gflags;
40 propagatedBuildInputs = [ eigen glog ]
41 ++ lib.optionals withBlas [ blas suitesparse ];
42
43 cmakeFlags = [
44 "-DBUILD_SHARED_LIBS=${if enableStatic then "OFF" else "ON"}"
45 ];
46
47 # The Basel BUILD file conflicts with the cmake build directory on
48 # case-insensitive filesystems, eg. darwin.
49 preConfigure = ''
50 rm BUILD
51 '';
52
53 doCheck = runTests;
54
55 checkTarget = "test";
56
57 meta = with lib; {
58 description = "C++ library for modeling and solving large, complicated optimization problems";
59 license = licenses.bsd3;
60 homepage = "http://ceres-solver.org";
61 maintainers = with maintainers; [ giogadi ];
62 platforms = platforms.unix;
63 };
64}