Installation
Universal is a header-only C++ template library with no external dependencies.
Requirements
Section titled “Requirements”- C++20 compiler (GCC 11+, Clang 14+, MSVC 2022+)
- CMake 3.22 or later
Install CMake
Section titled “Install CMake”Ubuntu/Debian:
sudo snap install cmake --classicPortable Linux:
wget https://github.com/Kitware/CMake/releases/download/v4.2.1/cmake-4.2.1-Linux-x86_64.shsudo sh cmake-4.2.1-Linux-x86_64.sh --prefix=/usr/local --exclude-subdirmacOS/Windows: Download the installer from cmake.org/download.
Build from Source
Section titled “Build from Source”git clone https://github.com/stillwater-sc/universalcd universalmkdir build && cd buildcmake ..make -j4make testCMake Build Options
Section titled “CMake Build Options”Use cmake-gui or ccmake to explore interactively, or set options on the command line:
# Build everythingcmake -DUNIVERSAL_BUILD_ALL=ON ..
# Build a specific number systemcmake -DUNIVERSAL_BUILD_NUMBER_POSITS=ON ..
# Enable AVX2 optimizationscmake -DUSE_AVX2=ON ..
# Build educational examplescmake -DUNIVERSAL_BUILD_EDUCATION=ON ..Using Universal in Your Project
Section titled “Using Universal in Your Project”Option 1: CMake find_package
Section titled “Option 1: CMake find_package”After installing Universal (make install):
project("my-numerical-experiment")find_package(UNIVERSAL CONFIG REQUIRED)
add_executable(${PROJECT_NAME} src/main.cpp)set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)target_link_libraries(${PROJECT_NAME} universal::universal)Option 2: Header-only include
Section titled “Option 2: Header-only include”Since Universal is header-only, you can simply add the include path:
g++ -std=c++20 -I/path/to/universal/include/sw my_program.cpp -o my_programInstall / Uninstall
Section titled “Install / Uninstall”# Install (default: /usr/local)cmake -DCMAKE_INSTALL_PREFIX=/your/path ..make install
# Uninstallmake uninstall