Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 88 lines 2.7 kB view raw
1{ config, lib, stdenv, fetchFromGitHub, cmake, pkg-config, xorg, libGLU 2, libGL, glew, ocl-icd, python3 3, cudaSupport ? config.cudaSupport 4, cudaPackages 5, openclSupport ? !cudaSupport 6, darwin 7}: 8 9stdenv.mkDerivation rec { 10 pname = "opensubdiv"; 11 version = "3.6.0"; 12 13 src = fetchFromGitHub { 14 owner = "PixarAnimationStudios"; 15 repo = "OpenSubdiv"; 16 rev = "v${lib.replaceStrings ["."] ["_"] version}"; 17 sha256 = "sha256-liy6pQyWMk7rw0usrCoLGzZLO7RAg0z2pV/GF2NnOkE="; 18 }; 19 20 outputs = [ "out" "dev" "static" ]; 21 22 nativeBuildInputs = [ 23 cmake 24 pkg-config 25 ] ++ lib.optional cudaSupport [ 26 cudaPackages.cuda_nvcc 27 ]; 28 buildInputs = 29 [ libGLU libGL python3 30 # FIXME: these are not actually needed, but the configure script wants them. 31 glew xorg.libX11 xorg.libXrandr xorg.libXxf86vm xorg.libXcursor 32 xorg.libXinerama xorg.libXi 33 ] 34 ++ lib.optionals (openclSupport && !stdenv.isDarwin) [ ocl-icd ] 35 ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ 36 OpenCL 37 Cocoa 38 CoreVideo 39 IOKit 40 AppKit 41 AGL 42 MetalKit 43 ]) 44 ++ lib.optionals cudaSupport [ 45 cudaPackages.cuda_cudart 46 ]; 47 48 # It's important to set OSD_CUDA_NVCC_FLAGS, 49 # because otherwise OSD might piggyback unwanted architectures: 50 # https://github.com/PixarAnimationStudios/OpenSubdiv/blob/7d0ab5530feef693ac0a920585b5c663b80773b3/CMakeLists.txt#L602 51 preConfigure = lib.optionalString cudaSupport '' 52 cmakeFlagsArray+=( 53 -DOSD_CUDA_NVCC_FLAGS="${lib.concatStringsSep " " cudaPackages.cudaFlags.gencode}" 54 ) 55 ''; 56 57 cmakeFlags = 58 [ "-DNO_TUTORIALS=1" 59 "-DNO_REGRESSION=1" 60 "-DNO_EXAMPLES=1" 61 (lib.cmakeBool "NO_METAL" (!stdenv.isDarwin)) 62 (lib.cmakeBool "NO_OPENCL" (!openclSupport)) 63 (lib.cmakeBool "NO_CUDA" (!cudaSupport)) 64 ] ++ lib.optionals (!stdenv.isDarwin) [ 65 "-DGLEW_INCLUDE_DIR=${glew.dev}/include" 66 "-DGLEW_LIBRARY=${glew.dev}/lib" 67 ] ++ lib.optionals cudaSupport [ 68 ] ++ lib.optionals (!openclSupport) [ 69 ]; 70 71 preBuild = let maxBuildCores = 16; in lib.optionalString cudaSupport '' 72 # https://github.com/PixarAnimationStudios/OpenSubdiv/issues/1313 73 NIX_BUILD_CORES=$(( NIX_BUILD_CORES < ${toString maxBuildCores} ? NIX_BUILD_CORES : ${toString maxBuildCores} )) 74 ''; 75 76 postInstall = '' 77 moveToOutput "lib/*.a" $static 78 ''; 79 80 meta = { 81 description = "Open-Source subdivision surface library"; 82 homepage = "http://graphics.pixar.com/opensubdiv"; 83 broken = openclSupport && cudaSupport; 84 platforms = lib.platforms.unix; 85 maintainers = [ lib.maintainers.eelco ]; 86 license = lib.licenses.asl20; 87 }; 88}