CMB Superbuild working for Ubuntu and Gentoo

I was quite interested in trying CMB, the computational model builder from Kitware. Kitware also provides Paraview, one of the best all around post-processing tools I’ve ever used.

Note that the team at Kitware provide a significant level of support and responsiveness! Thanks to them! The thread where we debugged some of the issues can be found here.

Clone, install dependencies, and compile

My primary machines are Gentoo, however, I have a graduate student considering the use of CMB for his thesis. Hence, we also wanted to use Ubuntu as well as Ubuntu WSL to ease the transition.

On Ubuntu, the following provided necessary dependencies including compilers and libraries.

sudo apt install cmake cmake-curses-gui libboost-all-dev libfreetype-dev qtbase5-dev libqt5svg5-dev libqt5x11extras5-dev libqt5help5 qttools5-dev libclang-dev libxkbcommon-x11-dev qtxmlpatterns5-dev-tools libqt5webkit5-dev libxcursor-dev libbz2-dev ninja-build build-essential libxml2-dev libglvnd-dev gcc-12 g++-12

On Gentoo, I already had all the required dependencies installed. (Though they can be inferred from the above.)

Current assumptions:

The superbuild of CMB is rather complex with many dependencies and options. We want to use as many system libraries as possible to minimize the build effort, however, incompatibilities forced some source builds (managed by the superbuild). For consistency among Ubuntu and Gentoo, we found the following assumptions to work.

  • System libraries rebuilt and locally linked by the superbuild
    • hdf5 (System serial, openmpi, and mpich versions on Gentoo don’t work with the superbuild due to Paraview/hdf5/mpi build incompatibilities. It is easier to just build again.)
    • netcdf (on Gentoo, system netcdf doesn’t work because of mpi and pnetcdf confusion)
    • boost (cmake did not find the system boost, hence boost is built for simplicity)

Clone

FWIW, we generally want to use a release build, but inconsistencies among the superbuild sub-modules versions made us switch to the master branch (commit d4d8c364f34).

git clone https://gitlab.kitware.com/cmb/cmb-superbuild.git
cd cmb-superbuild/
git checkout master
git submodule update --init
cd ..

Create a build directory and configure with cmake. (Note CMB builds VTK, and VTK from the superbuild won’t build currently with gcc-13. Hence, specify gcc-12 explicitly.)

mkdir build
cd build

CC=/usr/bin/gcc-12 \
CXX=/usr/bin/g++-12 \
cmake -GNinja -Wno-dev \
	-DBUILD_TESTING=0 \
	-DDEVELOPER_MODE_cmb=0 \
	-DDEVELOPER_MODE_smtk=0 \
	-DENABLE_cmbworkflows=1 \
	-DENABLE_DOCUMENTATION=0 \
	-DUSE_SYSTEM_boost=0 \
	-DUSE_SYSTEM_bzip2=1 \
	-DUSE_SYSTEM_freetype=1 \
	-DUSE_SYSTEM_hdf5=0 \
	-DUSE_SYSTEM_libxml2=1 \
	-DUSE_SYSTEM_netcdf=0 \
	-DUSE_SYSTEM_pkgconf=1 \
	-DUSE_SYSTEM_png=1 \
	-DUSE_SYSTEM_python3=0 \
	-DUSE_SYSTEM_qt5=1 \
	-DENABLE_qt5=0 \
	-DUSE_SYSTEM_sqlite=0 \
	-DUSE_SYSTEM_zlib=1 \
	-DENABLE_pythonsetuptoolsscm=1 \
	-DCMAKE_INSTALL_PREFIX=/home/pete/local \
	-DENABLE_vtk=1 \
	../cmb-superbuild/

ninja -j8

Running the code

After successful build, the code is executed thusly:

~/software/kitware-stuff/build$ ./install/bin/modelbuilder 

Modelbuilder running in a window

Issues left unresolved

gcc-13

With gcc-13, it was possible to build VTK with some patches. This was found when trying to build superbuild release tag v23.01.0. However, that was not building the units package for smtk, hence the effort was abandoned for the master branch commit d4d8c364f34. It has not been tested whether this can continue on master branch with gcc-13.

Don’t do this unless you are me, and you are investigating gcc-13 compatibility. This checks out my patches which are relative to VTK tag v9.2.5.

cd ~/software/kitware-stuff/build/superbuild/paraview/src/VTK
git remote add spitfire svpn:software/VTK
git fetch spitfire pete
git checkout spitfire/pete

Memory requirements

The Ubuntu virtual machine failed to build with an 8GB RAM virtual system, (it appears to be memory limits related to default compilation using lto). It did build with 32GB RAM system.

Compatibility

This was most recently tested using 23.10 LTS Mantic Minotaur. It completed successfully both on Ubuntu and Ubuntu WSL. Lastly, it completed on Gentoo, my daily driver.

You may check your Ubuntu install using the following:

lsb_release -a

For example:

pete@ubuntu:~/CalculiX$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:	Ubuntu 23.10
Release:	23.10
Codename:	mantic

Support open source maintenance!

Please donate to support the maintenance of our code!