2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, pkg-config
|
2022-10-21 18:38:19 +00:00
|
|
|
, libdeflate, libpng, libtiff, zlib, lcms2, jpylyzer
|
2020-04-24 23:36:52 +00:00
|
|
|
, jpipLibSupport ? false # JPIP library & executables
|
2022-10-21 18:38:19 +00:00
|
|
|
, jpipServerSupport ? false, curl, fcgi # JPIP Server
|
|
|
|
, jdk
|
|
|
|
, poppler
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
mkFlag = optSet: flag: "-D${flag}=${if optSet then "ON" else "OFF"}";
|
|
|
|
in
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "openjpeg";
|
2022-10-21 18:38:19 +00:00
|
|
|
version = "2.5.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "uclouvain";
|
|
|
|
repo = "openjpeg";
|
2021-02-05 17:12:51 +00:00
|
|
|
rev = "v${version}";
|
2022-10-21 18:38:19 +00:00
|
|
|
sha256 = "sha256-/0o3Fl6/jx5zu854TCqMyOz/8mnEyEC9lpZ6ij/tbHc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
patches = [
|
2022-10-21 18:38:19 +00:00
|
|
|
# modernise cmake files, also fixes them for multiple outputs
|
2021-02-05 17:12:51 +00:00
|
|
|
(fetchpatch {
|
2022-10-21 18:38:19 +00:00
|
|
|
url = "https://github.com/uclouvain/openjpeg/pull/1424.patch";
|
|
|
|
sha256 = "sha256-CxVRt1u4HVOMUjWiZ2plmZC29t/zshCpSY+N4Wlrlvg=";
|
|
|
|
})
|
|
|
|
# fix cmake files cross compilation
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/uclouvain/openjpeg/commit/c6ceb84c221b5094f1e8a4c0c247dee3fb5074e8.patch";
|
|
|
|
sha256 = "sha256-gBUtmO/7RwSWEl7rc8HGr8gNtvNFdhjEwm0Dd51p5O8=";
|
2021-02-05 17:12:51 +00:00
|
|
|
})
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DCMAKE_INSTALL_NAME_DIR=\${CMAKE_INSTALL_PREFIX}/lib"
|
|
|
|
"-DBUILD_SHARED_LIBS=ON"
|
|
|
|
"-DBUILD_CODEC=ON"
|
2022-10-21 18:38:19 +00:00
|
|
|
"-DBUILD_THIRDPARTY=OFF"
|
2020-04-24 23:36:52 +00:00
|
|
|
(mkFlag jpipLibSupport "BUILD_JPIP")
|
|
|
|
(mkFlag jpipServerSupport "BUILD_JPIP_SERVER")
|
|
|
|
"-DBUILD_VIEWER=OFF"
|
2022-10-21 18:38:19 +00:00
|
|
|
"-DBUILD_JAVA=OFF"
|
|
|
|
(mkFlag doCheck "BUILD_TESTING")
|
2021-02-05 17:12:51 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ cmake pkg-config ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
buildInputs = [ libpng libtiff zlib lcms2 ]
|
2022-10-21 18:38:19 +00:00
|
|
|
++ lib.optionals jpipServerSupport [ curl fcgi ]
|
|
|
|
++ lib.optional (jpipLibSupport) jdk;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
doCheck = (!stdenv.isAarch64 && !stdenv.hostPlatform.isPower64); # tests fail on aarch64-linux and powerpc64
|
2023-03-04 12:14:45 +00:00
|
|
|
nativeCheckInputs = [ jpylyzer ];
|
2020-04-24 23:36:52 +00:00
|
|
|
checkPhase = ''
|
|
|
|
substituteInPlace ../tools/ctest_scripts/travis-ci.cmake \
|
2023-03-04 12:14:45 +00:00
|
|
|
--replace "JPYLYZER_EXECUTABLE=" "JPYLYZER_EXECUTABLE=\"$(command -v jpylyzer)\" # "
|
2020-04-24 23:36:52 +00:00
|
|
|
OPJ_SOURCE_DIR=.. ctest -S ../tools/ctest_scripts/travis-ci.cmake
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = {
|
2022-10-21 18:38:19 +00:00
|
|
|
incDir = "openjpeg-${lib.versions.majorMinor version}";
|
|
|
|
tests = {
|
|
|
|
inherit poppler;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Open-source JPEG 2000 codec written in C language";
|
2021-02-05 17:12:51 +00:00
|
|
|
homepage = "https://www.openjpeg.org/";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.bsd2;
|
|
|
|
maintainers = with maintainers; [ codyopel ];
|
|
|
|
platforms = platforms.all;
|
2022-11-21 17:40:18 +00:00
|
|
|
changelog = "https://github.com/uclouvain/openjpeg/blob/v${version}/CHANGELOG.md";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|