python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / libraries / openjpeg / default.nix
blobad4206eedfbb475eda66f252263534c5dc4e6f26
1 { lib, stdenv, fetchFromGitHub, fetchpatch, cmake, pkg-config
2 , libdeflate, libpng, libtiff, zlib, lcms2, jpylyzer
3 , jpipLibSupport ? false # JPIP library & executables
4 , jpipServerSupport ? false, curl, fcgi # JPIP Server
5 , jdk
6 , poppler
7 }:
9 let
10   mkFlag = optSet: flag: "-D${flag}=${if optSet then "ON" else "OFF"}";
13 stdenv.mkDerivation rec {
14   pname = "openjpeg";
15   version = "2.5.0";
17   src = fetchFromGitHub {
18     owner = "uclouvain";
19     repo = "openjpeg";
20     rev = "v${version}";
21     sha256 = "sha256-/0o3Fl6/jx5zu854TCqMyOz/8mnEyEC9lpZ6ij/tbHc=";
22   };
24   outputs = [ "out" "dev" ];
26   patches = [
27     # modernise cmake files, also fixes them for multiple outputs
28     (fetchpatch {
29       url = "https://github.com/uclouvain/openjpeg/pull/1424.patch";
30       sha256 = "sha256-CxVRt1u4HVOMUjWiZ2plmZC29t/zshCpSY+N4Wlrlvg=";
31     })
32     # fix cmake files cross compilation
33     (fetchpatch {
34       url = "https://github.com/uclouvain/openjpeg/commit/c6ceb84c221b5094f1e8a4c0c247dee3fb5074e8.patch";
35       sha256 = "sha256-gBUtmO/7RwSWEl7rc8HGr8gNtvNFdhjEwm0Dd51p5O8=";
36     })
37   ];
39   cmakeFlags = [
40     "-DCMAKE_INSTALL_NAME_DIR=\${CMAKE_INSTALL_PREFIX}/lib"
41     "-DBUILD_SHARED_LIBS=ON"
42     "-DBUILD_CODEC=ON"
43     "-DBUILD_THIRDPARTY=OFF"
44     (mkFlag jpipLibSupport "BUILD_JPIP")
45     (mkFlag jpipServerSupport "BUILD_JPIP_SERVER")
46     "-DBUILD_VIEWER=OFF"
47     "-DBUILD_JAVA=OFF"
48     (mkFlag doCheck "BUILD_TESTING")
49   ];
51   nativeBuildInputs = [ cmake pkg-config ];
53   buildInputs = [ libdeflate libpng libtiff zlib lcms2 ]
54     ++ lib.optionals jpipServerSupport [ curl fcgi ]
55     ++ lib.optional (jpipLibSupport) jdk;
57   doCheck = (!stdenv.isAarch64 && !stdenv.hostPlatform.isPower64); # tests fail on aarch64-linux and powerpc64
59   checkPhase = ''
60     substituteInPlace ../tools/ctest_scripts/travis-ci.cmake \
61       --replace "JPYLYZER_EXECUTABLE=" "JPYLYZER_EXECUTABLE=\"${jpylyzer}/bin/jpylyzer\" # "
62     OPJ_SOURCE_DIR=.. ctest -S ../tools/ctest_scripts/travis-ci.cmake
63   '';
65   passthru = {
66     incDir = "openjpeg-${lib.versions.majorMinor version}";
67     tests = {
68       inherit poppler;
69     };
70   };
72   meta = with lib; {
73     description = "Open-source JPEG 2000 codec written in C language";
74     homepage = "https://www.openjpeg.org/";
75     license = licenses.bsd2;
76     maintainers = with maintainers; [ codyopel ];
77     platforms = platforms.all;
78     changelog = "https://github.com/uclouvain/openjpeg/blob/v${version}/CHANGELOG.md";
79   };