nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05-pre 90 lines 3.1 kB view raw
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 11, testsSupport ? true 12, jdk ? null 13}: 14 15assert jpipServerSupport -> jpipLibSupport && curl != null && fcgi != null; 16#assert opjViewerSupport -> (wxGTK != null); 17assert (openjpegJarSupport || jpipLibSupport) -> jdk != null; 18 19let 20 inherit (lib) optional optionals; 21 mkFlag = optSet: flag: "-D${flag}=${if optSet then "ON" else "OFF"}"; 22in 23 24stdenv.mkDerivation rec { 25 pname = "openjpeg"; 26 version = "2.4.0"; # don't forget to change passthru.incDir 27 28 src = fetchFromGitHub { 29 owner = "uclouvain"; 30 repo = "openjpeg"; 31 rev = "v${version}"; 32 sha256 = "143dvy5g6v6129lzvl0r8mrgva2fppkn0zl099qmi9yi9l9h7yyf"; 33 }; 34 35 patches = [ 36 ./fix-cmake-config-includedir.patch 37 (fetchpatch { 38 url = "https://patch-diff.githubusercontent.com/raw/uclouvain/openjpeg/pull/1321.patch"; 39 sha256 = "1cjpr76nf9g65nqkfnxnjzi3bv7ifbxpc74kxxibh58pzjlp6al8"; 40 }) 41 ]; 42 43 outputs = [ "out" "dev" ]; 44 45 cmakeFlags = [ 46 "-DCMAKE_INSTALL_NAME_DIR=\${CMAKE_INSTALL_PREFIX}/lib" 47 "-DBUILD_SHARED_LIBS=ON" 48 "-DBUILD_CODEC=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") 54 "-DBUILD_VIEWER=OFF" 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}" 61 ]; 62 63 nativeBuildInputs = [ cmake pkg-config ]; 64 65 buildInputs = [ ] 66 ++ optionals jpipServerSupport [ curl fcgi ] 67 #++ optional opjViewerSupport wxGTK 68 ++ optional (openjpegJarSupport || jpipLibSupport) jdk; 69 70 propagatedBuildInputs = [ libpng libtiff lcms2 ]; 71 72 doCheck = (testsSupport && !stdenv.isAarch64); # tests fail on aarch64-linux 73 checkPhase = '' 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 77 ''; 78 79 passthru = { 80 incDir = "openjpeg-2.4"; 81 }; 82 83 meta = with lib; { 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; 89 }; 90}