Skip to content

Helpful scripts and modules for CMake, especially for scientific computing, HPC, and Fortran

License

Notifications You must be signed in to change notification settings

scivision/cmakeutils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Mar 24, 2021
01a86ae · Mar 24, 2021
Oct 16, 2020
Mar 24, 2021
Mar 24, 2021
Mar 24, 2021
Jan 3, 2021
Mar 24, 2021
Mar 24, 2021
Mar 24, 2021
Nov 30, 2020
Mar 24, 2021
Mar 24, 2021
Mar 24, 2021
Mar 24, 2021
Mar 24, 2021
Mar 24, 2021
Jan 10, 2021
Jul 9, 2019
Jan 3, 2021
May 20, 2020
Nov 9, 2020
Mar 24, 2021
Mar 24, 2021
Jun 12, 2019
Feb 1, 2021
Mar 24, 2021
Mar 24, 2021
Feb 9, 2021
Mar 24, 2021
Mar 24, 2021
Aug 4, 2020
Mar 24, 2021
Sep 11, 2020

Repository files navigation

CMake Utils

DOI Language grade: Python PyPi versions PyPi Download stats

Actions Status

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 install_cmake.cmake

if you need to compile CMake from source, for example on BSD or ARM 32-bit using existing CMake >= 3.13:

cmake -P build_cmake.cmake

Install

pip install cmakeutils

or

git clone https://github.com/scivision/cmakeutils
pip install -e cmakeutils

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 -m cmakeutils.graph ~/myprog/gfx

Install CMake binary

cmake_setup

takes only a minute to install binary and includes cmake-gui. It works for Linux, MacOS, native Windows and Windows Subsystem for Linux.

Ninja is strongly recommended in general for use with CMake on Windows, Mac and Linux:

ninja_setup

Build CMake

CMake can be builts from source using either:

  • older version of CMake,
  • without CMake using the "bootstrap" method

The bootstrap method is only for Unix-like systems, while the CMake-based build can also be used on Windows. Any platform for which Kitware doesn't distribute binaries use this script, including IBM Power and ARM.

cmake_compile

This downloads the latest CMake release source and builds from scratch.

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.

GNU Octave

Octave from CMake via our FindOctave.cmake works well from CMake for unit tests, liboctave, etc. for Octave ≥ 3.8. We didn't try older versions of Octave.

Matlab

One-time setup: if you've never used mex before, you must setup the C++ compiler. It doesn't hurt to do this again if you're not sure. From Matlab:

mex -setup -client engine C++

Will ask you to select a compiler, or simply return:

ENGINE configured to use 'g++' for C++ language compilation.