1 { lib, stdenv, fetchFromGitHub, fetchpatch, cmake, pkg-config
2 , libpng, libtiff, lcms2, jpylyzer
3 , mj2Support ? true # MJ2 executables
4 , jpwlLibSupport ? true # JPWL library & executables
5 , jpipLibSupport ? false # JPIP library & executables
6 , jpipServerSupport ? false, curl ? null, fcgi ? null # JPIP Server
7 #, opjViewerSupport ? false, wxGTK ? null # OPJViewer executable
8 , openjpegJarSupport ? false # Openjpeg jar (Java)
9 , jp3dSupport ? true # # JP3D comp
10 , thirdPartySupport ? false # Third party libraries - OFF: only build when found, ON: always build
15 assert jpipServerSupport -> jpipLibSupport && curl != null && fcgi != null;
16 #assert opjViewerSupport -> (wxGTK != null);
17 assert (openjpegJarSupport || jpipLibSupport) -> jdk != null;
20 inherit (lib) optional optionals;
21 mkFlag = optSet: flag: "-D${flag}=${if optSet then "ON" else "OFF"}";
24 stdenv.mkDerivation rec {
26 version = "2.4.0"; # don't forget to change passthru.incDir
28 src = fetchFromGitHub {
32 sha256 = "143dvy5g6v6129lzvl0r8mrgva2fppkn0zl099qmi9yi9l9h7yyf";
36 ./fix-cmake-config-includedir.patch
38 url = "https://patch-diff.githubusercontent.com/raw/uclouvain/openjpeg/pull/1321.patch";
39 sha256 = "1cjpr76nf9g65nqkfnxnjzi3bv7ifbxpc74kxxibh58pzjlp6al8";
43 outputs = [ "out" "dev" ];
46 "-DCMAKE_INSTALL_NAME_DIR=\${CMAKE_INSTALL_PREFIX}/lib"
47 "-DBUILD_SHARED_LIBS=ON"
49 (mkFlag mj2Support "BUILD_MJ2")
50 (mkFlag jpwlLibSupport "BUILD_JPWL")
51 (mkFlag jpipLibSupport "BUILD_JPIP")
52 (mkFlag jpipServerSupport "BUILD_JPIP_SERVER")
53 #(mkFlag opjViewerSupport "BUILD_VIEWER")
55 (mkFlag openjpegJarSupport "BUILD_JAVA")
56 (mkFlag jp3dSupport "BUILD_JP3D")
57 (mkFlag thirdPartySupport "BUILD_THIRDPARTY")
58 (mkFlag testsSupport "BUILD_TESTING")
59 "-DOPENJPEG_INSTALL_INCLUDE_DIR=${placeholder "dev"}/include/${passthru.incDir}"
60 "-DOPENJPEG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/${passthru.incDir}"
63 nativeBuildInputs = [ cmake pkg-config ];
66 ++ optionals jpipServerSupport [ curl fcgi ]
67 #++ optional opjViewerSupport wxGTK
68 ++ optional (openjpegJarSupport || jpipLibSupport) jdk;
70 propagatedBuildInputs = [ libpng libtiff lcms2 ];
72 doCheck = (testsSupport && !stdenv.isAarch64); # tests fail on aarch64-linux
74 substituteInPlace ../tools/ctest_scripts/travis-ci.cmake \
75 --replace "JPYLYZER_EXECUTABLE=" "JPYLYZER_EXECUTABLE=\"${jpylyzer}/bin/jpylyzer\" # "
76 OPJ_SOURCE_DIR=.. ctest -S ../tools/ctest_scripts/travis-ci.cmake
80 incDir = "openjpeg-2.4";
84 description = "Open-source JPEG 2000 codec written in C language";
85 homepage = "https://www.openjpeg.org/";
86 license = licenses.bsd2;
87 maintainers = with maintainers; [ codyopel ];
88 platforms = platforms.all;