1{ stdenv, lib, fetchFromGitHub, cmake, pkg-config, libpng, libjpeg
2, guiSupport ? false, libX11
3
4 # see http://dlib.net/compile.html
5, sse4Support ? stdenv.hostPlatform.sse4_1Support
6, avxSupport ? stdenv.hostPlatform.avxSupport
7, cudaSupport ? true
8}:
9
10stdenv.mkDerivation rec {
11 pname = "dlib";
12 version = "19.24.2";
13
14 src = fetchFromGitHub {
15 owner = "davisking";
16 repo = "dlib";
17 rev ="v${version}";
18 sha256 = "sha256-Z1fScuaIHjj2L1uqLIvsZ7ARKNjM+iaA8SAtWUTPFZk=";
19 };
20
21 postPatch = ''
22 rm -rf dlib/external
23 '';
24
25 cmakeFlags = [
26 "-DUSE_DLIB_USE_CUDA=${if cudaSupport then "1" else "0"}"
27 "-DUSE_SSE4_INSTRUCTIONS=${if sse4Support then "yes" else "no"}"
28 "-DUSE_AVX_INSTRUCTIONS=${if avxSupport then "yes" else "no"}" ];
29
30 nativeBuildInputs = [ cmake pkg-config ];
31 buildInputs = [ libpng libjpeg ] ++ lib.optional guiSupport libX11;
32
33 meta = with lib; {
34 description = "A general purpose cross-platform C++ machine learning library";
35 homepage = "http://www.dlib.net";
36 license = licenses.boost;
37 maintainers = with maintainers; [ christopherpoole ma27 ];
38 platforms = platforms.unix;
39 };
40}