3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/libraries/opencv/default.nix

95 lines
2.8 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchFromGitHub, cmake, pkgconfig, unzip
, zlib
, enablePython ? false, pythonPackages
, enableGtk2 ? false, gtk2
, enableJPEG ? true, libjpeg
, enablePNG ? true, libpng
, enableTIFF ? true, libtiff
2017-04-20 22:46:11 +01:00
, enableEXR ? (!stdenv.isDarwin), openexr, ilmbase
, enableJPEG2K ? false, jasper # disable jasper by default (many CVE)
, enableFfmpeg ? false, ffmpeg_3
2018-05-04 02:51:07 +01:00
, enableGStreamer ? false, gst_all_1
, enableEigen ? true, eigen
2019-06-19 19:14:17 +01:00
, Cocoa, QTKit
}:
let
opencvFlag = name: enabled: "-DWITH_${name}=${if enabled then "ON" else "OFF"}";
in
stdenv.mkDerivation rec {
pname = "opencv";
version = "2.4.13";
src = fetchFromGitHub {
owner = "Itseez";
repo = "opencv";
rev = version;
sha256 = "1k29rxlvrhgc5hadg2nc50wa3d2ls9ndp373257p756a0aividxh";
};
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
];
# 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
'';
outputs = [ "out" "dev" ];
buildInputs =
[ zlib ]
2016-06-07 19:26:33 +01:00
++ lib.optional enablePython pythonPackages.python
++ 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_3
2018-05-04 02:51:07 +01:00
++ lib.optionals enableGStreamer (with gst_all_1; [ gstreamer gst-plugins-base ])
++ lib.optional enableEigen eigen
2019-06-19 19:14:17 +01:00
++ lib.optionals stdenv.isDarwin [ Cocoa QTKit ]
;
2016-06-07 19:26:33 +01:00
propagatedBuildInputs = lib.optional enablePython pythonPackages.numpy;
nativeBuildInputs = [ cmake pkgconfig unzip ];
2019-10-30 01:29:30 +00:00
NIX_CFLAGS_COMPILE = lib.optionalString enableEXR "-I${ilmbase.dev}/include/OpenEXR";
cmakeFlags = [
(opencvFlag "TIFF" enableTIFF)
(opencvFlag "JASPER" enableJPEG2K)
(opencvFlag "JPEG" enableJPEG)
(opencvFlag "PNG" enablePNG)
(opencvFlag "OPENEXR" enableEXR)
2018-05-04 02:51:07 +01:00
(opencvFlag "GSTREAMER" enableGStreamer)
];
enableParallelBuilding = true;
hardeningDisable = [ "bindnow" "relro" ];
# 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|"
'';
passthru = lib.optionalAttrs enablePython { pythonPath = []; };
2017-04-20 22:46:11 +01:00
meta = with stdenv.lib; {
description = "Open Computer Vision Library with more than 500 algorithms";
homepage = "https://opencv.org/";
2017-04-20 22:46:11 +01:00
license = licenses.bsd3;
maintainers = with maintainers; [ ];
platforms = platforms.linux;
};
}