2016-06-07 17:08:20 +03:00
|
|
|
{ lib, stdenv, fetchFromGitHub, cmake, pkgconfig, unzip
|
|
|
|
, zlib
|
|
|
|
, enablePython ? false, pythonPackages
|
|
|
|
, enableGtk2 ? false, gtk2
|
|
|
|
, enableJPEG ? true, libjpeg
|
|
|
|
, enablePNG ? true, libpng
|
|
|
|
, enableTIFF ? true, libtiff
|
2017-04-21 00:46:11 +03:00
|
|
|
, enableEXR ? (!stdenv.isDarwin), openexr, ilmbase
|
2016-06-07 17:08:20 +03:00
|
|
|
, enableJPEG2K ? true, jasper
|
|
|
|
, enableFfmpeg ? false, ffmpeg
|
|
|
|
, enableGStreamer ? false, gst_all
|
|
|
|
, enableEigen ? false, eigen
|
2017-04-21 00:46:11 +03:00
|
|
|
, darwin
|
2016-06-07 17:08:20 +03:00
|
|
|
}:
|
2011-09-25 00:40:58 +04:00
|
|
|
|
2016-06-07 17:08:20 +03:00
|
|
|
let
|
|
|
|
opencvFlag = name: enabled: "-DWITH_${name}=${if enabled then "ON" else "OFF"}";
|
|
|
|
|
|
|
|
in
|
2010-01-17 00:26:10 +03:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2016-06-07 17:08:20 +03:00
|
|
|
name = "opencv-${version}";
|
|
|
|
version = "2.4.13";
|
2010-01-17 00:26:10 +03:00
|
|
|
|
2016-06-07 17:08:20 +03:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Itseez";
|
|
|
|
repo = "opencv";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "1k29rxlvrhgc5hadg2nc50wa3d2ls9ndp373257p756a0aividxh";
|
2010-01-17 00:26:10 +03:00
|
|
|
};
|
|
|
|
|
2016-10-02 20:22:02 +03:00
|
|
|
patches =
|
|
|
|
[ # Don't include a copy of the CMake status output in the
|
|
|
|
# build. This causes a runtime dependency on GCC.
|
|
|
|
./no-build-info.patch
|
|
|
|
];
|
|
|
|
|
2017-05-15 23:45:52 +03:00
|
|
|
# This prevents cmake from using libraries in impure paths (which causes build failure on non NixOS)
|
|
|
|
postPatch = ''
|
|
|
|
sed -i '/Add these standard paths to the search paths for FIND_LIBRARY/,/^\s*$/{d}' CMakeLists.txt
|
|
|
|
'';
|
|
|
|
|
2016-10-02 20:22:02 +03:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2014-07-22 14:01:01 +04:00
|
|
|
buildInputs =
|
2016-06-07 17:08:20 +03:00
|
|
|
[ zlib ]
|
2016-06-07 21:26:33 +03:00
|
|
|
++ lib.optional enablePython pythonPackages.python
|
2016-06-07 17:08:20 +03:00
|
|
|
++ lib.optional enableGtk2 gtk2
|
|
|
|
++ lib.optional enableJPEG libjpeg
|
|
|
|
++ lib.optional enablePNG libpng
|
|
|
|
++ lib.optional enableTIFF libtiff
|
|
|
|
++ lib.optionals enableEXR [ openexr ilmbase ]
|
|
|
|
++ lib.optional enableJPEG2K jasper
|
|
|
|
++ lib.optional enableFfmpeg ffmpeg
|
|
|
|
++ lib.optionals enableGStreamer (with gst_all; [ gstreamer gst-plugins-base ])
|
|
|
|
++ lib.optional enableEigen eigen
|
2017-04-21 00:46:11 +03:00
|
|
|
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Cocoa QTKit ])
|
2016-06-07 17:08:20 +03:00
|
|
|
;
|
|
|
|
|
2016-06-07 21:26:33 +03:00
|
|
|
propagatedBuildInputs = lib.optional enablePython pythonPackages.numpy;
|
|
|
|
|
2016-06-07 17:08:20 +03:00
|
|
|
nativeBuildInputs = [ cmake pkgconfig unzip ];
|
2011-09-25 00:40:58 +04:00
|
|
|
|
2016-09-01 19:11:21 +03:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optional enableEXR "-I${ilmbase.dev}/include/OpenEXR";
|
2016-06-07 17:08:20 +03:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
(opencvFlag "TIFF" enableTIFF)
|
|
|
|
(opencvFlag "JASPER" enableJPEG2K)
|
|
|
|
(opencvFlag "JPEG" enableJPEG)
|
|
|
|
(opencvFlag "PNG" enablePNG)
|
|
|
|
(opencvFlag "OPENEXR" enableEXR)
|
|
|
|
];
|
2010-01-17 00:26:10 +03:00
|
|
|
|
2011-07-20 17:24:26 +04:00
|
|
|
enableParallelBuilding = true;
|
2010-01-17 00:26:10 +03:00
|
|
|
|
2016-02-26 20:38:15 +03:00
|
|
|
hardeningDisable = [ "bindnow" "relro" ];
|
2016-02-07 22:18:57 +03:00
|
|
|
|
2016-10-20 16:38:02 +03:00
|
|
|
# Fix pkgconfig file that gets broken with multiple outputs
|
|
|
|
postFixup = ''
|
|
|
|
sed -i $dev/lib/pkgconfig/opencv.pc -e "s|includedir_old=.*|includedir_old=$dev/include/opencv|"
|
|
|
|
sed -i $dev/lib/pkgconfig/opencv.pc -e "s|includedir_new=.*|includedir_new=$dev/include|"
|
|
|
|
'';
|
|
|
|
|
2016-06-07 17:08:20 +03:00
|
|
|
passthru = lib.optionalAttrs enablePython { pythonPath = []; };
|
|
|
|
|
2017-04-21 00:46:11 +03:00
|
|
|
meta = with stdenv.lib; {
|
2010-01-17 00:26:10 +03:00
|
|
|
description = "Open Computer Vision Library with more than 500 algorithms";
|
2014-12-16 18:10:18 +03:00
|
|
|
homepage = http://opencv.org/;
|
2017-04-21 00:46:11 +03:00
|
|
|
license = licenses.bsd3;
|
2017-05-10 12:10:10 +03:00
|
|
|
maintainers = with maintainers; [ viric ];
|
2017-04-21 00:46:11 +03:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2010-01-17 00:26:10 +03:00
|
|
|
};
|
|
|
|
}
|