11{ config , lib , stdenv , fetchFromGitHub , cmake , pkg-config , xorg , libGLU
22, libGL , glew , ocl-icd , python3
3- , cudaSupport ? config . cudaSupport , cudatoolkit
4- # For visibility mostly. The whole approach to cuda architectures and capabilities
5- # will be reworked soon.
6- , cudaArch ? "compute_37"
3+ , cudaSupport ? config . cudaSupport
4+ , cudaPackages
75, openclSupport ? ! cudaSupport
86, darwin
97} :
@@ -21,7 +19,11 @@ stdenv.mkDerivation rec {
2119
2220 outputs = [ "out" "dev" ] ;
2321
24- nativeBuildInputs = [ cmake pkg-config ] ;
22+ nativeBuildInputs = [
23+ cmake
24+ pkg-config
25+ cudaPackages . cuda_nvcc
26+ ] ;
2527 buildInputs =
2628 [ libGLU libGL python3
2729 # FIXME: these are not actually needed, but the configure script wants them.
@@ -30,21 +32,31 @@ stdenv.mkDerivation rec {
3032 ]
3133 ++ lib . optional ( openclSupport && ! stdenv . isDarwin ) ocl-icd
3234 ++ lib . optionals stdenv . isDarwin ( with darwin . apple_sdk . frameworks ; [ OpenCL Cocoa CoreVideo IOKit AppKit AGL ] )
33- ++ lib . optional cudaSupport cudatoolkit ;
35+ ++ lib . optional cudaSupport [
36+ cudaPackages . cuda_cudart
37+ ] ;
38+
39+ # It's important to set OSD_CUDA_NVCC_FLAGS,
40+ # because otherwise OSD might piggyback unwanted architectures:
41+ # https://github.com/PixarAnimationStudios/OpenSubdiv/blob/7d0ab5530feef693ac0a920585b5c663b80773b3/CMakeLists.txt#L602
42+ preConfigure = lib . optionalString cudaSupport ''
43+ cmakeFlagsArray+=(
44+ -DOSD_CUDA_NVCC_FLAGS="${ lib . concatStringsSep " " cudaPackages . cudaFlags . gencode } "
45+ )
46+ '' ;
3447
3548 cmakeFlags =
3649 [ "-DNO_TUTORIALS=1"
3750 "-DNO_REGRESSION=1"
3851 "-DNO_EXAMPLES=1"
3952 "-DNO_METAL=1" # don’t have metal in apple sdk
53+ ( lib . cmakeBool "NO_OPENCL" ( ! openclSupport ) )
54+ ( lib . cmakeBool "NO_CUDA" ( ! cudaSupport ) )
4055 ] ++ lib . optionals ( ! stdenv . isDarwin ) [
4156 "-DGLEW_INCLUDE_DIR=${ glew . dev } /include"
4257 "-DGLEW_LIBRARY=${ glew . dev } /lib"
4358 ] ++ lib . optionals cudaSupport [
44- "-DOSD_CUDA_NVCC_FLAGS=--gpu-architecture=${ cudaArch } "
45- "-DCUDA_HOST_COMPILER=${ cudatoolkit . cc } /bin/cc"
4659 ] ++ lib . optionals ( ! openclSupport ) [
47- "-DNO_OPENCL=1"
4860 ] ;
4961
5062 preBuild = let maxBuildCores = 16 ; in lib . optionalString cudaSupport ''
0 commit comments