1{ lib
2, stdenv
3, fetchpatch
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 = [ "out" "dev" ];
30
31 nativeBuildInputs = [ cmake ];
32 buildInputs = lib.optional runTests gflags;
33 propagatedBuildInputs = [ eigen glog ]
34 ++ lib.optionals withBlas [ blas suitesparse metis ];
35
36 cmakeFlags = [
37 "-DBUILD_SHARED_LIBS=${if enableStatic then "OFF" else "ON"}"
38 ];
39
40 # The Basel BUILD file conflicts with the cmake build directory on
41 # case-insensitive filesystems, eg. darwin.
42 preConfigure = ''
43 rm BUILD
44 '';
45
46 doCheck = runTests;
47
48 checkTarget = "test";
49
50 meta = with lib; {
51 description = "C++ library for modeling and solving large, complicated optimization problems";
52 license = licenses.bsd3;
53 homepage = "http://ceres-solver.org";
54 maintainers = with maintainers; [ giogadi ];
55 platforms = platforms.unix;
56 };
57}