308.6. gmsh-4.15.2
3D finite element mesh generator with CAD, meshing and post-processing (FLTK)
| Version | 4.15.2, release 2 |
| Shelf | cad — Mechanical, architectural and 2D CAD, geometry kernels, meshing and FEM |
| Phase | 44_apps (Applications), 27 of 422 in build order |
| Licence | GPL-2.0-or-later |
| Homepage | https://gmsh.info/ |
| Build time | 13.8 SBU |
| Installed size | 44.9 MiB in 547 files |
| Recipe | ports/core/cad/gmsh/kpkgbuild |
About
Gmsh is a finite-element mesh generator: it reads or builds a geometry, through its own .geo scripting language or OpenCASCADE’s CAD kernel (STEP, IGES, BRep), meshes it in one, two or three dimensions, and displays the results a solver writes back. The port builds the FLTK interface, the shared library libgmsh and its Python API, so a script can import gmsh.
Sources
gmsh-4.15.2.tgz(17.6 MiB)
sha256be3f66f225d27ba9fa014f07e83169285da8a051b0e8ab7103d88066b39bdd3e
upstream: https://gmsh.info/src/gmsh-4.15.2-source.tgz
archive copy: sources-1/cad--gmsh-4.15.2.tgz
Dependencies
Depends on: cmake, ninja, pkgconf, fltk, opencascade, eigen, tinyxml2, gmp, cairo, fontconfig, freetype2, libX11, libXext, libXft, libXinerama, libXfixes, libXcursor, libXrender, mesa, libglvnd, glu, libjpeg-turbo, libpng, zlib, python3, librsvg, libmed, hdf5.
Required by: no port names it.
Optional, off in KDOS
These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.
-DENABLE_POPPLER=OFF, line 34: poppler (explained with the switches below)
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/44_apps/phase.env && kpkg install gmsh'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/cad/gmsh.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/cad/gmsh
echo 'be3f66f225d27ba9fa014f07e83169285da8a051b0e8ab7103d88066b39bdd3e gmsh-4.15.2.tgz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/gmsh
SRC=$SRC_ROOT/gmsh-4.15.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf gmsh-4.15.2.tgz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
export CXXFLAGS="$CXXFLAGS $(pkg-config --cflags cairo)"
cmake -S . -B build -G Ninja \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DENABLE_BUILD_SHARED=ON \
-DENABLE_BUILD_DYNAMIC=ON \
-DENABLE_FLTK=ON \
-DENABLE_CAIRO=ON \
-DENABLE_OCC=ON \
-DENABLE_OCC_CAF=ON \
-DENABLE_SYSTEM_CONTRIB=ON \
-DENABLE_EIGEN=ON \
-DENABLE_GMP=ON \
-DENABLE_OPENMP=ON \
-DENABLE_MED=ON \
-DENABLE_CGNS=OFF \
-DENABLE_MMG=OFF \
-DENABLE_PETSC=OFF \
-DENABLE_SLEPC=OFF \
-DENABLE_MUMPS=OFF \
-DENABLE_MPI=OFF \
-DENABLE_POPPLER=OFF \
-DENABLE_OSMESA=OFF \
-DENABLE_TESTS=OFF \
-DENABLE_RPATH=OFF \
-DENABLE_PACKAGE_STRIP=OFF \
-DCMAKE_REQUIRE_FIND_PACKAGE_HDF5=ON
grep -q '^#define HAVE_MED' build/src/common/GmshConfig.h ||
{ echo "gmsh: MED was not found" >&2; exit 1; }
grep -q '^TINYXML2_LIB:FILEPATH=/usr/lib/libtinyxml2' build/CMakeCache.txt
cmake --build build
DESTDIR=$PKG cmake --install build
_site=$(python3 -c 'import sysconfig; print(sysconfig.get_path("purelib"))')
install -d "$PKG$_site"
mv "$PKG/usr/lib/gmsh.py" "$PKG$_site/gmsh.py"
rm -f "$PKG/usr/lib/gmsh.jl"
install -Dm644 utils/icons/gmsh.svg "$PKG/usr/share/icons/hicolor/scalable/apps/gmsh.svg"
install -d "$PKG/usr/share/icons/hicolor/256x256/apps"
rsvg-convert -w 256 -h 256 utils/icons/gmsh.svg \
-o "$PKG/usr/share/icons/hicolor/256x256/apps/gmsh.png"
install -Dm644 utils/freedesktop/info.gmsh.gmsh.metainfo.xml \
"$PKG/usr/share/metainfo/info.gmsh.gmsh.metainfo.xml"
install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/info.gmsh.gmsh.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=Gmsh
GenericName=Mesh Generator
Comment=Three-dimensional finite element mesh generator with pre- and post-processing
Exec=gmsh %F
Icon=gmsh
Terminal=false
StartupWMClass=gmsh
Categories=Science;Engineering;NumericalAnalysis;
Keywords=mesh;finite;element;fem;cad;step;geo;
DESKTOP
chmod 644 "$PKG/usr/share/applications/info.gmsh.gmsh.desktop"
The switches, and why each is set:
CXXFLAGS="$CXXFLAGS $(pkg-config --cflags cairo)"— add Cairo’s include directories to the C++ flags. The fltk port is built with Cairo support, and itsFL/Fl.Hthen includes, throughFL/Fl_Cairo.H,<cairo.h>with no directory, which only-I/usr/include/cairoresolves; Gmsh’s own Cairo check adds only the directory above it, for its<cairo/cairo.h>.-DENABLE_BUILD_SHARED=ON— buildlibgmsh.so, and with-DENABLE_BUILD_DYNAMIC=ONlink thegmshprogram against it rather than statically. Both are off by default upstream. The Python API,gmsh.py, is a ctypes wrapper that loads this library, and upstream installs the API files only when one of the library targets is enabled.-DENABLE_FLTK=ON— the graphical interface, upstream’s default, named; with-DENABLE_CAIRO=ONit renders fonts through Cairo, which upstream marks experimental.-DENABLE_OCC=ON— the OpenCASCADE CAD kernel, and with-DENABLE_OCC_CAF=ONits CAF layer, which carries the names and colours of STEP and IGES entities. Both are upstream’s defaults.-DENABLE_SYSTEM_CONTRIB=ON— prefer system copies of the libraries Gmsh carries undercontrib/. Of those, the tree has eigen and tinyxml2; the rest (ANN, ALGLIB, MathEx, METIS, Voro++, gmm) are not ports and stay the bundled ones. Off by default upstream.-DENABLE_EIGEN=ON— linear algebra with Eigen instead of BLAS and LAPACK, upstream’s default;-DENABLE_GMP=ON(GMP for the Kbipack homology code) and-DENABLE_OPENMP=ONare upstream’s defaults too, named.-DENABLE_MED=ON— the MED mesh and post-processing formats, through libmed and hdf5. Upstream enables it only if both are found, and thegrepafter the configure stops the build whenGmshConfig.hlacksHAVE_MED.-DENABLE_CGNS=OFF— withENABLE_MMG,ENABLE_PETSC,ENABLE_SLEPC,ENABLE_MUMPSandENABLE_MPI, the optional interfaces to libraries the tree does not carry: CGNS files, Mmg mesh adaptation, the PETSc and MUMPS solvers, SLEPc eigensolvers and MPI. CGNS and Mmg are on by default upstream and would be used if found; the others are off by default.-DENABLE_POPPLER=OFF— no PDF display inside the interface, an experimental feature that is off by default upstream;-DENABLE_OSMESA=OFF, likewise off by default, leaves out offscreen rendering through OSMesa.-DENABLE_TESTS=OFF— skip the test suite, which upstream enables by default.-DENABLE_RPATH=OFF— no RPATH in the program and library. Upstream’s default writes the install’s library directory,/usr/lib, plus the directory of every library it links from outside the build tree; here those are all on the loader’s default path, an entry the package lint warns about.-DENABLE_PACKAGE_STRIP=OFF— upstream’s switch for stripping CPack packages. The port usescmake --install, not CPack, so it changes nothing here.-DCMAKE_REQUIRE_FIND_PACKAGE_HDF5=ON— make a missing HDF5 a configure error. Upstream looks for it without requiring it and leaves MED out when it is absent.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/gmsh, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf gmsh-4.15.2-2.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/gmsh, and runs the triggers its paths call for.
Contents
Installed programs: gmsh, onelab.py.
Installed libraries: libgmsh.so.
Installed directories: /usr/lib/gmsh-4.15.2.dev1.dist-info, /usr/share/doc/gmsh, /usr/share/gmsh, /usr/share/licenses/gmsh.
Short descriptions
gmsh |
3D finite element mesh generator with built-in CAD engine and post-processor |
Notes
Two checks after the configure guard the result: HAVE_MED in build/src/common/GmshConfig.h, and TINYXML2_LIB in CMakeCache.txt naming /usr/lib/libtinyxml2, so neither the MED support nor the system tinyxml2 can drop out in silence.
Upstream installs gmsh.py and the Julia binding gmsh.jl beside the library in /usr/lib. build.sh moves gmsh.py into Python’s site-packages and deletes gmsh.jl; the tree has no Julia. The module loads the library by a name carrying Gmsh’s major and minor version, libgmsh.so.4.15 for 4.15.2, and looks for it beside itself and in the two directories above it; from /usr/lib/python3.x/site-packages the second of those is /usr/lib, so the moved module still finds it. The 256-pixel icon is rendered from upstream’s SVG with rsvg-convert, which is why librsvg is in depends.