diff options
author | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:36 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:47 +0000 |
commit | 36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (patch) | |
tree | b3faaf573407b32aa645237a4d16b82778a39a92 /nixpkgs/pkgs/development/libraries/opencv/default.nix | |
parent | 4e31070265257dc67d120c27e0f75c2344fdfa9a (diff) | |
parent | abf060725d7614bd3b9f96764262dfbc2f9c2199 (diff) | |
download | nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.gz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.bz2 nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.lz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.xz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.zst nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.zip |
Add 'nixpkgs/' from commit 'abf060725d7614bd3b9f96764262dfbc2f9c2199'
git-subtree-dir: nixpkgs git-subtree-mainline: 4e31070265257dc67d120c27e0f75c2344fdfa9a git-subtree-split: abf060725d7614bd3b9f96764262dfbc2f9c2199
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/opencv/default.nix')
-rw-r--r-- | nixpkgs/pkgs/development/libraries/opencv/default.nix | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/opencv/default.nix b/nixpkgs/pkgs/development/libraries/opencv/default.nix new file mode 100644 index 000000000000..4532285e53dc --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/opencv/default.nix @@ -0,0 +1,94 @@ +{ lib, stdenv, fetchFromGitHub, cmake, pkgconfig, unzip +, zlib +, enablePython ? false, pythonPackages +, enableGtk2 ? false, gtk2 +, enableJPEG ? true, libjpeg +, enablePNG ? true, libpng +, enableTIFF ? true, libtiff +, enableEXR ? (!stdenv.isDarwin), openexr, ilmbase +, enableJPEG2K ? true, jasper +, enableFfmpeg ? false, ffmpeg +, enableGStreamer ? false, gst_all_1 +, enableEigen ? true, eigen +, cf-private, Cocoa, QTKit +}: + +let + opencvFlag = name: enabled: "-DWITH_${name}=${if enabled then "ON" else "OFF"}"; + +in + +stdenv.mkDerivation rec { + name = "opencv-${version}"; + 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 ] + ++ 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 + ++ lib.optionals enableGStreamer (with gst_all_1; [ gstreamer gst-plugins-base ]) + ++ lib.optional enableEigen eigen + ++ lib.optionals stdenv.isDarwin [ Cocoa QTKit cf-private /* For NSDefaultRunLoopMode */ ] + ; + + propagatedBuildInputs = lib.optional enablePython pythonPackages.numpy; + + nativeBuildInputs = [ cmake pkgconfig unzip ]; + + NIX_CFLAGS_COMPILE = lib.optional enableEXR "-I${ilmbase.dev}/include/OpenEXR"; + + cmakeFlags = [ + (opencvFlag "TIFF" enableTIFF) + (opencvFlag "JASPER" enableJPEG2K) + (opencvFlag "JPEG" enableJPEG) + (opencvFlag "PNG" enablePNG) + (opencvFlag "OPENEXR" enableEXR) + (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 = []; }; + + meta = with stdenv.lib; { + description = "Open Computer Vision Library with more than 500 algorithms"; + homepage = https://opencv.org/; + license = licenses.bsd3; + maintainers = with maintainers; [ ]; + platforms = platforms.linux ++ platforms.darwin; + }; +} |