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
10 mkFlag = optSet: flag: "-D${flag}=${if optSet then "ON" else "OFF"}";
13 stdenv.mkDerivation rec {
17 src = fetchFromGitHub {
21 sha256 = "sha256-/0o3Fl6/jx5zu854TCqMyOz/8mnEyEC9lpZ6ij/tbHc=";
24 outputs = [ "out" "dev" ];
27 # modernise cmake files, also fixes them for multiple outputs
29 url = "https://github.com/uclouvain/openjpeg/pull/1424.patch";
30 sha256 = "sha256-CxVRt1u4HVOMUjWiZ2plmZC29t/zshCpSY+N4Wlrlvg=";
32 # fix cmake files cross compilation
34 url = "https://github.com/uclouvain/openjpeg/commit/c6ceb84c221b5094f1e8a4c0c247dee3fb5074e8.patch";
35 sha256 = "sha256-gBUtmO/7RwSWEl7rc8HGr8gNtvNFdhjEwm0Dd51p5O8=";
40 "-DCMAKE_INSTALL_NAME_DIR=\${CMAKE_INSTALL_PREFIX}/lib"
41 "-DBUILD_SHARED_LIBS=ON"
43 "-DBUILD_THIRDPARTY=OFF"
44 (mkFlag jpipLibSupport "BUILD_JPIP")
45 (mkFlag jpipServerSupport "BUILD_JPIP_SERVER")
48 (mkFlag doCheck "BUILD_TESTING")
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
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
66 incDir = "openjpeg-${lib.versions.majorMinor version}";
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";