1{ lib, stdenv, fetchFromGitHub, fetchpatch, libGL, libGLU, libXmu, cmake, ninja,
2 pkg-config, fontconfig, freetype, expat, freeimage, vtk_8, gl2ps, tbb,
3 OpenCL, Cocoa
4}:
5
6stdenv.mkDerivation rec {
7 pname = "opencascade-oce";
8 version = "0.18.3";
9
10 src = fetchFromGitHub {
11 owner = "tpaviot";
12 repo = "oce";
13 rev = "OCE-${version}";
14 sha256 = "17wy8dcf44vqisishv1jjf3cmcxyygqq29y9c3wjdj983qi2hsig";
15 };
16
17 nativeBuildInputs = [ cmake ninja pkg-config ];
18 buildInputs = [
19 libGL libGLU libXmu freetype fontconfig expat freeimage vtk_8
20 gl2ps tbb
21 ]
22 ++ lib.optionals stdenv.isDarwin [OpenCL Cocoa]
23 ;
24
25 cmakeFlags = [
26 "-DOCE_INSTALL_PREFIX=${placeholder "out"}"
27 "-DOCE_WITH_FREEIMAGE=ON"
28 "-DOCE_WITH_VTK=ON"
29 "-DOCE_WITH_GL2PS=ON"
30 "-DOCE_MULTITHREAD_LIBRARY=TBB"
31 ]
32 ++ lib.optionals stdenv.isDarwin ["-DOCE_OSX_USE_COCOA=ON" "-DOCE_WITH_OPENCL=ON"];
33
34 patches = [
35 # Use fontconfig instead of hardcoded directory list
36 # https://github.com/tpaviot/oce/pull/714
37 (fetchpatch {
38 url = "https://github.com/tpaviot/oce/commit/9643432b27fec8974ca0ee15c3c372f5fe8fc069.patch";
39 sha256 = "1wd940rszmh5apcpk5fv6126h8mcjcy4rjifrql5d4ac90v06v4c";
40 })
41 # Fix for glibc 2.26
42 (fetchpatch {
43 url = "https://github.com/tpaviot/oce/commit/3b44656e93270d782009b06ec4be84d2a13f8126.patch";
44 sha256 = "1ccakkcwy5g0184m23x0mnh22i0lk45xm8kgiv5z3pl7nh35dh8k";
45 })
46 (fetchpatch {
47 url = "https://github.com/tpaviot/oce/commit/cf50d078cd5fac03a48fd204938bd240930a08dc.patch";
48 sha256 = "1xv94hcvggmb1c8vqwic1aiw9jw1sxk8mqbaak9xs9ycfqdvgdyc";
49 })
50 ];
51
52 postPatch = ''
53 # make sure the installed cmake file uses absolute paths for fontconfig
54 substituteInPlace adm/cmake/TKService/CMakeLists.txt \
55 --replace FONTCONFIG_LIBRARIES FONTCONFIG_LINK_LIBRARIES
56 '';
57
58 meta = with lib; {
59 description = "Open CASCADE Technology, libraries for 3D modeling and numerical simulation";
60 homepage = "https://github.com/tpaviot/oce";
61 maintainers = [ maintainers.viric ];
62 platforms = platforms.unix;
63 license = licenses.lgpl21;
64 };
65}