about summary refs log tree commit diff
path: root/pkgs/applications/science/misc/openmvg/default.nix
blob: 5cf4dc4377521a9806bf3289e3805a2292a0eab3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{ lib, stdenv, fetchFromGitHub, pkg-config, cmake
, cereal
, ceres-solver
, clp
, coin-utils
, eigen
, lemon-graph
, libjpeg
, libpng
, libtiff
, nix-update-script
, openmp
, osi
, zlib
, enableShared ? !stdenv.hostPlatform.isStatic
, enableExamples ? false
, enableDocs ? false }:

stdenv.mkDerivation rec {
  version = "2.1";
  pname = "openmvg";

  src = fetchFromGitHub {
    owner = "openmvg";
    repo = "openmvg";
    rev = "v${version}";
    hash = "sha256-vG+tW9Gl/DAUL8DeY+rJVDJH/oMPH3XyZMUgzjtwFv0=";
  };

  # Pretend we checked out the dependency submodules
  postPatch = ''
    mkdir src/dependencies/cereal/include
  '';

  buildInputs = [
    cereal
    ceres-solver
    clp
    coin-utils
    eigen
    lemon-graph
    libjpeg
    libpng
    libtiff
    openmp
    osi
    zlib
  ];

  nativeBuildInputs = [ cmake pkg-config ];

  # flann is missing because the lz4 dependency isn't propagated: https://github.com/openMVG/openMVG/issues/1265
  cmakeFlags = [
    "-DOpenMVG_BUILD_EXAMPLES=${if enableExamples then "ON" else "OFF"}"
    "-DOpenMVG_BUILD_DOC=${if enableDocs then "ON" else "OFF"}"
    "-DTARGET_ARCHITECTURE=generic"
    "-DCLP_INCLUDE_DIR_HINTS=${lib.getDev clp}/include"
    "-DCOINUTILS_INCLUDE_DIR_HINTS=${lib.getDev coin-utils}/include"
    "-DLEMON_INCLUDE_DIR_HINTS=${lib.getDev lemon-graph}/include"
    "-DOSI_INCLUDE_DIR_HINTS=${lib.getDev osi}/include"
  ] ++ lib.optional enableShared "-DOpenMVG_BUILD_SHARED=ON";

  cmakeDir = "./src";

  dontUseCmakeBuildDir = true;

  # This can be enabled, but it will exhause virtual memory on most machines.
  enableParallelBuilding = false;

  # Without hardeningDisable, certain flags are passed to the compile that break the build (primarily string format errors)
  hardeningDisable = [ "all" ];

  passthru.updateScript = nix-update-script { };

  meta = {
    broken = stdenv.isDarwin && stdenv.isx86_64;
    description = "A library for computer-vision scientists and targeted for the Multiple View Geometry community";
    homepage = "https://openmvg.readthedocs.io/en/latest/";
    license = lib.licenses.mpl20;
    platforms = lib.platforms.unix;
    maintainers = with lib.maintainers; [ mdaiter bouk ];
  };
}