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