From b496ffbe55f1a0604bfcf0eeb92a48f2fd504d03 Mon Sep 17 00:00:00 2001 From: mingchuan Date: Tue, 16 May 2017 04:45:52 +0800 Subject: [PATCH] opencv: Fix OpenCV build on non NixOS platform OpenCV's CMakeFile will use libraries in /lib and /lib64 if it can find libraries from those paths. However, it causes build failure because nix detects impure paths being used. --- pkgs/development/libraries/opencv/3.x.nix | 6 ++++++ pkgs/development/libraries/opencv/default.nix | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/pkgs/development/libraries/opencv/3.x.nix b/pkgs/development/libraries/opencv/3.x.nix index 275c1cddab0..5c7972eb2fa 100644 --- a/pkgs/development/libraries/opencv/3.x.nix +++ b/pkgs/development/libraries/opencv/3.x.nix @@ -78,6 +78,12 @@ stdenv.mkDerivation rec { ln -s "${bootdescFiles}/$name" "$NIX_BUILD_TOP/opencv_contrib/xfeatures2d/src/$name" done ''); + + # 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 + ''; + preConfigure = (let version = "20151201"; md5 = "808b791a6eac9ed78d32a7666804320e"; diff --git a/pkgs/development/libraries/opencv/default.nix b/pkgs/development/libraries/opencv/default.nix index 37b33c21a30..d7824dbed34 100644 --- a/pkgs/development/libraries/opencv/default.nix +++ b/pkgs/development/libraries/opencv/default.nix @@ -35,6 +35,11 @@ stdenv.mkDerivation rec { ./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 =