cpptensor/Installation
Installation
Clone cpptensor, set up its conda environment, and build with CMake presets or the manual workflow.
cpptensor builds with CMake and ships a conda environment that pins its
toolchain and dependencies. The commands below use that dedicated environment.
Requirements
- CMake ≥ 3.26 (for the
CMakePresets.jsonworkflows) - A C++ compiler with C++26 support
- Ninja or Make
- Git (for submodules)
Clone
git clone --recurse-submodules https://github.com/Research-Commons/cpptensor.git
cd cpptensorSubmodules
Pass --recurse-submodules. If you already cloned without it, run
git submodule update --init --recursive.
Set up the conda environment
# First-time setup:
conda env create -f environment.yml
# Updating an existing environment:
conda env update -n cpptensor -f environment.yml --pruneBuild with CMake presets (recommended)
Run configure + build + test in a single command:
conda run -n cpptensor cmake --workflow --preset devThis executes configure/build/test in build/dev. Other presets:
# CI-style test workflow
conda run -n cpptensor cmake --workflow --preset ci
# Release build
conda run -n cpptensor cmake --preset release
conda run -n cpptensor cmake --build --preset release
# Benchmarks (CPU target build)
conda run -n cpptensor cmake --preset benchmark
conda run -n cpptensor cmake --build --preset benchmarkManual CMake workflow
If you prefer not to use presets:
conda run -n cpptensor cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCPPTENSOR_BUILD_TESTS=ON \
-DCPPTENSOR_BUILD_EXAMPLES=ON \
-DCPPTENSOR_BUILD_BENCHMARKS=ON
conda run -n cpptensor cmake --build build -j
conda run -n cpptensor ctest --test-dir build --output-on-failureTests, examples, and benchmarks are opt-in (all default to OFF). For a
library-only configure:
conda run -n cpptensor cmake -S . -B buildInstall + consume downstream
conda run -n cpptensor cmake -S . -B build
conda run -n cpptensor cmake --build build
conda run -n cpptensor cmake --install build --prefix /tmp/cpptensor-installThen, from another CMake project:
find_package(cpptensor CONFIG REQUIRED)
target_link_libraries(your_target PRIVATE cpptensor::cpptensor)Next
Head to the Quickstart, and see Build options for the full set of flags.