Hi everyone,
I'd like to start a discussion about adding a CMake build to JOREK. I have a working prototype in my fork, and I'd like gathering some feedback.
Current Makefile situation
- On a new machine, the first step is usually finding a close-enough
Makefile.inc and editing it until things link.
- Dependency tracking relies on two Perl scripts (
util/makedepend and util/obj_deps). They scan use and call statements to determine dependencies and object files per executable. This requires module and subroutine names to match filenames, and no two files in DIRS to share a basename. Useless to say that this is not standard.
- Builds happen in the source tree (
.obj/, .mod/, .dep/), so only one configuration can exist at a time. Switching model or build type means rebuilding from scratch.
MPI_VERSION is determined by writing, compiling, and running a small Fortran program, then parsing its output.
- Compiler detection relies on
$(FC) --version | grep ..., while Intel version checks use the shell and bc.
None of this is broken and it has worked for years, and people familiar with it know how to use it. But it is custom and can be prone to bugs.
Why CMake
CMake is an open-source, cross-platform build system. It uses compiler-independent configuration files and generates native build files for Make or IDEs.
What's the advantage for us:
- CMake handles module dependencies, replacing
util/makedepend. Building non-program sources into one static library also lets the linker determine what each executable needs, replacing util/obj_deps. Filename conventions would no longer be required.
- Standard dependency discovery.
find_package can handle MPI, HDF5, and BLAS/LAPACK rather than hand-written link lines. MPI_VERSION comes from FindMPI. Paths are still needed for sparse solvers such as STRUMPACK, MUMPS, PaStiX, METIS, and PARMETIS.
- Debug, release builds, or different models, can coexist without rebuilding everything.
- Versioned machine configurations. Cluster configurations could be kept in only one place in the repository through
CMakePresets.json. cmake --list-presets shows the available configurations, and presets can record the required module load command.
- CI, regression tests, and development tools become easier to integrate. CTest can be used to wire up regression tests and CI, while compile_commands.json improves support for code editors and language servers. This is part of a broader effort to modernise the codebase, simplify development, and align more closely with common software-engineering practices.
- It represents a fundation for future GPU work.
- CMake is widely used, so most students and newcomers will already have encountered it as a build tool.
What I have
Here I have a first working version. For this I've already:
- Tested the compilation for all the targets with Intel oneAPI + MKL + STRUMPACK + HDF5 on Pitagora, TOK, and Viper. The resulting binary ran model600 for both fluid-only and fluid+kinetic.
- Instructions on the new workflow can be found here.
- I dind't check MUMPS and PASTiX or other compilers.
It would be great if people can take a look at it and try it out so we can find out what's missing.
For now the idea is to keep the two build systems in parallel for a transition period and gradually move to CMake.
What people think about it?
Hi everyone,
I'd like to start a discussion about adding a CMake build to JOREK. I have a working prototype in my fork, and I'd like gathering some feedback.
Current Makefile situation
Makefile.incand editing it until things link.util/makedependandutil/obj_deps). They scanuseandcallstatements to determine dependencies and object files per executable. This requires module and subroutine names to match filenames, and no two files inDIRSto share a basename. Useless to say that this is not standard..obj/,.mod/,.dep/), so only one configuration can exist at a time. Switching model or build type means rebuilding from scratch.MPI_VERSIONis determined by writing, compiling, and running a small Fortran program, then parsing its output.$(FC) --version | grep ..., while Intel version checks use the shell andbc.None of this is broken and it has worked for years, and people familiar with it know how to use it. But it is custom and can be prone to bugs.
Why CMake
CMake is an open-source, cross-platform build system. It uses compiler-independent configuration files and generates native build files for Make or IDEs.
What's the advantage for us:
util/makedepend. Building non-program sources into one static library also lets the linker determine what each executable needs, replacingutil/obj_deps. Filename conventions would no longer be required.find_packagecan handle MPI, HDF5, and BLAS/LAPACK rather than hand-written link lines.MPI_VERSIONcomes fromFindMPI. Paths are still needed for sparse solvers such as STRUMPACK, MUMPS, PaStiX, METIS, and PARMETIS.CMakePresets.json.cmake --list-presetsshows the available configurations, and presets can record the requiredmodule loadcommand.What I have
Here I have a first working version. For this I've already:
It would be great if people can take a look at it and try it out so we can find out what's missing.
For now the idea is to keep the two build systems in parallel for a transition period and gradually move to CMake.
What people think about it?