2021-01-15 22:18:51 +00:00
|
|
|
{ config, lib, stdenv, fetchFromGitHub, cmake, pkg-config, xorg, libGLU
|
2020-04-24 23:36:52 +00:00
|
|
|
, libGL, glew, ocl-icd, python3
|
2024-01-02 11:29:13 +00:00
|
|
|
, cudaSupport ? config.cudaSupport
|
|
|
|
, cudaPackages
|
2022-04-15 01:41:22 +00:00
|
|
|
, openclSupport ? !cudaSupport
|
2020-04-24 23:36:52 +00:00
|
|
|
, darwin
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "opensubdiv";
|
2023-10-09 19:29:22 +00:00
|
|
|
version = "3.5.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "PixarAnimationStudios";
|
|
|
|
repo = "OpenSubdiv";
|
2022-12-17 10:02:37 +00:00
|
|
|
rev = "v${lib.replaceStrings ["."] ["_"] version}";
|
2023-10-09 19:29:22 +00:00
|
|
|
sha256 = "sha256-uDKCT0Uoa5WQekMUFm2iZmzm+oWAZ6IWMwfpchkUZY0=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
outputs = [ "out" "dev" "static" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
pkg-config
|
|
|
|
] ++ lib.optional cudaSupport [
|
|
|
|
cudaPackages.cuda_nvcc
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs =
|
2021-01-15 22:18:51 +00:00
|
|
|
[ libGLU libGL python3
|
2020-04-24 23:36:52 +00:00
|
|
|
# FIXME: these are not actually needed, but the configure script wants them.
|
|
|
|
glew xorg.libX11 xorg.libXrandr xorg.libXxf86vm xorg.libXcursor
|
|
|
|
xorg.libXinerama xorg.libXi
|
|
|
|
]
|
2024-02-29 20:09:43 +00:00
|
|
|
++ lib.optionals (openclSupport && !stdenv.isDarwin) [ ocl-icd ]
|
|
|
|
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
|
|
|
|
OpenCL
|
|
|
|
Cocoa
|
|
|
|
CoreVideo
|
|
|
|
IOKit
|
|
|
|
AppKit
|
|
|
|
AGL
|
|
|
|
MetalKit
|
|
|
|
])
|
|
|
|
++ lib.optionals cudaSupport [
|
2024-01-02 11:29:13 +00:00
|
|
|
cudaPackages.cuda_cudart
|
|
|
|
];
|
|
|
|
|
|
|
|
# It's important to set OSD_CUDA_NVCC_FLAGS,
|
|
|
|
# because otherwise OSD might piggyback unwanted architectures:
|
|
|
|
# https://github.com/PixarAnimationStudios/OpenSubdiv/blob/7d0ab5530feef693ac0a920585b5c663b80773b3/CMakeLists.txt#L602
|
|
|
|
preConfigure = lib.optionalString cudaSupport ''
|
|
|
|
cmakeFlagsArray+=(
|
|
|
|
-DOSD_CUDA_NVCC_FLAGS="${lib.concatStringsSep " " cudaPackages.cudaFlags.gencode}"
|
|
|
|
)
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags =
|
|
|
|
[ "-DNO_TUTORIALS=1"
|
|
|
|
"-DNO_REGRESSION=1"
|
|
|
|
"-DNO_EXAMPLES=1"
|
2024-02-29 20:09:43 +00:00
|
|
|
(lib.cmakeBool "NO_METAL" (!stdenv.isDarwin))
|
2024-01-02 11:29:13 +00:00
|
|
|
(lib.cmakeBool "NO_OPENCL" (!openclSupport))
|
|
|
|
(lib.cmakeBool "NO_CUDA" (!cudaSupport))
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ lib.optionals (!stdenv.isDarwin) [
|
|
|
|
"-DGLEW_INCLUDE_DIR=${glew.dev}/include"
|
|
|
|
"-DGLEW_LIBRARY=${glew.dev}/lib"
|
|
|
|
] ++ lib.optionals cudaSupport [
|
2022-04-15 01:41:22 +00:00
|
|
|
] ++ lib.optionals (!openclSupport) [
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
preBuild = let maxBuildCores = 16; in lib.optionalString cudaSupport ''
|
|
|
|
# https://github.com/PixarAnimationStudios/OpenSubdiv/issues/1313
|
|
|
|
NIX_BUILD_CORES=$(( NIX_BUILD_CORES < ${toString maxBuildCores} ? NIX_BUILD_CORES : ${toString maxBuildCores} ))
|
|
|
|
'';
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
postInstall = ''
|
|
|
|
moveToOutput "lib/*.a" $static
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "An Open-Source subdivision surface library";
|
|
|
|
homepage = "http://graphics.pixar.com/opensubdiv";
|
2022-04-15 01:41:22 +00:00
|
|
|
broken = openclSupport && cudaSupport;
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = lib.platforms.unix;
|
|
|
|
maintainers = [ lib.maintainers.eelco ];
|
|
|
|
license = lib.licenses.asl20;
|
|
|
|
};
|
|
|
|
}
|