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