Getting Started | C++

Installation

Install trueform — via pip, system install, or CMake FetchContent.

Requirements

Installing TBB

brew install tbb
If TBB is in a non-standard location:
cmake -B build -DTBB_ROOT=/path/to/tbb

pip install

The easiest way to get trueform C++ headers is via pip. This installs both Python bindings and C++ headers:

pip install trueform

CMake Integration

Use the header-only library as a CMake package:

CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(my_app LANGUAGES CXX)

find_package(trueform REQUIRED CONFIG)

add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE tf::trueform)

Configure your build so CMake can find the package installed by pip:

cmake -B build -Dtrueform_ROOT=$(python -m trueform.cmake)
cmake --build build
You can also query paths directly:
  • python -m trueform.cmake — CMake config directory
  • python -m trueform.cmake --include_dir — C++ headers path
  • python -m trueform.cmake --cmake_dir — Same as default

System Install

Clone and install trueform system-wide:

git clone https://github.com/xlabmedical/trueform.git
cd trueform

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
cmake --install build --config Release

Then use find_package in your project:

CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(my_app LANGUAGES CXX)

find_package(trueform REQUIRED CONFIG)

add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE tf::trueform)
cmake -B build
cmake --build build
To install to a custom location:
cmake --install build --prefix ~/mylibs
Then configure with:
cmake -B build -DCMAKE_PREFIX_PATH=~/mylibs

CMake FetchContent

For a self-contained project without system installation:

CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(my_app LANGUAGES CXX)

include(FetchContent)

FetchContent_Declare(
  trueform
  GIT_REPOSITORY https://github.com/xlabmedical/trueform.git
  GIT_TAG        main
)

FetchContent_MakeAvailable(trueform)

add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE tf::trueform)
cmake -B build
cmake --build build
Pin to a specific version using a git tag or commit hash in GIT_TAG.

Verify Installation

main.cpp
#include <trueform/trueform.hpp>
#include <iostream>

int main() {
    auto pt = tf::make_point(1.0, 2.0, 3.0);
    std::cout << "trueform is working!" << std::endl;
    return 0;
}

VTK Integration

For VTK integration (tf::vtk), see the VTK documentation for build and installation instructions.