nixpkgs/pkgs/applications/science/math/gmsh/default.nix
Sergei Trofimovich 775c761fd8 gmsh: pull gcc-13 build fix from upstream
Without the change `gmsh` build fails in `staging-next` as:

    /build/gmsh-4.11.1-source/src/mesh/meshGFacePack.cpp:209:7: error: 'uint32_t' was not declared in this scope
      209 |   for(uint32_t j = 0; j < 6; j++) {
          |       ^~~~~~~~
    /build/gmsh-4.11.1-source/src/mesh/meshGFacePack.cpp:16:1: note: 'uint32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
       15 | #include "robustPredicates.h"
      +++ |+#include <cstdint>
2024-01-01 20:30:30 +00:00

71 lines
2.2 KiB
Nix

{ lib, stdenv, fetchurl, fetchpatch, cmake, blas, lapack, gfortran, gmm, fltk, libjpeg
, zlib, libGL, libGLU, xorg, opencascade-occt
, python ? null, enablePython ? false }:
assert (!blas.isILP64) && (!lapack.isILP64);
assert enablePython -> (python != null);
stdenv.mkDerivation rec {
pname = "gmsh";
version = "4.11.1";
src = fetchurl {
url = "https://gmsh.info/src/gmsh-${version}-source.tgz";
sha256 = "sha256-xf4bfL1AOIioFJKfL9D11p4nYAIioYx4bbW3boAFs2U=";
};
buildInputs = [
blas lapack gmm fltk libjpeg zlib opencascade-occt
] ++ lib.optionals (!stdenv.isDarwin) [
libGL libGLU xorg.libXrender xorg.libXcursor xorg.libXfixes
xorg.libXext xorg.libXft xorg.libXinerama xorg.libX11 xorg.libSM
xorg.libICE
] ++ lib.optional enablePython python;
enableParallelBuilding = true;
patches = [
./fix-python.patch
# Pull upstream fix git gcc-13:
# https://gitlab.onelab.info/gmsh/gmsh/-/issues/2416
(fetchpatch {
name = "gcc-13-p1.patch";
url = "https://gitlab.onelab.info/gmsh/gmsh/-/commit/fb81a9c9026700e078de947b4522cb39e543a86b.patch";
hash = "sha256-1GInFqQZvOgflC3eQTjmZ9uBGFASRNCpCwDACN3yTQ4=";
})
(fetchpatch {
name = "gcc-13-p2.patch";
url = "https://gitlab.onelab.info/gmsh/gmsh/-/commit/aceb09c807b78ea26555f99fcb16c4f87c31fb5a.patch";
hash = "sha256-6FI0hIvj8hglCvxoKV0GzT2/F/Wz+ddkxV/TLzzJBLU=";
})
];
postPatch = ''
substituteInPlace api/gmsh.py --subst-var-by LIBPATH ${placeholder "out"}/lib/libgmsh.so
'';
# N.B. the shared object is used by bindings
cmakeFlags = [
"-DENABLE_BUILD_SHARED=ON"
"-DENABLE_BUILD_DYNAMIC=ON"
"-DENABLE_OPENMP=ON"
];
nativeBuildInputs = [ cmake gfortran ];
postFixup = lib.optionalString enablePython ''
mkdir -p $out/lib/python${python.pythonVersion}/site-packages
mv $out/lib/gmsh.py $out/lib/python${python.pythonVersion}/site-packages
mv $out/lib/*.dist-info $out/lib/python${python.pythonVersion}/site-packages
'';
doCheck = true;
meta = {
description = "A three-dimensional finite element mesh generator";
homepage = "https://gmsh.info/";
license = lib.licenses.gpl2Plus;
};
}