FluidityProject / fluidity

Fluidity
http://fluidity-project.org
Other
362 stars 113 forks source link

ENH: Discuss inclusion of a CMake build #356

Open Patol75 opened 2 years ago

Patol75 commented 2 years ago

I am opening this PR to discuss a possible addition of a CMake build to Fluidity as an alternative to Autotools. The main motivation is the deprecation by CMake of the command-line argument --find-package (more details here) that was used in #125 to fix #113. This deprecation complicates building against recent VTK libraries using Autotools. Overall, it might be valuable to support CMake to avoid such issues, even though it is not impossible it brings issues of its own.

I will write the content of the PR later using the tree of file changes GitHub provides, summarising the changes I have made building on @jrper original build described in #115.

By no means the present PR should be merged as-is. If a CMake build is to be included in Fluidity, changes from this branch will likely be ported to another branch through targetted commits.

Useful URLs:

Patol75 commented 2 years ago

Given the massive changes included in the present branch, I have pushed another branch, called cmake_build_2022_minimal, which only contains a minimal changeset to allow for a CMake build and unit tests to successfully complete. Changes can be found here, and the associated successful Actions run here.

To summarise the changes, there is now a CMakeLists.txt file within most of Fluidity's sub-directories that contain source files. Additionally, Python packages are now installed in the user site-packages directory and can be accessed within the Python interpreter without having to set the PYTHONPATH environment variable.

Steps to build Fluidity from a fresh Jammy 22.04 installation are detailed in docker/Dockerfile.jammy. Packages are downloaded from the official Ubuntu package repositories using the latest versions available (e.g. VTK 9.1), except for GMSH and PETSc. The former is downloaded from the official website as a pre-built binary, while the latter is first cloned from the official release branch hosted on GitLab and then built.

Configure- and build-time instructions are mostly found in the CMakeLists.txt file at the root of Fluidity's directory. Programs/packages marked as required include HDF5, MPI, NetCDF, PETSc, Python 3, sed, TCMalloc, UDUNITS and VTK. Additionally, a few libraries are fetched over the network: libspatialindex is downloaded from the official GitHub repository and seamlessly integrated into Fluidity's build as it also uses CMake, while Judy and Zoltan are downloaded from their respective SourceForge and GitHub repositories and built according to provided instructions. The only environment variables required to be set by the user are PETSC_ARCH and PETSC_DIR.

Questions, comments, feedback and suggestions are all very much welcomed.

angus-g commented 2 years ago

Thanks for your work on this! I recommend switching the PR to the minimal branch, because this one is impossible to do a meaningful review on. I do think that having a CMake build system available is worthwhile, even just to avoid make makefiles!