test-page

Build with CMake

Table of contents

Introduction

CMake is an open-source and cross-platform building tool for software packages that provides easy managing of multiple build systems at a time. It works by allowing the developer to specify build parameters and rules in a simple text file that CMake then processes to generate project files for the actual native build tools (e.g. UNIX Makefiles, Microsoft Visual Studio, Apple XCode, etc). That means you can easily maintain multiple separate builds for one project and manage cross-platform hardware and software complexity.

If you are not already familiar with CMake, please refer to the official documentation or the CMake Wiki introduction (recommended).

Before using CMake you will need to install/build the binaries on your system. Most systems have CMake already installed or provided by the standard package manager. If that is not the case for you, please download and install now.

For building SLEEF, CMake 3.18 is the minimum required.

Quick start

  1. Make sure CMake is available. The following command line should display a version number greater than or equal to 3.18.
cmake --version
  1. Download the tar from sourceforge, GitHub releases, or checkout out the source code from the GitHub repository.
git clone https://github.com/shibatch/sleef
  1. Make separate directories to create out-of-source build and install. SLEEF does not allow for in-tree builds.
cd sleef
mkdir build
mkdir install
  1. Run CMake to configure your project and generate the system to build it.
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
      -DCMAKE_INSTALL_PREFIX=install/ \
      -S . -B build/

By default, CMake will detect your system platform and configure the build using the default parameters. You can control and modify these parameters by setting variables when running CMake. See the list of options and variables for customizing your build.

In the above example:

  1. Run make to build the project
cmake --build build -j --clean-first

NOTE: On Windows, you need to use a specific generator like this: cmake -G"Visual Studio 14 2015 Win64" .. specifying the Visual Studio version and targeting specifically Win64 (to support compilation of AVX/AVX2) Check cmake -G to get a full list of supported Visual Studio project generators. This generator will create a proper solution SLEEF.sln under the build directory. You can still use cmake --build build to build without opening Visual Studio.

  1. Run ctest suite (CMake 3.20+)
ctest --test-dir build -j

or for older CMake versions

cd build/ && ctest -j
  1. Install at path provided earlier or at new path <prefix>
cmake --install build/ [--prefix <prefix>]

Refer to our web page for detailed build instructions.

Build customization

Variables dictate how the build is generated; options are defined and undefined, respectively, on the CMake command line like this:

cmake -DVARIABLE=<value> <cmake-build-dir>
cmake -UVARIABLE <cmake-build-dir>

Build configurations allow a project to be built in different ways for debug, optimized, or any other special set of flags.

CMake Variables

SLEEF Variables

Library

Tests

Quad and DFT

Vector extensions and instructions