Build and test ITK

The CMake build system was initially created to support development of ITK; ITK is built following standard CMake practices.

ITK’s tests are defined with CTest, and the tests can be executed via ctest.

FFTW

Enable ITK_USE_FFTWF for single precision or ITK_USE_FFTWD for double precision. Either option adds the ITKFFTW third-party module to ITKFFT. Enabling Module_ITKFFTW with neither option is a configuration error. FFTW is GPL licensed; linking it changes the licensing requirements of the resulting binaries.

By default, ITKFFTW downloads FFTW 3.3.10 at configuration time with CMake FetchContent. Both precisions share one source download and use separate build directories. Set FETCHCONTENT_SOURCE_DIR_FFTW to an unpacked FFTW source directory to build offline, or set ITK_USE_SYSTEM_FFTW=ON to use an installed library instead.

FFTW_ENABLE_NEON, FFTW_ENABLE_SSE, FFTW_ENABLE_SSE2, FFTW_ENABLE_AVX, and FFTW_ENABLE_AVX2 control SIMD codelets. Defaults follow the target architecture and compiler flags, not the build host. Link consumers to ITK::ITKFFTModule to inherit FFTW dependencies.

Pixi

An easy and reproducible way to build and test ITK for development is via Pixi. Pixi will provide locally-scoped build tools such as toolchains, cmake, ninja, and python.

First, install pixi,

curl -fsSL https://pixi.sh/install.sh | bash

PowerShell:

iwr -useb https://pixi.sh/install.ps1 | iex

winget:

winget install prefix-dev.pixi

or use another pixi installation option.

You might need to restart your terminal or source your shell for the changes to take effect.

ITK’s Pixi configuration uses the conda-forge compiler and the Ninja CMake generator.

Test C++

To configure, build, and run ITK’s C++ tests,

# Change to the ITK source directory
cd src/ITK

pixi run test

Test Python

To configure, build, and run ITK’s Python bindings and run the Python and C++ tests,

# Change to the ITK source directory
cd src/ITK

pixi run test-python

To run a python interpreter with the locally built itk Python package:

pixi run python-exe

A Python script can also be passed in, e.g.

pixi run python-exe ./test.py

To run a python interpreter with a locally built itk Python package with debug symbols,

pixi run python-exe-debug

Further testing and development

Additional pixi tasks to run specific steps of the configure, build, test development process or create builds with other CMake build types are listed with

pixi task list

To start up a shell environment with all build dependencies:

pixi shell

Once in the pixi shell, cmake, ninja, ctest, etc can be executed in the local build/ directory containing the build to perform targeted development.