ripasso-cursive: cosmetic changes (#361736)
[NixPkgs.git] / pkgs / by-name / dl / dlib / package.nix
blob8d85fc3325e228f8ece9119c8aa599ccf8dc4850
1 { stdenv
2 , lib
3 , fetchFromGitHub
4 , cmake
5 , pkg-config
6 , libpng
7 , libjpeg
8 , libwebp
9 , blas
10 , lapack
11 , config
12 , guiSupport ? false
13 , libX11
14 , enableShared ? !stdenv.hostPlatform.isStatic # dlib has a build system that forces the user to choose between either shared or static libraries. See https://github.com/davisking/dlib/issues/923#issuecomment-2175865174
15 , sse4Support ? stdenv.hostPlatform.sse4_1Support
16 , avxSupport ? stdenv.hostPlatform.avxSupport
17 , cudaSupport ? config.cudaSupport
18 , cudaPackages
19 }@inputs:
20 (if cudaSupport then cudaPackages.backendStdenv else inputs.stdenv).mkDerivation rec {
21   pname = "dlib";
22   version = "19.24.6";
24   src = fetchFromGitHub {
25     owner = "davisking";
26     repo = "dlib";
27     rev = "refs/tags/v${version}";
28     sha256 = "sha256-BpE7ZrtiiaDqwy1G4IHOQBJMr6sAadFbRxsdObs1SIY=";
29   };
31   postPatch = ''
32     rm -rf dlib/external
33   '';
35   cmakeFlags = [
36     (lib.cmakeBool "BUILD_SHARED_LIBS" enableShared)
37     (lib.cmakeBool "USE_SSE4_INSTRUCTIONS" sse4Support)
38     (lib.cmakeBool "USE_AVX_INSTRUCTIONS" avxSupport)
39     (lib.cmakeBool "DLIB_USE_CUDA" cudaSupport)
40   ] ++ lib.optionals cudaSupport [
41     (lib.cmakeFeature "DLIB_USE_CUDA_COMPUTE_CAPABILITIES" (builtins.concatStringsSep "," (with cudaPackages.flags; map dropDot cudaCapabilities)))
42   ];
44   nativeBuildInputs = [
45     cmake
46     pkg-config
47   ] ++ lib.optionals cudaSupport (with cudaPackages; [
48     cuda_nvcc
49   ]);
51   buildInputs = [
52     libpng
53     libjpeg
54     libwebp
55     blas
56     lapack
57   ]
58   ++ lib.optionals guiSupport [ libX11 ]
59   ++ lib.optionals cudaSupport (with cudaPackages; [
60     cuda_cudart
61     cuda_nvcc
62     libcublas
63     libcurand
64     libcusolver
65     cudnn
66     cuda_cccl
67   ]);
69   passthru = {
70     inherit
71       cudaSupport cudaPackages
72       sse4Support avxSupport;
73   };
75   meta = with lib; {
76     description = "General purpose cross-platform C++ machine learning library";
77     homepage = "http://www.dlib.net";
78     license = licenses.boost;
79     maintainers = with maintainers; [ christopherpoole ];
80     platforms = platforms.unix;
81   };