2024-01-02 11:29:13 +00:00
{ stdenv
, lib
, fetchFromGitHub
, cmake
, pkg-config
, libpng
, libjpeg
, libwebp
2024-01-25 14:12:00 +00:00
, blas
, lapack
, config
2024-01-02 11:29:13 +00:00
, guiSupport ? false
, libX11
2024-06-20 14:57:18 +00:00
, 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
2021-03-09 03:18:52 +00:00
, sse4Support ? stdenv . hostPlatform . sse4_1Support
2020-09-25 04:45:31 +00:00
, avxSupport ? stdenv . hostPlatform . avxSupport
2024-01-25 14:12:00 +00:00
, cudaSupport ? config . cudaSupport
, cudaPackages
} @ inputs :
( if cudaSupport then cudaPackages . backendStdenv else inputs . stdenv ) . mkDerivation rec {
2020-04-24 23:36:52 +00:00
pname = " d l i b " ;
2024-09-19 14:19:46 +00:00
version = " 1 9 . 2 4 . 6 " ;
2020-04-24 23:36:52 +00:00
src = fetchFromGitHub {
owner = " d a v i s k i n g " ;
repo = " d l i b " ;
2024-09-19 14:19:46 +00:00
rev = " r e f s / t a g s / v ${ version } " ;
sha256 = " s h a 2 5 6 - B p E 7 Z r t i i a D q w y 1 G 4 I H O Q B J M r 6 s A a d F b R x s d O b s 1 S I Y = " ;
2020-04-24 23:36:52 +00:00
} ;
postPatch = ''
rm - rf dlib/external
'' ;
2020-09-25 04:45:31 +00:00
cmakeFlags = [
2024-06-20 14:57:18 +00:00
( lib . cmakeBool " B U I L D _ S H A R E D _ L I B S " enableShared )
2024-01-02 11:29:13 +00:00
( lib . cmakeBool " U S E _ S S E 4 _ I N S T R U C T I O N S " sse4Support )
( lib . cmakeBool " U S E _ A V X _ I N S T R U C T I O N S " avxSupport )
2024-01-25 14:12:00 +00:00
( lib . cmakeBool " D L I B _ U S E _ C U D A " cudaSupport )
] ++ lib . optionals cudaSupport [
( lib . cmakeFeature " D L I B _ U S E _ C U D A _ C O M P U T E _ C A P A B I L I T I E S " ( builtins . concatStringsSep " , " ( with cudaPackages . flags ; map dropDot cudaCapabilities ) ) )
2024-01-02 11:29:13 +00:00
] ;
2020-04-24 23:36:52 +00:00
2024-01-25 14:12:00 +00:00
nativeBuildInputs = [
cmake
pkg-config
] ++ lib . optionals cudaSupport ( with cudaPackages ; [
cuda_nvcc
] ) ;
2024-01-02 11:29:13 +00:00
buildInputs = [
libpng
libjpeg
libwebp
2024-01-25 14:12:00 +00:00
blas
lapack
]
++ lib . optionals guiSupport [ libX11 ]
2024-04-21 15:54:59 +00:00
++ lib . optionals cudaSupport ( with cudaPackages ; [
2024-07-27 06:49:29 +00:00
cuda_cudart
cuda_nvcc
libcublas
libcurand
libcusolver
cudnn
cuda_cccl
2024-01-25 14:12:00 +00:00
] ) ;
passthru = {
inherit
cudaSupport cudaPackages
sse4Support avxSupport ;
} ;
2020-04-24 23:36:52 +00:00
2021-02-05 17:12:51 +00:00
meta = with lib ; {
2024-06-20 14:57:18 +00:00
description = " G e n e r a l p u r p o s e c r o s s - p l a t f o r m C + + m a c h i n e l e a r n i n g l i b r a r y " ;
2020-04-24 23:36:52 +00:00
homepage = " h t t p : / / w w w . d l i b . n e t " ;
license = licenses . boost ;
2023-10-19 13:55:26 +00:00
maintainers = with maintainers ; [ christopherpoole ] ;
2022-09-09 14:08:57 +00:00
platforms = platforms . unix ;
2020-04-24 23:36:52 +00:00
} ;
}