Skip to content

Commit

Permalink
Merge pull request #299049 from nim65s/meshlab
Browse files Browse the repository at this point in the history
 meshlab: 2022.02 -> 2023.12
  • Loading branch information
SuperSandro2000 authored Apr 20, 2024
2 parents fca59ef + fc7d8b3 commit 3773b49
Show file tree
Hide file tree
Showing 10 changed files with 335 additions and 39 deletions.
58 changes: 32 additions & 26 deletions pkgs/applications/graphics/meshlab/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,27 @@
, qhull
, cmake
, cgal
, boost179
, boost
, mpfr
, xercesc
, tbb
, embree
, vcg
, libigl
, corto
, openctm
, structuresynth
}:

mkDerivation rec {
pname = "meshlab";
version = "2022.02";
version = "2023.12";

src = fetchFromGitHub {
owner = "cnr-isti-vclab";
repo = "meshlab";
rev = "MeshLab-${version}";
sha256 = "sha256-jcc3PfsiIeYyipteZgzd0NwZgFFgR/mMBiaInzhOcDY=";
fetchSubmodules = true; # for vcglib
sha256 = "sha256-AdUAWS741RQclYaSE3Tz1/I0YSinNAnfSaqef+Tib8Y=";
};

buildInputs = [
Expand All @@ -46,38 +52,38 @@ mkDerivation rec {
levmar
qhull
cgal
boost179
boost
mpfr
xercesc
tbb
embree
vcg
libigl
corto
openctm
structuresynth
];

nativeBuildInputs = [ cmake ];

preConfigure = ''
substituteAll ${./meshlab.desktop} scripts/Linux/resources/meshlab.desktop
cmakeDir=$PWD/src
mkdir ../build
cd ../build
substituteAll ${./meshlab.desktop} resources/linux/meshlab.desktop
substituteInPlace src/external/libigl.cmake \
--replace-fail '$'{MESHLAB_EXTERNAL_DOWNLOAD_DIR}/libigl-2.4.0 ${libigl}
substituteInPlace src/external/nexus.cmake \
--replace-fail '$'{NEXUS_DIR}/src/corto ${corto.src}
substituteInPlace src/external/levmar.cmake \
--replace-fail '$'{LEVMAR_LINK} ${levmar.src} \
--replace-warn "MD5 ''${LEVMAR_MD5}" ""
substituteInPlace src/external/ssynth.cmake \
--replace-fail '$'{SSYNTH_LINK} ${structuresynth.src} \
--replace-warn "MD5 ''${SSYNTH_MD5}" ""
substituteInPlace src/common_gui/CMakeLists.txt \
--replace-warn "MESHLAB_LIB_INSTALL_DIR" "CMAKE_INSTALL_LIBDIR"
'';

cmakeFlags = [
"-DALLOW_BUNDLED_EIGEN=OFF"
"-DALLOW_BUNDLED_GLEW=OFF"
"-DALLOW_BUNDLED_LIB3DS=OFF"
"-DALLOW_BUNDLED_MUPARSER=OFF"
"-DALLOW_BUNDLED_QHULL=OFF"
# disable when available in nixpkgs
"-DALLOW_BUNDLED_OPENCTM=ON"
"-DALLOW_BUNDLED_SSYNTH=ON"
"-DALLOW_BUNDLED_BOOST=OFF"
# some plugins are disabled unless these are on
"-DALLOW_BUNDLED_NEWUOA=ON"
"-DALLOW_BUNDLED_LEVMAR=ON"
];

CXXFLAGS = [
# GCC 13: error: 'int16_t' has not been declared in 'std'
"-include cstdint"
"-DVCGDIR=${vcg.src}"
];

postFixup = ''
Expand Down
107 changes: 107 additions & 0 deletions pkgs/applications/graphics/pymeshlab/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{ stdenv
, lib
, fetchFromGitHub
, libGLU
, qtbase
, qtscript
, qtxmlpatterns
, lib3ds
, bzip2
, muparser
, eigen
, glew
, gmp
, levmar
, qhull
, cmake
, cgal
, boost
, mpfr
, xercesc
, tbb
, embree
, vcg
, libigl
, corto
, openctm
, structuresynth
, wrapQtAppsHook
, python3Packages
}:

stdenv.mkDerivation (finalAttrs: {
pname = "pymeshlab";
version = "2023.12";

src = fetchFromGitHub {
owner = "cnr-isti-vclab";
repo = "pymeshlab";
rev = "v${finalAttrs.version}";
hash = "sha256-IOlRdXoUPOJt67g3HqsLchV5aL+JUEks2y1Sy+wpwsg=";
fetchSubmodules = true;
};

buildInputs = [
libGLU
qtbase
qtscript
qtxmlpatterns
lib3ds
bzip2
muparser
eigen
glew
gmp
levmar
qhull
cgal
boost
mpfr
xercesc
tbb
embree
vcg
libigl
corto
structuresynth
openctm
];

nativeBuildInputs = [
cmake
wrapQtAppsHook
python3Packages.pybind11
];

propagatedBuildInputs = [
python3Packages.numpy
];

preConfigure = ''
substituteInPlace src/meshlab/src/external/libigl.cmake \
--replace-fail '$'{MESHLAB_EXTERNAL_DOWNLOAD_DIR}/libigl-2.4.0 ${libigl}
substituteInPlace src/meshlab/src/external/nexus.cmake \
--replace-fail '$'{NEXUS_DIR}/src/corto ${corto.src}
substituteInPlace src/meshlab/src/external/levmar.cmake \
--replace-fail '$'{LEVMAR_LINK} ${levmar.src} \
--replace-warn "MD5 ''${LEVMAR_MD5}" ""
substituteInPlace src/meshlab/src/external/ssynth.cmake \
--replace-fail '$'{SSYNTH_LINK} ${structuresynth.src} \
--replace-warn "MD5 ''${SSYNTH_MD5}" ""
export cmakeFlags="cmakeFlags
-DCMAKE_INSTALL_PREFIX=$out/${python3Packages.python.sitePackages}/pymeshlab
"
'';

cmakeFlags = [
"-DVCGDIR=${vcg.src}"
];

meta = {
description = "The open source mesh processing python library";
homepage = "https://github.com/cnr-isti-vclab/PyMeshLab";
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ nim65s ];
platforms = with lib.platforms; linux;
};
})
27 changes: 27 additions & 0 deletions pkgs/by-name/co/corto/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
lib,
stdenv,
fetchFromGitHub,
cmake,
}:

stdenv.mkDerivation {
pname = "corto";
version = "0-unstable-2024-04-05";

src = fetchFromGitHub {
owner = "cnr-isti-vclab";
repo = "corto";
rev = "d880519c490c88a39d12c31a914b6a687a7019c3";
hash = "sha256-0OUijrf+0ZNv3oYko2r8Kp9zgtg8b9RPL7DXHf15Ryc=";
};

nativeBuildInputs = [ cmake ];

meta = with lib; {
description = "Mesh compression library, designed for rendering and speed";
homepage = "https://github.com/cnr-isti-vclab/corto";
license = licenses.mit;
maintainers = with maintainers; [ nim65s ];
};
}
31 changes: 31 additions & 0 deletions pkgs/by-name/li/libigl/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
lib,
stdenvNoCC,
fetchFromGitHub,
}:

stdenvNoCC.mkDerivation (finalAttrs: {
pname = "libigl";
version = "2.5.0";

src = fetchFromGitHub {
owner = "libigl";
repo = "libigl";
rev = "v${finalAttrs.version}";
hash = "sha256-OpjkQGRiuc7kNlwgCeM4dcotTb5J+6LUn4IOe9bFbW4=";
};

# We could also properly use CMake, but we would have to heavily patch it
# to avoid configure-time downloads of many things.
installPhase = ''
mkdir -p $out/include
cp -r include/igl $out/include
'';

meta = with lib; {
description = "Simple C++ geometry processing library";
homepage = "https://github.com/libigl/libigl";
license = licenses.mpl20;
maintainers = with maintainers; [ nim65s ];
};
})
59 changes: 59 additions & 0 deletions pkgs/by-name/op/openctm/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
lib,
stdenv,
fetchurl,
pkg-config,
freeglut,
gtk2,
libGLU,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "openctm";
version = "1.0.3";

src = fetchurl {
url = "https://downloads.sourceforge.net/project/openctm/OpenCTM-${finalAttrs.version}/OpenCTM-${finalAttrs.version}-src.tar.bz2";
hash = "sha256-So0mCNlzZPfuxWt8Y3xWuTCK6YKGs+kNu3QTyQ6UPx0=";
};

outputs = [
"bin"
"dev"
"man"
"out"
];

nativeBuildInputs = [ pkg-config ];

buildInputs = [
freeglut
gtk2
libGLU
];

postPatch = ''
substituteInPlace tools/tinyxml/Makefile.linux \
--replace-warn "-Wno-format" "-Wno-format -Wno-format-security"
substituteInPlace tools/Makefile.linux \
--replace-warn "-lglut" "-lglut -lGL -lGLU"
'';

makeFlags = [
"BINDIR=$(bin)/bin/"
"INCDIR=$(dev)/include/"
"LIBDIR=$(out)/lib/"
"MAN1DIR=$(man)/share/man//man1"
];

makefile = if stdenv.isDarwin then "Makefile.macosx" else "Makefile.linux";

preInstall = "mkdir -p $bin/bin $dev/include $out/lib $man/share/man/man1";

meta = with lib; {
description = "File format, software library and a tool set for compression of 3D triangle meshes";
homepage = "https://sourceforge.net/projects/openctm/";
license = licenses.zlib;
maintainers = with maintainers; [ nim65s ];
};
})
18 changes: 5 additions & 13 deletions pkgs/development/libraries/embree/default.nix
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
{ stdenv, lib, fetchFromGitHub, fetchpatch, cmake, pkg-config, ispc, tbb, glfw,
{ stdenv, lib, fetchFromGitHub, cmake, pkg-config, ispc, tbb, glfw,
openimageio, libjpeg, libpng, libpthreadstubs, libX11, glib }:

stdenv.mkDerivation rec {
pname = "embree";
version = "3.13.5";
version = "4.3.1";

src = fetchFromGitHub {
owner = "embree";
repo = "embree";
rev = "v${version}";
sha256 = "sha256-tfM4SGOFVBG0pQK9B/iN2xDaW3yjefnTtsoUad75m80=";
sha256 = "sha256-gQPlk0bDn04s2pncF22m/OpIbzF3NXKkRCZbmxfXEY4=";
};

patches = [
(fetchpatch {
name = "fixed-compilation-issues-for-arm-aarch64-processor-under-linux.patch";
url = "https://github.com/embree/embree/commit/82ca6b5ccb7abe0403a658a0e079926478f04cb1.patch";
hash = "sha256-l9S4PBk+yQUypQ22l05daD0ruouZKE4VHkGvzKxkH4o=";
})
];

postPatch = ''
# Fix duplicate /nix/store/.../nix/store/.../ paths
sed -i "s|SET(EMBREE_ROOT_DIR .*)|set(EMBREE_ROOT_DIR $out)|" \
common/cmake/embree-config.cmake
sed -i "s|$""{EMBREE_ROOT_DIR}/||" common/cmake/embree-config.cmake
substituteInPlace common/math/math.h --replace 'defined(__MACOSX__) && !defined(__INTEL_COMPILER)' 0
substituteInPlace common/math/math.h --replace 'defined(__WIN32__) || defined(__FreeBSD__)' 'defined(__WIN32__) || defined(__FreeBSD__) || defined(__MACOSX__)'
substituteInPlace common/math/emath.h --replace 'defined(__MACOSX__) && !defined(__INTEL_COMPILER)' 0
substituteInPlace common/math/emath.h --replace 'defined(__WIN32__) || defined(__FreeBSD__)' 'defined(__WIN32__) || defined(__FreeBSD__) || defined(__MACOSX__)'
'';

cmakeFlags = [
Expand Down
Loading

0 comments on commit 3773b49

Please sign in to comment.