Skip to content

scivision/cmakeutils

Repository files navigation

CMake Utils

DOI ci

CMake is a powerful and easy to use build system for a wide variety of languages including:

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

convert CMake hierarchy .dot to SVG or PNG

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

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.

Build CMake

To compile CMake from source, for example on BSD or ARM 32-bit using existing CMake:

cmake -S build_cmake -B build

Requirements:

  • SSL library
  • C++ compiler
  • GNU Make or Ninja

Examples

  • Download with git using FetchContent
  • Download and extract ZIP
  • measure system parameters with CMake. Note Cygwin reports really small RAM and zero virtual memory.