CMake is a powerful and easy to use build system for a wide variety of languages including:
- C / C++
- modern object-oriented Fortran 2008 / 2018
- Python
- Matlab / GNU Octave
It's important to use a recent CMake version to be effective and clean with CMake script. This can be done via the Python package described below, or from CMake >= 2.8.12 by:
cmake -P scripts/install_cmake.cmake
Ninja is recommended in general for use with CMake instead of Make:
cmake -P scripts/install_ninja.cmake
CMake plots dependency graphs for programs like:
cmake -B build --graphviz=gfx/block.dot
Then convert to PNG or SVG like:
python graph.py ~/myprog/gfx
Convert the resulting index.html with the SVGs to PDF like:
cmake -Dhtml=~/myprog/gfx/index.html -P html2pdf.cmake
CMake regular expressions have a distinct syntax tied to the origins of CMake syntax in the late 1990s. The CMake regex syntax is not the same as Python, Perl, etc. We give a few examples under regex.
Examples of project using CMake ExternalProject are under scripts/mpi. This project can be invoked to build OpenMPI or MPICH (each are Autotools projects):
cmake -S scripts/mpi -B build --install-prefix=$HOME/openmpi
cmake --build build
or by convenience scripts build_openmpi.cmake or build_mpich.cmake.
To compile CMake from source:
cmake -S scripts/build_cmake -B build
cmake --build build
Requirements:
- SSL library
- C++ compiler
- GNU Make or Ninja
- Download with git using FetchContent
- Download and extract ZIP
- measure system parameters with CMake. Note Cygwin reports really small RAM and zero virtual memory.